Package com.asakusafw.runtime.core.context

Examples of com.asakusafw.runtime.core.context.RuntimeContext


     * Test for passing runtime context.
     * @throws Exception if failed
     */
    @Test
    public void inherit_context() throws Exception {
        RuntimeContext context = RuntimeContext.DEFAULT
            .mode(ExecutionMode.SIMULATION)
            .batchId("testbatch")
            .buildId("testverify");

        RuntimeContext.set(context);

        putScript(target, "libexec/check-context.sh", SshProfile.COMMAND_GET);
        Map<String, String> results = new HashMap<String, String>();
        JschConnection conn = new JschConnection(profile, Arrays.asList(profile.getGetCommand()));
        try {
            InputStream output = conn.openStandardOutput();
            conn.connect();
            Scanner s = new Scanner(output, "UTF-8");
            while (s.hasNextLine()) {
                String[] pair = s.nextLine().split("=", 2);
                if (pair.length == 2) {
                    results.put(pair[0], pair[1]);
                }
            }
            s.close();
            int exit = conn.waitForExit(10000);
            assertThat(exit, is(0));
        } finally {
            conn.close();
        }

        RuntimeContext restored = RuntimeContext.DEFAULT.apply(results);
        assertThat(results.toString(), restored, is(context));
    }
View Full Code Here


        HadoopScriptHandler handler = handler(
                "env.ASAKUSA_HOME", getAsakusaHome().getAbsolutePath(),
                "env.handler", "HANDLER",
                "env.override", "HANDLER");

        RuntimeContext rc = RuntimeContext.DEFAULT
            .batchId("b")
            .mode(ExecutionMode.SIMULATION)
            .buildId("OK");
        ExecutionContext context = new ExecutionContext("b", "f", "e", ExecutionPhase.MAIN, map(), rc.unapply());
        execute(context, script, handler);

        Map<String, String> map = new HashMap<String, String>();
        for (String line : getOutput(shell)) {
            if (line.trim().isEmpty()) {
View Full Code Here

        MockJobClient c1 = new MockJobClient("testing", COMPLETED);
        JobClientProfile profile = new JobClientProfile("testing", list(c1), 1000, 10);
        QueueHadoopScriptHandler handler = create();
        handler.doConfigure(profile);

        RuntimeContext rc = RuntimeContext.DEFAULT
            .batchId("b")
            .mode(ExecutionMode.SIMULATION)
            .buildId("OK");
        ExecutionContext context = new ExecutionContext(
                "b", "f", "e", ExecutionPhase.MAIN,
                Collections.<String, String>emptyMap(),
                rc.unapply());

        HadoopScript script = script();
        handler.execute(ExecutionMonitor.NULL, context, script);

        JobScript js = c1.registered.get("testing");
View Full Code Here

            Map<String, String> copyDefinitions,
            BatchScript script) {
        assert result != null;
        assert copyDefinitions != null;
        assert script != null;
        RuntimeContext rc = RuntimeContext.get().batchId(script.getId()).buildId(script.getBuildId());

        Ternary dryRunResult = consumeBoolean(copyDefinitions, KEY_VERIFY_DRYRUN);
        if (dryRunResult == Ternary.TRUE) {
            rc = rc.mode(ExecutionMode.SIMULATION);
        } else if (dryRunResult == Ternary.FALSE) {
            rc = rc.mode(ExecutionMode.PRODUCTION);
        }

        Ternary verify = consumeBoolean(copyDefinitions, KEY_VERIFY_APPLICATION);
        if (verify == Ternary.FALSE) {
            rc = rc.buildId(null);
        }

        result.runtimeContext = rc;
        result.getEnv().putAll(rc.unapply());
    }
View Full Code Here

                Arrays.asList(shell.getAbsolutePath()),
                map("script", "SCRIPT", "override", "SCRIPT"));

        CommandScriptHandler handler = handler("env.handler", "HANDLER", "env.override", "HANDLER");

        RuntimeContext rc = RuntimeContext.DEFAULT
            .batchId("b")
            .mode(ExecutionMode.SIMULATION)
            .buildId("OK");
        ExecutionContext context = new ExecutionContext("b", "f", "e", ExecutionPhase.MAIN, map(), rc.unapply());
        execute(context, script, handler);

        Map<String, String> map = new HashMap<String, String>();
        for (String line : getOutput(shell)) {
            if (line.trim().isEmpty()) {
View Full Code Here

        HadoopScriptHandler handler = handler(
                "env.ASAKUSA_HOME", getAsakusaHome().getAbsolutePath(),
                "env.handler", "HANDLER",
                "env.override", "HANDLER");

        RuntimeContext rc = RuntimeContext.DEFAULT
            .batchId("b")
            .mode(ExecutionMode.SIMULATION)
            .buildId("OK");
        ExecutionContext context = new ExecutionContext("b", "f", "e", ExecutionPhase.MAIN, map(), rc.unapply());
        execute(context, script, handler);

        Map<String, String> map = new HashMap<String, String>();
        for (String line : getOutput(shell)) {
            if (line.trim().isEmpty()) {
View Full Code Here

                Arrays.asList(shell.getAbsolutePath()),
                map("script", "SCRIPT", "override", "SCRIPT"));

        CommandScriptHandler handler = handler("env.handler", "HANDLER", "env.override", "HANDLER");

        RuntimeContext rc = RuntimeContext.DEFAULT
            .batchId("b")
            .mode(ExecutionMode.SIMULATION)
            .buildId("OK");
        ExecutionContext context = new ExecutionContext(
                "b", "f", "e", ExecutionPhase.MAIN, map(), rc.unapply());
        execute(context, script, handler);

        Map<String, String> map = new HashMap<String, String>();
        for (String line : getOutput(shell)) {
            if (line.trim().isEmpty()) {
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.core.context.RuntimeContext

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.