Search in sources :

Example 6 with INodeInstance

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

the class BatchSharingExecutor2 method scheduleExecution.

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

Example 7 with INodeInstance

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

the class StreamingAllSharingExecutor2 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 8 with INodeInstance

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

the class StreamingAllSharingExecutor2 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();
    }
    executionHook.onClose(this);
    // clear the finished instances
    cleanUpCalled = true;
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation)

Example 9 with INodeInstance

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

the class StreamingAllSharingExecutor2 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, 0);
    for (int i = 1; i < numThreads; i++) {
        StreamWorker task = new StreamWorker(tasks, taskStatus, idleTasks, idleCounter, i);
        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)

Example 10 with INodeInstance

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

the class StreamingAllSharingExecutor 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();
    }
    executionHook.onClose(this);
    // clear the finished instances
    cleanUpCalled = true;
}
Also used : INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation)

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