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);
}
}
}
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;
}
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;
}
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;
}
Aggregations