use of edu.iu.dsc.tws.task.core.TaskExecutionOptimizer in project twister2 by DSC-SPIDAL.
the class SimpleMultiTaskGraph method init.
/**
* Init method to submit the task to the executor
*/
public void init(Config cfg, int containerId, ResourcePlan plan) {
LOG.log(Level.INFO, "Starting the example with container id: " + plan.getThisId());
taskExecutor = new TaskExecutorFixedThread();
this.status = SimpleMultiTaskGraph.Status.INIT;
TaskPlan taskPlan = Utils.createTaskPlan(cfg, plan);
TWSNetwork network = new TWSNetwork(cfg, taskPlan);
TWSCommunication channel = network.getDataFlowTWSCommunication();
Set<Integer> sources = new HashSet<>();
sources.add(0);
int destination = 1;
Map<String, Object> newCfg = new HashMap<>();
LinkedQueue<Message> pongQueue = new LinkedQueue<Message>();
taskExecutor.registerQueue(0, pongQueue);
direct = channel.direct(newCfg, MessageType.OBJECT, 0, sources, destination, new SimpleMultiTaskGraph.PingPongReceive());
taskExecutor.initCommunication(channel, direct);
// For Dataflow Task Graph Generation call the dataflow task graph generator
MapWorker sourceTask = new MapWorker(0, direct);
ReceiveWorker sinkTask = new ReceiveWorker(1);
// later we can add a different task
ReceiveWorker sinkTask1 = new ReceiveWorker(2);
dataflowTaskGraph = new DataflowTaskGraphGenerator().generateDataflowGraph(sourceTask, sinkTask, direct).generateDataflowGraph(sinkTask, sinkTask1, direct);
if (dataflowTaskGraph != null) {
dataflowTaskGraphParser = new DataflowTaskGraphParser(dataflowTaskGraph);
parsedTaskSet = dataflowTaskGraphParser.dataflowTaskGraphParseAndSchedule();
}
// the taskgraph scheduler is constructed...!
if (!parsedTaskSet.isEmpty() && containerId > 1) {
List<Task> taskList = new ArrayList<>();
for (Task processedTasks : parsedTaskSet) {
taskList.add(processedTasks);
}
LOG.info("Submitting Pipeline Task:" + taskList.size());
taskExecutionOptimizer = new TaskExecutionOptimizer(taskExecutor);
PipelinedTask pipelinedTask = new PipelinedTask(1, taskList);
pipelinedTask.execute();
}
}
Aggregations