Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.Parallel


        context.getExecutionListener().log(3,
            "preparing for parallel execution...(keepgoing? " + keepgoing + ", threads: "
            + context.getThreadCount()
            + ")");
        configureNodeContextThreadLocalsForProject(project);
        final Parallel parallelTask = new Parallel();
        parallelTask.setProject(project);
        parallelTask.setThreadCount(context.getThreadCount());
        parallelTask.setFailOnAny(!keepgoing);
        boolean success = false;
        final HashMap<String, NodeStepResult> resultMap = new HashMap<String, NodeStepResult>();
        final HashMap<String, NodeStepResult> failureMap = new HashMap<String, NodeStepResult>();
        final Collection<INodeEntry> nodes1 = nodes.getNodes();
        //reorder based on configured rank property and order
        final String rankProperty = null != context.getNodeRankAttribute() ? context.getNodeRankAttribute() : "nodename";
        final boolean rankAscending = context.isNodeRankOrderAscending();
        final INodeEntryComparator comparator = new INodeEntryComparator(rankProperty);
        final TreeSet<INodeEntry> orderedNodes = new TreeSet<INodeEntry>(
            rankAscending ? comparator : Collections.reverseOrder(comparator));

        orderedNodes.addAll(nodes1);
        for (final INodeEntry node: orderedNodes) {
            final Callable tocall;
            if (null != item) {
                tocall = execItemCallable(context, item, resultMap, node, failureMap);
            } else {
                tocall = dispatchableCallable(context, toDispatch, resultMap, node, failureMap);
            }
            nodeNames.add(node.getNodename());
            context.getExecutionListener().log(3, "Create task for node: " + node.getNodename());
            final CallableWrapperTask callableWrapperTask1 = new CallableWrapperTask(tocall);
            callableWrapperTask1.setProject(project);
            parallelTask.addTask(callableWrapperTask1);
        }
        if (null != failedListener) {
            failedListener.matchedNodes(nodeNames);
        }
        context.getExecutionListener().log(3, "parallel dispatch to nodes: " + nodeNames);
        BuildException buildException;
        try {
            parallelTask.execute();
            success = true;
        } catch (BuildException e) {
            buildException=e;
            if(e.getCause() !=null && e.getCause() instanceof DispatchFailure) {
                DispatchFailure df = (DispatchFailure) e.getCause();
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.Parallel

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.