Package org.apache.oozie.util

Examples of org.apache.oozie.util.ELEvaluator


        createEval.setVariable(OozieClient.GROUP_NAME, "test_group");
    }

    @Test
    public void testActionExpressions() throws Exception {
        ELEvaluator eval = createActionStartEvaluator();
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${now(0, 0)}"), "2009-09-02T10:00Z");
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${now(1, 0)}"), "2009-09-02T11:00Z");

        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${today(0, 0)}"), "2009-09-02T00:00Z");
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${today(-1, 0)}"), "2009-09-01T23:00Z");
View Full Code Here


                "2009-Sep-02");
    }

    @Test
    public void testUser() throws Exception {
        ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("coord-action-start");
        eval.setVariable(OozieClient.USER_NAME, "test");
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${user()}"), "test");
    }
View Full Code Here

        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${user()}"), "test");
    }

    @Test
    public void testDataIn() throws Exception {
        ELEvaluator eval = createActionStartEvaluator();
        String uris = "hdfs://localhost:8020/clicks/2009/09/02/10,hdfs://localhost:8020/clicks/2009/09/02/09";
        eval.setVariable(".datain.clicks", uris);
        String expuris =
                "hdfs://localhost:8020/clicks/2009/09/02/10/*/US,hdfs://localhost:8020/clicks/2009/09/02/09/*/US";
        Assert.assertEquals(expuris, CoordELFunctions.evalAndWrap(eval, "${dataIn('clicks', '*/US')}"));

        //test optional input
        String inName = "clicks";
        SyncCoordDataset ds = createDataSet("2007-09-30T010:00Z");
        eval.setVariable(inName + ".frequency", String.valueOf(ds.getFrequency()));
        eval.setVariable(inName + ".freq_timeunit", ds.getTimeUnit().name());
        eval.setVariable(inName + ".timezone", ds.getTimeZone().getID());
        eval.setVariable(inName + ".end_of_duration", Timeunit.NONE.name());
        eval.setVariable(inName + ".initial-instance", DateUtils.formatDateOozieTZ(ds.getInitInstance()));
        eval.setVariable(inName + ".done-flag", "notused");
        eval.setVariable(inName + ".uri-template", ds.getUriTemplate());
        eval.setVariable(inName + ".start-instance", "now(-1,0)");
        eval.setVariable(inName + ".end-instance", "now(0,0)");
        // TODO Had to comment this out for this test to PASS else NPE in
        // TODO org.apache.oozie.command.coord.CoordCommandUtils.createEarlyURIs(CoordCommandUtils.java:359)
        // eval.setVariable(".datain.clicks", null);
        Assert.assertEquals(expuris, CoordELFunctions.evalAndWrap(eval, "${dataIn('clicks', '*/US')}"));
    }
View Full Code Here

        CoordELFunctions.configureEvaluator(createEval, ds, appInst);
    }

    private ELEvaluator createActionStartEvaluator() throws Exception {
        SyncCoordAction appInst = createCoordAction("2009-09-02T11:30Z", "2009-09-02T10:00Z");
        ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("coord-action-start");
        CoordELFunctions.configureEvaluator(eval, null, appInst);
        return eval;
    }
View Full Code Here

        createEval.setVariable(OozieClient.GROUP_NAME, "test_group");
    }

    @Test
    public void testActionExpressions() throws Exception {
        ELEvaluator eval = createActionStartEvaluator();
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${now(0, 0)}"), "2009-09-02T10:00Z");
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${now(1, 0)}"), "2009-09-02T11:00Z");

        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${today(0, 0)}"), "2009-09-02T00:00Z");
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${today(-1, 0)}"), "2009-09-01T23:00Z");
View Full Code Here

                "2009-Sep-02");
    }

    @Test
    public void testUser() throws Exception {
        ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("coord-action-start");
        eval.setVariable(OozieClient.USER_NAME, "test");
        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${user()}"), "test");
    }
View Full Code Here

        Assert.assertEquals(CoordELFunctions.evalAndWrap(eval, "${user()}"), "test");
    }

    @Test
    public void testDataIn() throws Exception {
        ELEvaluator eval = createActionStartEvaluator();
        String uris = "hdfs://localhost:8020/clicks/2009/09/02/10,hdfs://localhost:8020/clicks/2009/09/02/09";
        eval.setVariable(".datain.clicks", uris);
        String expuris =
                "hdfs://localhost:8020/clicks/2009/09/02/10/*/US,hdfs://localhost:8020/clicks/2009/09/02/09/*/US";
        Assert.assertEquals(expuris, CoordELFunctions.evalAndWrap(eval, "${dataIn('clicks', '*/US')}"));

        //test optional input
        String inName = "clicks";
        SyncCoordDataset ds = createDataSet("2007-09-30T010:00Z");
        eval.setVariable(inName + ".frequency", String.valueOf(ds.getFrequency()));
        eval.setVariable(inName + ".freq_timeunit", ds.getTimeUnit().name());
        eval.setVariable(inName + ".timezone", ds.getTimeZone().getID());
        eval.setVariable(inName + ".end_of_duration", Timeunit.NONE.name());
        eval.setVariable(inName + ".initial-instance", OozieELExtensions.formatDateUTC(ds.getInitInstance()));
        eval.setVariable(inName + ".done-flag", "notused");
        eval.setVariable(inName + ".uri-template", ds.getUriTemplate());
        eval.setVariable(inName + ".start-instance", "now(-1,0)");
        eval.setVariable(inName + ".end-instance", "now(0,0)");
        // TODO Had to comment this out for this test to PASS else NPE in
        // TODO org.apache.oozie.command.coord.CoordCommandUtils.createEarlyURIs(CoordCommandUtils.java:359)
        // eval.setVariable(".datain.clicks", null);
        Assert.assertEquals(expuris, CoordELFunctions.evalAndWrap(eval, "${dataIn('clicks', '*/US')}"));
    }
View Full Code Here

        CoordELFunctions.configureEvaluator(createEval, ds, appInst);
    }

    private ELEvaluator createActionStartEvaluator() throws Exception {
        SyncCoordAction appInst = createCoordAction("2009-09-02T11:30Z", "2009-09-02T10:00Z");
        ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("coord-action-start");
        CoordELFunctions.configureEvaluator(eval, null, appInst);
        return eval;
    }
View Full Code Here

    public static String ph1_dataIn_echo(String dataInName, String part) {
        return "dataIn('" + dataInName + "', '" + part + "')";
    }

    public static String ph3_dataIn(String dataInName, String part) {
        ELEvaluator eval = ELEvaluator.getCurrent();
        String uristr = (String) eval.getVariable(".datain." + dataInName);

        //optional input
        if (uristr == null) {
            Element dsEle = getDSElement(eval, dataInName);
            Configuration conf = new Configuration();
            SyncCoordAction appInst = (SyncCoordAction) eval.getVariable(CoordELFunctions.COORD_ACTION);
            try {
                ELEvaluator instEval = CoordELEvaluator.createInstancesELEvaluator(dsEle, appInst, conf);
                StringBuilder instances = new StringBuilder();
                CoordCommandUtils.resolveInstanceRange(dsEle, instances , appInst, conf, instEval);
                uristr = CoordCommandUtils.createEarlyURIs(dsEle, instances.toString(),
                        new StringBuilder(), new StringBuilder());
                uristr = uristr.replace(CoordELFunctions.INSTANCE_SEPARATOR, ",");
View Full Code Here

        return ele;
    }

    public static String ph1_now_echo(int hr, int min) {
        ELEvaluator eval = ELEvaluator.getCurrent();
        eval.setVariable(".wrap", "true");
        return "now(" + hr + "," + min + ")"; // Unresolved
    }
View Full Code Here

TOP

Related Classes of org.apache.oozie.util.ELEvaluator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.