Package com.asakusafw.yaess.core

Examples of com.asakusafw.yaess.core.CommandScript


    private List<TestExecutionPlan.Command> resolveCommands(FlowScript flow, ExecutionPhase phase) throws IOException {
        ExecutionContext context = createExecutionContext(flow, phase);
        List<TestExecutionPlan.Command> results = new ArrayList<TestExecutionPlan.Command>();
        for (ExecutionScript script : flow.getScripts().get(phase)) {
            CommandScript resolved = (CommandScript) resolveScript(script, context);
            results.add(new TestExecutionPlan.Command(
                    resolved.getCommandLineTokens(),
                    resolved.getModuleName(),
                    resolved.getProfileName(),
                    resolved.getEnvironmentVariables()));
        }
        return results;
    }
View Full Code Here


        assert provider != null;
        assert commands != null;
        List<ExecutionScript> scripts = Lists.create();
        for (Command command : commands) {
            String profile = command.getProfileName();
            scripts.add(new CommandScript(
                    command.getId(),
                    Collections.<String>emptySet(),
                    profile == null ? CommandScript.DEFAULT_PROFILE_NAME : profile,
                    command.getModuleName(),
                    command.getCommandTokens(),
View Full Code Here

        Map<String, String> conf = createConf();
        declare(conf, "default", FailCommandScriptHandler.class);
        declare(conf, "other", FailCommandScriptHandler.class);
        CommandScriptHandlerDispatcher dispatcher = create(conf);

        CommandScript script = script("stage");
        ExecutionContext something = context("something", ExecutionPhase.MAIN);
        try {
            dispatcher.execute(ExecutionMonitor.NULL, something, script);
            fail();
        } catch (MessageException e) {
View Full Code Here

        declare(conf, "default", MockCommandScriptHandler.class);
        declare(conf, "match", MockCommandScriptHandler.class);
        CommandScriptHandlerDispatcher dispatcher = create(conf);

        ExecutionContext context = context("flow", ExecutionPhase.MAIN);
        CommandScript script = script("stage");

        assertThat(dispatcher.getResourceId(context, script), is("match"));

        ExecutionContext otherFlow = context("otherflow", ExecutionPhase.MAIN);
        assertThat(dispatcher.getResourceId(otherFlow, script), is("default"));

        ExecutionContext otherPhase = context("flow", ExecutionPhase.PROLOGUE);
        assertThat(dispatcher.getResourceId(otherPhase, script), is("default"));

        CommandScript otherScript = script("otherstage");
        assertThat(dispatcher.getResourceId(context, otherScript), is("default"));
    }
View Full Code Here

        declare(conf, "default", MockCommandScriptHandler.class);
        declare(conf, "match", MockCommandScriptHandler.class);
        CommandScriptHandlerDispatcher dispatcher = create(conf);

        ExecutionContext context = context("flow", ExecutionPhase.MAIN);
        CommandScript script = script("stage");
        assertThat(dispatcher.getResourceId(context, script), is("match"));

        ExecutionContext otherFlow = context("otherflow", ExecutionPhase.MAIN);
        assertThat(dispatcher.getResourceId(otherFlow, script), is("default"));

        ExecutionContext otherPhase = context("flow", ExecutionPhase.PROLOGUE);
        assertThat(dispatcher.getResourceId(otherPhase, script), is("default"));

        CommandScript otherScript = script("otherstage");
        assertThat(dispatcher.getResourceId(context, otherScript), is("match"));
    }
View Full Code Here

        declare(conf, "default", MockCommandScriptHandler.class);
        declare(conf, "match", MockCommandScriptHandler.class);
        CommandScriptHandlerDispatcher dispatcher = create(conf);

        ExecutionContext context = context("flow", ExecutionPhase.MAIN);
        CommandScript script = script("stage");
        assertThat(dispatcher.getResourceId(context, script), is("match"));

        ExecutionContext otherFlow = context("otherflow", ExecutionPhase.MAIN);
        assertThat(dispatcher.getResourceId(otherFlow, script), is("default"));

        ExecutionContext otherPhase = context("flow", ExecutionPhase.PROLOGUE);
        assertThat(dispatcher.getResourceId(otherPhase, script), is("match"));

        CommandScript otherScript = script("otherstage");
        assertThat(dispatcher.getResourceId(context, otherScript), is("match"));
    }
View Full Code Here

        declare(conf, "default", MockCommandScriptHandler.class);
        declare(conf, "match", MockCommandScriptHandler.class);
        CommandScriptHandlerDispatcher dispatcher = create(conf);

        ExecutionContext context = context("flow", ExecutionPhase.MAIN);
        CommandScript script = script("stage");
        assertThat(dispatcher.getResourceId(context, script), is("match"));

        ExecutionContext otherFlow = context("otherflow", ExecutionPhase.MAIN);
        assertThat(dispatcher.getResourceId(otherFlow, script), is("match"));

        ExecutionContext otherPhase = context("flow", ExecutionPhase.PROLOGUE);
        assertThat(dispatcher.getResourceId(otherPhase, script), is("match"));

        CommandScript otherScript = script("otherstage");
        assertThat(dispatcher.getResourceId(context, otherScript), is("match"));
    }
View Full Code Here

    private ExecutionContext context(String flowId, ExecutionPhase phase) {
        return new ExecutionContext(BATCH_ID, flowId, "exec", phase, Collections.<String, String>emptyMap());
    }

    CommandScript script(String scriptId) {
        CommandScript script = new CommandScript(
                scriptId,
                Collections.<String>emptySet(),
                "profile",
                "module",
                Collections.singletonList("hello"),
View Full Code Here

                Set<String> actual = new TreeSet<String>();
                for (ExecutionScript ex : scripts) {
                    if ((ex instanceof CommandScript) == false) {
                        return false;
                    }
                    CommandScript cs = (CommandScript) ex;
                    actual.add(cs.getCommandLineTokens().get(0));
                }
                return actual.equals(expected);
            }
            @Override
            public void describeTo(Description desc) {
View Full Code Here

        assert executions != null;
        List<ScriptJob<?>> results = new ArrayList<ScriptJob<?>>();
        for (ExecutionScript execution : executions) {
            switch (execution.getKind()) {
            case COMMAND: {
                CommandScript exec = (CommandScript) execution;
                String profileName = exec.getProfileName();
                CommandScriptHandler handler = profileName == null ? null : commandHandlers.get(profileName);
                if (handler == null) {
                    LOG.debug("Profile {} is not defined in comand script handlers, try wildcard: {}",
                            profileName,
                            exec.getId());
                    handler = commandHandlers.get(CommandScriptHandler.PROFILE_WILDCARD);
                }
                if (handler == null) {
                    throw new IOException(MessageFormat.format(
                            "Profile \"{5}\" is not defined (batch={0}, flow={1}, phase={2}, module={3}, id={4})",
                            context.getBatchId(),
                            context.getFlowId(),
                            context.getPhase().getSymbol(),
                            exec.getModuleName(),
                            exec.getId(),
                            profileName));
                }
                results.add(new ScriptJob<CommandScript>(exec.resolve(context, handler), handler));
                break;
            }
            case HADOOP: {
                HadoopScript exec = (HadoopScript) execution;
                results.add(new ScriptJob<HadoopScript>(exec.resolve(context, hadoopHandler), hadoopHandler));
                break;
            }
            default:
                throw new AssertionError(MessageFormat.format(
                        "Unknown execution script: {0}",
View Full Code Here

TOP

Related Classes of com.asakusafw.yaess.core.CommandScript

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.