Package org.jenkinsci.plugins.workflow.graph

Examples of org.jenkinsci.plugins.workflow.graph.FlowNode


                        if (p == null) {
                            throw new IllegalStateException(node + " is offline");
                        }
                        WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(p);
                        FilePath workspace = lease.path;
                        FlowNode flowNode = context.get(FlowNode.class);
                        flowNode.addAction(new WorkspaceActionImpl(workspace, flowNode));
                        listener.getLogger().println("Running on " + computer.getDisplayName() + " in " + workspace); // TODO hyperlink
                        context.invokeBodyLater(exec, computer, env, workspace).addCallback(new Callback(cookie, lease));
                        LOGGER.log(Level.FINE, "started {0}", cookie);
                    } else {
                        // just rescheduled after a restart; wait for task to complete
View Full Code Here


        final NamedArgsAndClosure ps = parseArgs(d,args);

        CpsThread thread = CpsThread.current();

        FlowNode an;

        // TODO: generalize the notion of Step taking over the FlowNode creation.
        // see https://trello.com/c/v6Pbwqxj/13-allowing-steps-to-build-flownodes
        boolean hack = d instanceof ParallelStep.DescriptorImpl;
View Full Code Here

    private void writeDot(PrintWriter w) throws IOException {
        try {
            w.println("digraph G {");
            FlowGraphWalker walker = new FlowGraphWalker(run.getExecution());
            FlowNode n;
            while ((n=walker.next())!=null) {
                for (FlowNode p : n.getParents()) {
                    w.printf("%s -> %s%n",
                            p.getId(), n.getId());
                }

                if (n instanceof BlockStartNode) {
                    BlockStartNode sn = (BlockStartNode) n;
                    w.printf("%s [shape=trapezium]%n", n.getId());
                } else
                if (n instanceof BlockEndNode) {
                    BlockEndNode sn = (BlockEndNode) n;
                    w.printf("%s [shape=invtrapezium]%n", n.getId());
                    w.printf("%s -> %s [style=dotted]%n",
                            sn.getStartNode().getId(), n.getId());
                }

                w.printf("%s [label=\"%s: %s\"]%n", n.getId(), n.getId(), n.getDisplayName());
            }

            w.println("}");
        } finally {
            w.close();
View Full Code Here

        if (exec == null) {
            return Collections.emptySet();
        }
        List<FlowNode> nodes = new ArrayList<FlowNode>();
        FlowGraphWalker walker = new FlowGraphWalker(exec);
        FlowNode n;
        while ((n = walker.next()) != null) {
            nodes.add(n);
        }
        Collections.reverse(nodes); // TODO would be more intuitive for FlowGraphWalker to do this to begin with
        return nodes;
View Full Code Here

        }
        Iterator<Map.Entry<String,Long>> it = logsToCopy.entrySet().iterator();
        boolean modified = false;
        while (it.hasNext()) {
            Map.Entry<String,Long> entry = it.next();
            FlowNode node;
            try {
                node = execution.getNode(entry.getKey());
            } catch (IOException x) {
                LOGGER.log(Level.WARNING, null, x);
                it.remove();
                modified = true;
                continue;
            }
            if (node == null) {
                LOGGER.log(Level.WARNING, "no such node {0}", entry.getKey());
                it.remove();
                modified = true;
                continue;
            }
            LogAction la = node.getAction(LogAction.class);
            if (la != null) {
                AnnotatedLargeText<? extends FlowNode> logText = la.getLogText();
                try {
                    long old = entry.getValue();
                    long revised = logText.writeRawLogTo(old, listener.getLogger());
                    if (revised != old) {
                        entry.setValue(revised);
                        modified = true;
                    }
                    if (logText.isComplete()) {
                        logText.writeRawLogTo(entry.getValue(), listener.getLogger()); // defend against race condition?
                        assert !node.isRunning() : "LargeText.complete yet " + node + " claims to still be running";
                        it.remove();
                        modified = true;
                    }
                } catch (IOException x) {
                    LOGGER.log(Level.WARNING, null, x);
                    it.remove();
                    modified = true;
                }
            } else if (!node.isRunning()) {
                it.remove();
                modified = true;
            }
        }
        if (modified) {
View Full Code Here

     * When this step context has completed execution (successful or otherwise), plan the next action.
     */
    private void scheduleNextRun() {
        if (!syncMode) {
            try {
                final FlowNode n = getNode();
                final CpsFlowExecution flow = getFlowExecution();

                final List<FlowNode> parents = new ArrayList<FlowNode>();
                parents.add(null);      // make room for the primary head
                for (String head : bodyInvHeads.values()) {
                    parents.add(flow.getNode(head));
                }

                flow.runInCpsVmThread(new FutureCallback<CpsThreadGroup>() {
                    @CpsVmThreadOnly
                    @Override
                    public void onSuccess(CpsThreadGroup g) {
                        g.unexport(body);
                        body = null;
                        CpsThread thread = getThread(g);
                        if (thread != null) {
                            if (n instanceof StepStartNode) {
                                FlowNode tip = thread.head.get();
                                parents.set(0, tip);

                                thread.head.setNewHead(new StepEndNode(flow, (StepStartNode) n, parents));
                            }
                            thread.head.markIfFail(getOutcome());
View Full Code Here

    public final @CheckForNull Throwable getCauseOfFailure() {
        List<FlowNode> heads = getCurrentHeads();
        if (heads.size()!=1 || !(heads.get(0) instanceof FlowEndNode))
            return null;

        FlowNode e = heads.get(0);
        ErrorAction error = e.getAction(ErrorAction.class);
        if (error==null)    return null;        // successful completion

        return error.getError();
    }
View Full Code Here

        final AtomicReference<FlowExecution> exec = new AtomicReference<FlowExecution>();
        exec.set(new STMFlowDefinition(Collections.<State>singletonList(new StepState("run", null, step))).create(new OwnerImpl(exec, tmp), Collections.<Action>emptyList()));
        SemaphoreListener l = new SemaphoreListener();
        exec.get().addListener(l);
        exec.get().start();
        FlowNode n = l.next();
        assertTrue(String.valueOf(n), n instanceof FlowStartNode);
        n = l.next();
        assertTrue(n instanceof BlockStartNode);
        step.success(null);
        n = l.next();
View Full Code Here

        final AtomicReference<FlowExecution> exec = new AtomicReference<FlowExecution>();
        exec.set(new STMFlowDefinition(Arrays.<State>asList(new BlockState("block", STMExecution.END, block, "step"), new StepState("step", STMExecution.END, step))).create(new OwnerImpl(exec, tmp), Collections.<Action>emptyList()));
        SemaphoreListener l = new SemaphoreListener();
        exec.get().addListener(l);
        exec.get().start();
        FlowNode n = l.next();
        assertTrue(String.valueOf(n), n instanceof FlowStartNode);
        n = l.next();
        assertTrue(n instanceof BlockStartNode);
        n = l.next();
        assertTrue(n instanceof BlockStartNode);
View Full Code Here

        FlowNodeConverter(XStream2 owner) {
            ref = new RobustReflectionConverter(owner.getMapper(),new JVM().bestReflectionProvider());
        }

        public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
            FlowNode n = (FlowNode)source;

            if (context.get(ROOT) ==null) {
                context.put(ROOT,n);
                ref.marshal(n, writer, context);
            } else {
                // this is a reference to another FlowNode. Persist as ID

                PersistenceContext c = CONTEXT.get();
                if (c!=null) {
                    // if we are trying to track reference graphs, remember IDs that we've encountered
                    c.queue.add(n);
                }
                writer.setValue(n.getId());
            }
        }
View Full Code Here

TOP

Related Classes of org.jenkinsci.plugins.workflow.graph.FlowNode

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.