Search in sources :

Example 6 with INode

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);
}
Also used : Fault(edu.iu.dsc.tws.api.faulttolerance.Fault) TaskScheduler(edu.iu.dsc.tws.tsched.taskscheduler.TaskScheduler) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) INode(edu.iu.dsc.tws.api.compute.nodes.INode) HashMap(java.util.HashMap) Config(edu.iu.dsc.tws.api.config.Config) INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) JobMasterAPI(edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI) ExecutionPlan(edu.iu.dsc.tws.api.compute.executor.ExecutionPlan) DataObject(edu.iu.dsc.tws.api.dataset.DataObject) TaskSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan) DataObjectImpl(edu.iu.dsc.tws.dataset.DataObjectImpl) Receptor(edu.iu.dsc.tws.api.compute.modifiers.Receptor) Map(java.util.Map) Collector(edu.iu.dsc.tws.api.compute.modifiers.Collector) ISource(edu.iu.dsc.tws.api.compute.nodes.ISource) EmptyDataObject(edu.iu.dsc.tws.api.dataset.EmptyDataObject) FaultAcceptable(edu.iu.dsc.tws.api.faulttolerance.FaultAcceptable) ExecutorFactory(edu.iu.dsc.tws.executor.threading.ExecutorFactory) Set(java.util.Set) Logger(java.util.logging.Logger) Communicator(edu.iu.dsc.tws.api.comms.Communicator) ExecutionPlanBuilder(edu.iu.dsc.tws.executor.core.ExecutionPlanBuilder) List(java.util.List) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) CheckpointingClient(edu.iu.dsc.tws.api.checkpointing.CheckpointingClient) IExecutor(edu.iu.dsc.tws.api.compute.executor.IExecutor) Worker(edu.iu.dsc.tws.api.compute.schedule.elements.Worker) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan) DataPartition(edu.iu.dsc.tws.api.dataset.DataPartition) INode(edu.iu.dsc.tws.api.compute.nodes.INode) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) DataObjectImpl(edu.iu.dsc.tws.dataset.DataObjectImpl) DataObject(edu.iu.dsc.tws.api.dataset.DataObject) EmptyDataObject(edu.iu.dsc.tws.api.dataset.EmptyDataObject) Collector(edu.iu.dsc.tws.api.compute.modifiers.Collector) DataPartition(edu.iu.dsc.tws.api.dataset.DataPartition)

Example 7 with INode

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

Aggregations

INode (edu.iu.dsc.tws.api.compute.nodes.INode)7 INodeInstance (edu.iu.dsc.tws.api.compute.executor.INodeInstance)5 Receptor (edu.iu.dsc.tws.api.compute.modifiers.Receptor)5 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)5 ISource (edu.iu.dsc.tws.api.compute.nodes.ISource)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)3 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)3 Config (edu.iu.dsc.tws.api.config.Config)3 ArrayList (java.util.ArrayList)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 Edge (edu.iu.dsc.tws.api.compute.graph.Edge)2 Vertex (edu.iu.dsc.tws.api.compute.graph.Vertex)2 Collector (edu.iu.dsc.tws.api.compute.modifiers.Collector)2 ICompute (edu.iu.dsc.tws.api.compute.nodes.ICompute)2 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)2