use of edu.iu.dsc.tws.api.compute.nodes.INode 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);
}
use of edu.iu.dsc.tws.api.compute.nodes.INode 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);
}
}
}
Aggregations