Package com.asakusafw.yaess.core

Examples of com.asakusafw.yaess.core.FlowScript


    private List<FlowScript> processJobflowList(Workflow workflow) {
        assert workflow != null;
        List<FlowScript> jobflows = Lists.create();
        for (Graph.Vertex<Workflow.Unit> vertex : sortJobflow(workflow.getGraph())) {
            FlowScript jobflow = processJobflow(vertex.getNode(), vertex.getConnected());
            jobflows.add(jobflow);
        }
        return jobflows;
    }
View Full Code Here


        scripts.put(ExecutionPhase.PROLOGUE, processPrologues(model, context));
        scripts.put(ExecutionPhase.MAIN, processMain(model, context));
        scripts.put(ExecutionPhase.EPILOGUE, processEpilogues(model, context));
        scripts.put(ExecutionPhase.EXPORT, processExporters(model, context));
        scripts.put(ExecutionPhase.FINALIZE, processFinalizers(model, context));
        return new FlowScript(model.getFlowId(), toUnitNames(blockers), scripts);
    }
View Full Code Here

    public void simple() throws Exception {
        Properties p = compile(SimpleBatch.class);
        BatchScript script = BatchScript.load(p);
        assertThat(FlowScript.extractFlowIds(p), is(set("first")));

        FlowScript first = script.findFlow("first");
        assertThat(first.getId(), is("first"));
        assertThat(first.getBlockerIds(), is(set()));
        Map<ExecutionPhase, Set<ExecutionScript>> firstScripts = first.getScripts();
        assertThat(firstScripts.get(ExecutionPhase.SETUP).size(), is(0));
        assertThat(firstScripts.get(ExecutionPhase.CLEANUP).size(), is(0));
        assertThat(firstScripts.get(ExecutionPhase.INITIALIZE), hasCommands("initialize"));
        assertThat(firstScripts.get(ExecutionPhase.IMPORT), hasCommands("import"));
        assertThat(firstScripts.get(ExecutionPhase.PROLOGUE).size(), is(1));
View Full Code Here

    public void complex() throws Exception {
        Properties p = compile(ComplexBatch.class);
        BatchScript script = BatchScript.load(p);
        assertThat(FlowScript.extractFlowIds(p), is(set("last")));

        FlowScript last = script.findFlow("last");
        assertThat(last.getId(), is("last"));
        assertThat(last.getBlockerIds(), is(set()));
        Map<ExecutionPhase, Set<ExecutionScript>> lastScripts = last.getScripts();
        assertThat(lastScripts.get(ExecutionPhase.MAIN).size(), is(3));
        Set<String> blockers = Sets.create();
        for (ExecutionScript ex : lastScripts.get(ExecutionPhase.MAIN)) {
            blockers.addAll(ex.getBlockerIds());
        }
View Full Code Here

        Properties p = compile(DiamondBatch.class);
        BatchScript script = BatchScript.load(p);

        assertThat(FlowScript.extractFlowIds(p), is(set("first", "left", "right", "last")));

        FlowScript first = script.findFlow("first");
        FlowScript left = script.findFlow("left");
        FlowScript right = script.findFlow("right");
        FlowScript last = script.findFlow("last");

        assertThat(first.getId(), is("first"));
        assertThat(left.getId(), is("left"));
        assertThat(right.getId(), is("right"));
        assertThat(last.getId(), is("last"));

        assertThat(first.getBlockerIds(), is(set()));
        assertThat(left.getBlockerIds(), is(set("first")));
        assertThat(right.getBlockerIds(), is(set("first")));
        assertThat(last.getBlockerIds(), is(set("left", "right")));
    }
View Full Code Here

        }
        LOG.debug("Definition: {}={}", KEY_SKIP_FLOWS, flows);
        for (String flowIdCandidate : flows.split(",")) {
            String flowId = flowIdCandidate.trim();
            if (flowId.isEmpty() == false) {
                FlowScript flow = script.findFlow(flowId);
                if (flow == null) {
                    throw new IllegalArgumentException(MessageFormat.format(
                            "Unknown flowId in definition {0} : {1}",
                            KEY_SKIP_FLOWS,
                            flowId));
View Full Code Here

            throw new IllegalArgumentException("flowId must not be null"); //$NON-NLS-1$
        }
        if (executionId == null) {
            throw new IllegalArgumentException("executionId must not be null"); //$NON-NLS-1$
        }
        FlowScript flow = script.findFlow(flowId);
        if (flow == null) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "Flow is undefined: batchId={0}, flowId={1}, executionId={2}",
                    batchId,
                    flowId,
View Full Code Here

     */
    public void executePhase(ExecutionContext context) throws InterruptedException, IOException {
        if (context == null) {
            throw new IllegalArgumentException("context must not be null"); //$NON-NLS-1$
        }
        FlowScript flow = script.findFlow(context.getFlowId());
        if (flow == null) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "Flow is undefined: batchId={0}, flowId={1}, executionId={2}",
                    context.getBatchId(),
                    context.getFlowId(),
                    context.getExecutionId()));
        }
        Set<ExecutionScript> executions = flow.getScripts().get(context.getPhase());
        ExecutionLock lock = acquireExecutionLock(context.getBatchId());
        try {
            lock.beginFlow(context.getFlowId(), context.getExecutionId());
            executePhase(context, executions);
            lock.endFlow(context.getFlowId(), context.getExecutionId());
View Full Code Here

        private boolean submit() {
            LOG.debug("Submitting waiting jobflows: {}", batchId);
            boolean submitted = false;
            for (Iterator<FlowScript> iter = flows.iterator(); iter.hasNext();) {
                FlowScript flow = iter.next();
                boolean blocked = false;
                for (String blockerId : flow.getBlockerIds()) {
                    if (blocking.contains(blockerId)) {
                        blocked = true;
                        break;
                    }
                }
View Full Code Here

        private void waitForComplete() throws InterruptedException, IOException {
            LOG.debug("Waiting for running jobflows complete: {}", batchId);
            FlowScriptTask done = doneQueue.take();
            assert done.isDone();
            FlowScript flow = done.script;
            try {
                done.get();
                boolean blocked = blocking.remove(flow.getId());
                assert blocked;
            } catch (CancellationException e) {
                YSLOG.info(e, "I01005", batchId, flow.getId());
            } catch (ExecutionException e) {
                if (e.getCause() instanceof IOException) {
                    throw (IOException) e.getCause();
                } else if (e.getCause() instanceof InterruptedException) {
                    throw (InterruptedException) e.getCause();
                } else if (e.getCause() instanceof Error) {
                    throw (Error) e.getCause();
                } else {
                    throw new IOException("Flow execution failed by unknown error", e);
                }
            } finally {
                FlowScriptTask ran = running.remove(flow.getId());
                assert ran != null;
            }
        }
View Full Code Here

TOP

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

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.