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