Search in sources :

Example 11 with INodeInstance

use of edu.iu.dsc.tws.api.compute.executor.INodeInstance in project twister2 by DSC-SPIDAL.

the class StreamingAllSharingExecutor method scheduleWaitFor.

private CommunicationWorker[] scheduleWaitFor(Map<Integer, INodeInstance> nodes) {
    BlockingQueue<INodeInstance> tasks;
    tasks = new ArrayBlockingQueue<>(nodes.size() * 2);
    tasks.addAll(nodes.values());
    CommunicationWorker[] workers = new CommunicationWorker[numThreads];
    workers[0] = new CommunicationWorker(tasks);
    doneSignal = new CountDownLatch(numThreads - 1);
    for (int i = 1; i < numThreads; i++) {
        workers[i] = new CommunicationWorker(tasks);
        threads.submit(workers[i]);
    }
    return workers;
}
Also used : INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 12 with INodeInstance

use of edu.iu.dsc.tws.api.compute.executor.INodeInstance in project twister2 by DSC-SPIDAL.

the class StreamingSharingExecutor method cleanUp.

private void cleanUp(Map<Integer, INodeInstance> nodes) {
    // lets wait for thread to finish
    try {
        doneSignal.await();
    } catch (InterruptedException e) {
        throw new RuntimeException("Interrupted", e);
    }
    // clean up the instances
    for (INodeInstance node : nodes.values()) {
        node.close();
    }
    // lets close the operations
    List<IParallelOperation> ops = executionPlan.getParallelOperations();
    for (IParallelOperation op : ops) {
        op.close();
    }
    // execution hook
    executionHook.afterExecution();
    cleanUpCalled = true;
}
Also used : INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation)

Example 13 with INodeInstance

use of edu.iu.dsc.tws.api.compute.executor.INodeInstance in project twister2 by DSC-SPIDAL.

the class StreamingSharingExecutor method schedulerExecution.

private void schedulerExecution(Map<Integer, INodeInstance> nodes) {
    BlockingQueue<INodeInstance> tasks;
    tasks = new ArrayBlockingQueue<>(nodes.size() * 2);
    tasks.addAll(nodes.values());
    for (INodeInstance node : tasks) {
        node.prepare(config);
    }
    doneSignal = new CountDownLatch(numThreads);
    for (int i = 0; i < numThreads; i++) {
        threads.execute(new StreamWorker(tasks));
    }
}
Also used : INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 14 with INodeInstance

use of edu.iu.dsc.tws.api.compute.executor.INodeInstance in project twister2 by DSC-SPIDAL.

the class TaskExecutor method addInput.

/**
 * Add input to the the task instances
 *
 * @param graph task graph
 * @param plan execution plan
 * @param taskName task name
 * @param inputKey inputkey
 * @param input input
 * @deprecated Inputs are automatically handled now
 */
@Deprecated
public void addInput(ComputeGraph graph, ExecutionPlan plan, String taskName, String inputKey, DataObject<?> input) {
    Map<Integer, INodeInstance> nodes = plan.getNodes(taskName);
    if (nodes == null) {
        return;
    }
    for (Map.Entry<Integer, INodeInstance> e : nodes.entrySet()) {
        INodeInstance node = e.getValue();
        INode task = node.getNode();
        if (task instanceof Receptor) {
            ((Receptor) task).add(inputKey, input);
        } else {
            throw new RuntimeException("Cannot add input to non input instance: " + node);
        }
    }
}
Also used : INode(edu.iu.dsc.tws.api.compute.nodes.INode) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Receptor(edu.iu.dsc.tws.api.compute.modifiers.Receptor) INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 15 with INodeInstance

use of edu.iu.dsc.tws.api.compute.executor.INodeInstance in project twister2 by DSC-SPIDAL.

the class TaskExecutor method collectData.

/**
 * This method collects all the output from the provided {@link ExecutionPlan}.
 * The partition IDs will be assigned just before adding the partitions to the {@link DataObject}
 */
public static void collectData(Config cfg, ExecutionPlan executionPlan, Map<String, DataObject> dataMap) {
    Map<Integer, INodeInstance> nodes = executionPlan.getNodes();
    Map<String, DataObject> dataObjectMapForPlan = new HashMap<>();
    if (nodes != null) {
        nodes.forEach((taskId, node) -> {
            INode task = node.getNode();
            if (task instanceof Collector) {
                Set<String> collectibleNames = ((Collector) task).getCollectibleNames();
                collectibleNames.forEach(name -> {
                    DataPartition partition = ((Collector) task).get(name);
                    // if this task outs only one partition and user has implemented no arg get() method
                    if (collectibleNames.size() == 1 && partition == null) {
                        partition = ((Collector) task).get();
                    }
                    if (partition != null) {
                        partition.setId(node.getIndex());
                        dataObjectMapForPlan.computeIfAbsent(name, n -> new DataObjectImpl<>(cfg)).addPartition(partition);
                    } else {
                        LOG.warning(String.format("Task index %d  of task %d returned null for data %s", node.getIndex(), node.getId(), name));
                    }
                });
            }
        });
    }
    dataMap.putAll(dataObjectMapForPlan);
}
Also used : Fault(edu.iu.dsc.tws.api.faulttolerance.Fault) TaskScheduler(edu.iu.dsc.tws.tsched.taskscheduler.TaskScheduler) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) INode(edu.iu.dsc.tws.api.compute.nodes.INode) HashMap(java.util.HashMap) Config(edu.iu.dsc.tws.api.config.Config) INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) JobMasterAPI(edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI) ExecutionPlan(edu.iu.dsc.tws.api.compute.executor.ExecutionPlan) DataObject(edu.iu.dsc.tws.api.dataset.DataObject) TaskSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan) DataObjectImpl(edu.iu.dsc.tws.dataset.DataObjectImpl) Receptor(edu.iu.dsc.tws.api.compute.modifiers.Receptor) Map(java.util.Map) Collector(edu.iu.dsc.tws.api.compute.modifiers.Collector) ISource(edu.iu.dsc.tws.api.compute.nodes.ISource) EmptyDataObject(edu.iu.dsc.tws.api.dataset.EmptyDataObject) FaultAcceptable(edu.iu.dsc.tws.api.faulttolerance.FaultAcceptable) ExecutorFactory(edu.iu.dsc.tws.executor.threading.ExecutorFactory) Set(java.util.Set) Logger(java.util.logging.Logger) Communicator(edu.iu.dsc.tws.api.comms.Communicator) ExecutionPlanBuilder(edu.iu.dsc.tws.executor.core.ExecutionPlanBuilder) List(java.util.List) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) CheckpointingClient(edu.iu.dsc.tws.api.checkpointing.CheckpointingClient) IExecutor(edu.iu.dsc.tws.api.compute.executor.IExecutor) Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan) DataPartition(edu.iu.dsc.tws.api.dataset.DataPartition) INode(edu.iu.dsc.tws.api.compute.nodes.INode) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) DataObjectImpl(edu.iu.dsc.tws.dataset.DataObjectImpl) DataObject(edu.iu.dsc.tws.api.dataset.DataObject) EmptyDataObject(edu.iu.dsc.tws.api.dataset.EmptyDataObject) Collector(edu.iu.dsc.tws.api.compute.modifiers.Collector) DataPartition(edu.iu.dsc.tws.api.dataset.DataPartition)

Aggregations

INodeInstance (edu.iu.dsc.tws.api.compute.executor.INodeInstance)19 CountDownLatch (java.util.concurrent.CountDownLatch)9 IParallelOperation (edu.iu.dsc.tws.api.compute.executor.IParallelOperation)6 ArrayList (java.util.ArrayList)6 INode (edu.iu.dsc.tws.api.compute.nodes.INode)5 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)5 Receptor (edu.iu.dsc.tws.api.compute.modifiers.Receptor)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 ISource (edu.iu.dsc.tws.api.compute.nodes.ISource)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CheckpointingClient (edu.iu.dsc.tws.api.checkpointing.CheckpointingClient)2 Communicator (edu.iu.dsc.tws.api.comms.Communicator)2 ExecutionPlan (edu.iu.dsc.tws.api.compute.executor.ExecutionPlan)2 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)2 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)2 Config (edu.iu.dsc.tws.api.config.Config)2 DataObject (edu.iu.dsc.tws.api.dataset.DataObject)2 DataPartition (edu.iu.dsc.tws.api.dataset.DataPartition)2