Search in sources :

Example 11 with IParallelOperation

use of edu.iu.dsc.tws.api.compute.executor.IParallelOperation in project twister2 by DSC-SPIDAL.

the class TaskBatchInstance method prepare.

public void prepare(Config cfg) {
    outputCollection = new DefaultOutputCollection(outQueue);
    taskContext = new TaskContextImpl(taskIndex, taskId, globalTaskId, taskName, parallelism, workerId, outputCollection, nodeConfigs, inputEdges, outputEdges, taskSchedule, OperationMode.BATCH);
    task.prepare(cfg, taskContext);
    // / we will use this array for iteration
    this.outOpArray = new IParallelOperation[outParOps.size()];
    int index = 0;
    for (Map.Entry<String, IParallelOperation> e : outParOps.entrySet()) {
        this.outOpArray[index++] = e.getValue();
    }
    this.outEdgeArray = new String[outputEdges.size()];
    index = 0;
    for (String e : outputEdges.keySet()) {
        this.outEdgeArray[index++] = e;
    }
    // / we will use this array for iteration
    this.intOpArray = new IParallelOperation[inParOps.size()];
    index = 0;
    for (Map.Entry<String, IParallelOperation> e : inParOps.entrySet()) {
        this.intOpArray[index++] = e.getValue();
    }
    this.inEdgeArray = new String[inputEdges.size()];
    index = 0;
    for (String e : inputEdges.keySet()) {
        this.inEdgeArray[index++] = e;
    }
}
Also used : IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation) DefaultOutputCollection(edu.iu.dsc.tws.executor.core.DefaultOutputCollection) TaskContextImpl(edu.iu.dsc.tws.executor.core.TaskContextImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with IParallelOperation

use of edu.iu.dsc.tws.api.compute.executor.IParallelOperation in project twister2 by DSC-SPIDAL.

the class SourceBatchInstance method prepare.

public void prepare(Config cfg) {
    outputBatchCollection = new DefaultOutputCollection(outBatchQueue);
    taskContext = new TaskContextImpl(batchTaskIndex, taskId, globalTaskId, batchTaskName, parallelism, workerId, outputBatchCollection, nodeConfigs, outputEdges, taskSchedule, OperationMode.BATCH);
    batchTask.prepare(cfg, taskContext);
    // / we will use this array for iteration
    this.outOpArray = new IParallelOperation[outBatchParOps.size()];
    int index = 0;
    for (Map.Entry<String, IParallelOperation> e : outBatchParOps.entrySet()) {
        this.outOpArray[index++] = e.getValue();
    }
    this.outEdgeArray = new String[outputEdges.size()];
    index = 0;
    for (String e : outputEdges.keySet()) {
        this.outEdgeArray[index++] = e;
    }
}
Also used : IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation) DefaultOutputCollection(edu.iu.dsc.tws.executor.core.DefaultOutputCollection) TaskContextImpl(edu.iu.dsc.tws.executor.core.TaskContextImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with IParallelOperation

use of edu.iu.dsc.tws.api.compute.executor.IParallelOperation in project twister2 by DSC-SPIDAL.

the class SourceStreamingInstance method execute.

/**
 * Execution Method calls the SourceTasks run method to get context
 */
public boolean execute() {
    if (outStreamingQueue.size() < lowWaterMark && !(this.checkpointable && this.pendingCheckpoint.isPending())) {
        // lets execute the task
        streamingTask.execute();
        if (this.checkpointable && (executions++ % this.checkPointingFrequency) == 0) {
            this.scheduleCheckpoint(checkpointVersion++);
        }
    }
    // we start with setting nothing to execute true
    boolean nothingToProcess = true;
    // now check the output queue
    while (!outStreamingQueue.isEmpty()) {
        IMessage message = outStreamingQueue.peek();
        if (message != null) {
            String edge = message.edge();
            IParallelOperation op = outStreamingParOps.get(edge);
            boolean barrierMessage = (message.getFlag() & MessageFlags.SYNC_BARRIER) == MessageFlags.SYNC_BARRIER;
            // if we successfully send remove message
            if (barrierMessage ? op.sendBarrier(globalTaskId, (byte[]) message.getContent()) : op.send(globalTaskId, message, message.getFlag())) {
                outStreamingQueue.poll();
            } else {
                nothingToProcess = false;
                // we need to break
                break;
            }
        } else {
            break;
        }
    }
    for (int i = 0; i < outOpArray.length; i++) {
        boolean needProgress = outOpArray[i].progress();
        if (needProgress) {
            nothingToProcess = false;
        }
    }
    if (this.checkpointable && outStreamingQueue.isEmpty() && this.pendingCheckpoint.isPending()) {
        long barrier = this.pendingCheckpoint.execute();
        if (barrier != -1) {
            ((CheckpointableTask) this.streamingTask).onCheckpointPropagated(this.snapshot);
            this.scheduleBarriers(barrier);
            taskContext.write(CheckpointingSGatherSink.FT_GATHER_EDGE, barrier);
            nothingToProcess = false;
        }
    }
    return !nothingToProcess;
}
Also used : IMessage(edu.iu.dsc.tws.api.compute.IMessage) IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation) CheckpointableTask(edu.iu.dsc.tws.checkpointing.task.CheckpointableTask)

Example 14 with IParallelOperation

use of edu.iu.dsc.tws.api.compute.executor.IParallelOperation 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;
}
Also used : INodeInstance(edu.iu.dsc.tws.api.compute.executor.INodeInstance) IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation)

Aggregations

IParallelOperation (edu.iu.dsc.tws.api.compute.executor.IParallelOperation)14 INodeInstance (edu.iu.dsc.tws.api.compute.executor.INodeInstance)6 CheckpointableTask (edu.iu.dsc.tws.checkpointing.task.CheckpointableTask)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 IMessage (edu.iu.dsc.tws.api.compute.IMessage)4 DefaultOutputCollection (edu.iu.dsc.tws.executor.core.DefaultOutputCollection)4 TaskContextImpl (edu.iu.dsc.tws.executor.core.TaskContextImpl)4 HashBasedTable (com.google.common.collect.HashBasedTable)1 Table (com.google.common.collect.Table)1 CheckpointingClient (edu.iu.dsc.tws.api.checkpointing.CheckpointingClient)1 Communicator (edu.iu.dsc.tws.api.comms.Communicator)1 LogicalPlan (edu.iu.dsc.tws.api.comms.LogicalPlan)1 ExecutionPlan (edu.iu.dsc.tws.api.compute.executor.ExecutionPlan)1 ExecutorContext (edu.iu.dsc.tws.api.compute.executor.ExecutorContext)1 IExecutionPlanBuilder (edu.iu.dsc.tws.api.compute.executor.IExecutionPlanBuilder)1 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)1 Edge (edu.iu.dsc.tws.api.compute.graph.Edge)1 OperationMode (edu.iu.dsc.tws.api.compute.graph.OperationMode)1 Vertex (edu.iu.dsc.tws.api.compute.graph.Vertex)1