Search in sources :

Example 16 with INodeInstance

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

the class TaskExecutor method addSourceInput.

/**
 * Add input to the the task instances
 *
 * @param graph task graph
 * @param plan execution plan
 * @param inputKey inputkey
 * @param input input
 * @deprecated Inputs are handled automatically now
 */
@Deprecated
public void addSourceInput(ComputeGraph graph, ExecutionPlan plan, String inputKey, DataObject<Object> input) {
    Map<Integer, INodeInstance> nodes = plan.getNodes();
    if (nodes == null) {
        throw new RuntimeException(String.format("%d Failed to set input for non-existing " + "existing sources: %s", workerID, plan.getNodeNames()));
    }
    for (Map.Entry<Integer, INodeInstance> e : nodes.entrySet()) {
        INodeInstance node = e.getValue();
        INode task = node.getNode();
        if (task instanceof Receptor && task instanceof ISource) {
            ((Receptor) task).add(inputKey, input);
        }
    }
}
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) ISource(edu.iu.dsc.tws.api.compute.nodes.ISource) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 17 with INodeInstance

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

the class BatchSharingExecutor2 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 18 with INodeInstance

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

the class BatchSharingExecutor2 method close.

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

Example 19 with INodeInstance

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

the class StreamingAllSharingExecutor method scheduleExecution.

private StreamWorker[] scheduleExecution(Map<Integer, INodeInstance> nodes) {
    // initialize finished
    List<INodeInstance> tasks = new ArrayList<>(nodes.values());
    // prepare the tasks
    for (INodeInstance node : tasks) {
        node.prepare(config);
    }
    StreamWorker[] workers = new StreamWorker[numThreads];
    final AtomicBoolean[] taskStatus = new AtomicBoolean[tasks.size()];
    final AtomicBoolean[] idleTasks = new AtomicBoolean[tasks.size()];
    for (int i = 0; i < tasks.size(); i++) {
        taskStatus[i] = new AtomicBoolean(false);
        idleTasks[i] = new AtomicBoolean(false);
    }
    doneSignal = new CountDownLatch(numThreads - 1);
    AtomicInteger idleCounter = new AtomicInteger(tasks.size());
    workers[0] = new StreamWorker(tasks, taskStatus, idleTasks, idleCounter);
    for (int i = 1; i < numThreads; i++) {
        StreamWorker task = new StreamWorker(tasks, taskStatus, idleTasks, idleCounter);
        threads.submit(task);
        workers[i] = task;
    }
    return workers;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch)

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