Search in sources :

Example 1 with DataObjectImpl

use of edu.iu.dsc.tws.dataset.DataObjectImpl in project twister2 by DSC-SPIDAL.

the class TaskWorkerDataLoader method showAllUnits.

public void showAllUnits(DataObject<Object> dataPointsObject) {
    for (int i = 0; i < dataPointsObject.getPartitions().length; i++) {
        DataPartition<Object> values = dataPointsObject.getPartitions()[i];
        DataPartitionConsumer<Object> dataPartitionConsumer = values.getConsumer();
        // LOG.info("Final Receive  : " + dataPartitionConsumer.hasNext());
        while (dataPartitionConsumer.hasNext()) {
            LOG.info(String.format("Id1[%d], Type: %s", i, dataPartitionConsumer.next().getClass().getName()));
            Object object = dataPartitionConsumer.next();
            if (object instanceof DataObjectImpl<?>) {
                DataObjectImpl<?> dataObjectImpl = (DataObjectImpl<?>) object;
                LOG.info(String.format("Id1[%d], Partition Count :  %d", i, dataObjectImpl.getPartitionCount()));
                int numpar = dataObjectImpl.getPartitions().length;
                LOG.info("Number of Partitions : " + numpar);
                for (int j = 0; j < dataObjectImpl.getPartitions().length; j++) {
                    DataPartition<?> values1 = dataObjectImpl.getPartitions()[j];
                    Object object1 = values1.getConsumer().next();
                    LOG.info(String.format("Ids[%d,%d] , Received Object : %s ", i, j, object1.getClass().getName()));
                    if (object1 instanceof Iterator<?>) {
                        Iterator<?> itr = (Iterator<?>) object1;
                        while (itr.hasNext()) {
                            Object object2 = itr.next();
                            if (object2 instanceof String) {
                                LOG.info(String.format("Ids[%d,%d] , Worker Id %d / %d, Data : %s", i, j, workerId, workers, String.valueOf(object2)));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : DataObjectImpl(edu.iu.dsc.tws.dataset.DataObjectImpl) Iterator(java.util.Iterator) DataObject(edu.iu.dsc.tws.api.dataset.DataObject)

Example 2 with DataObjectImpl

use of edu.iu.dsc.tws.dataset.DataObjectImpl 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)

Aggregations

DataObject (edu.iu.dsc.tws.api.dataset.DataObject)2 DataObjectImpl (edu.iu.dsc.tws.dataset.DataObjectImpl)2 CheckpointingClient (edu.iu.dsc.tws.api.checkpointing.CheckpointingClient)1 Communicator (edu.iu.dsc.tws.api.comms.Communicator)1 ExecutionPlan (edu.iu.dsc.tws.api.compute.executor.ExecutionPlan)1 IExecutor (edu.iu.dsc.tws.api.compute.executor.IExecutor)1 INodeInstance (edu.iu.dsc.tws.api.compute.executor.INodeInstance)1 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)1 Collector (edu.iu.dsc.tws.api.compute.modifiers.Collector)1 Receptor (edu.iu.dsc.tws.api.compute.modifiers.Receptor)1 INode (edu.iu.dsc.tws.api.compute.nodes.INode)1 ISource (edu.iu.dsc.tws.api.compute.nodes.ISource)1 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)1 Worker (edu.iu.dsc.tws.api.compute.schedule.elements.Worker)1 WorkerPlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)1 Config (edu.iu.dsc.tws.api.config.Config)1 DataPartition (edu.iu.dsc.tws.api.dataset.DataPartition)1 EmptyDataObject (edu.iu.dsc.tws.api.dataset.EmptyDataObject)1 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)1 Fault (edu.iu.dsc.tws.api.faulttolerance.Fault)1