Search in sources :

Example 1 with TaskContextImpl

use of edu.iu.dsc.tws.executor.core.TaskContextImpl in project twister2 by DSC-SPIDAL.

the class SourceStreamingInstance method prepare.

public void prepare(Config cfg) {
    outputStreamingCollection = new DefaultOutputCollection(outStreamingQueue);
    taskContext = new TaskContextImpl(streamingTaskIndex, taskId, globalTaskId, taskName, parallelism, workerId, outputStreamingCollection, nodeConfigs, outEdges, taskSchedule, OperationMode.STREAMING);
    streamingTask.prepare(cfg, taskContext);
    // / we will use this array for iteration
    this.outOpArray = new IParallelOperation[outStreamingParOps.size()];
    int index = 0;
    for (Map.Entry<String, IParallelOperation> e : outStreamingParOps.entrySet()) {
        this.outOpArray[index++] = e.getValue();
    }
    this.outEdgeArray = new String[outEdges.size()];
    index = 0;
    for (String e : outEdges.keySet()) {
        this.outEdgeArray[index++] = e;
    }
    if (this.checkpointable) {
        this.stateStore = CheckpointUtils.getStateStore(config);
        this.stateStore.init(config, this.taskGraphName, String.valueOf(globalTaskId));
        TaskCheckpointUtils.restore((CheckpointableTask) this.streamingTask, this.snapshot, this.stateStore, this.tasksVersion, globalTaskId);
        this.checkpointVersion = this.tasksVersion + 1;
        this.pendingCheckpoint = new PendingCheckpoint(taskGraphName, (CheckpointableTask) this.streamingTask, globalTaskId, outOpArray, outEdges.size(), checkpointingClient, stateStore, snapshot);
    }
}
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) CheckpointableTask(edu.iu.dsc.tws.checkpointing.task.CheckpointableTask)

Example 2 with TaskContextImpl

use of edu.iu.dsc.tws.executor.core.TaskContextImpl in project twister2 by DSC-SPIDAL.

the class TaskStreamingInstance method prepare.

/**
 * Preparing the task
 *
 * @param cfg configuration
 */
public void prepare(Config cfg) {
    outputCollection = new DefaultOutputCollection(outQueue);
    taskContext = new TaskContextImpl(taskIndex, taskId, globalTaskId, taskName, parallelism, workerId, outputCollection, nodeConfigs, inputEdges, outputEdges, taskSchedule, OperationMode.STREAMING);
    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;
    }
    if (this.checkpointable) {
        this.stateStore = CheckpointUtils.getStateStore(config);
        this.stateStore.init(config, this.taskGraphName, String.valueOf(globalTaskId));
        this.pendingCheckpoint = new PendingCheckpoint(this.taskGraphName, (CheckpointableTask) this.task, this.globalTaskId, this.intOpArray, this.inEdgeArray.length, this.checkpointingClient, this.stateStore, this.snapshot);
        TaskCheckpointUtils.restore((CheckpointableTask) this.task, this.snapshot, this.stateStore, this.tasksVersion, globalTaskId);
    }
}
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) CheckpointableTask(edu.iu.dsc.tws.checkpointing.task.CheckpointableTask)

Example 3 with TaskContextImpl

use of edu.iu.dsc.tws.executor.core.TaskContextImpl 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 4 with TaskContextImpl

use of edu.iu.dsc.tws.executor.core.TaskContextImpl 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)

Aggregations

IParallelOperation (edu.iu.dsc.tws.api.compute.executor.IParallelOperation)4 DefaultOutputCollection (edu.iu.dsc.tws.executor.core.DefaultOutputCollection)4 TaskContextImpl (edu.iu.dsc.tws.executor.core.TaskContextImpl)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 CheckpointableTask (edu.iu.dsc.tws.checkpointing.task.CheckpointableTask)2