use of edu.iu.dsc.tws.task.executiongraph.ExecutionGraph in project twister2 by DSC-SPIDAL.
the class SimpleTGraphExample 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 = 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 SimpleTGraphExample.PingPongReceive());
taskExecutor.initCommunication(channel, direct);
TMapper tMapper = new TMapper("1");
TReducer tReducer = new TReducer("2");
TShuffler tShuffler = new TShuffler("3");
TReducer tMergeFinal = new TReducer("4");
// Add the real input data files in the array list...
tMapper.addInputData("mapper1", new ArrayList<>());
tMapper.addInputData("mapper2", new ArrayList<>());
// Add the real input data files in the array list...
tReducer.addInputData("reducer1", new ArrayList<>());
tReducer.addInputData("reducer2", new ArrayList<>());
// Add the real input data files in the array list...
tShuffler.addInputData("shuffler1", new ArrayList<>());
tShuffler.addInputData("shuffler2", new ArrayList<>());
// Add the real input data files in the array list...
tMergeFinal.addInputData("merge1", new ArrayList<>());
tMergeFinal.addInputData("merge2", new ArrayList<>());
// Mention the output data files to be generated in the array list...
tMapper.addOutputData("mapperOut1", new ArrayList<>());
tMapper.addOutputData("mapperOut2", new ArrayList<>());
if (taskGraphFlag >= 0) {
// just for verification (replace with proper value)
/*dataflowTaskGraphGenerator = new DataflowTaskGraphGenerator()
.generateTGraph(tMapper, tShuffler, new DataflowOperation("Map"))
.generateTGraph(tMapper, tReducer, new DataflowOperation("Shuffle"))
.generateTGraph(tShuffler, tReducerFinal, new DataflowOperation("finalReduce"))
.generateTGraph(tReducer, tReducerFinal, new DataflowOperation("finalReduce"));*/
dataflowTaskGraphGenerator = new DataflowTaskGraphGenerator().generateTGraph(tMapper).generateTGraph(tMapper, tReducer, new DataflowOperation("Reduce")).generateTGraph(tMapper, tShuffler, new DataflowOperation("Shuffle")).generateTGraph(tReducer, tMergeFinal, new DataflowOperation("Merge1")).generateTGraph(tShuffler, tMergeFinal, new DataflowOperation("Merge2"));
LOG.info("Generated Dataflow Task Graph Vertices:" + dataflowTaskGraphGenerator.getTGraph().getTaskVertexSet());
if (dataflowTaskGraphGenerator != null) {
dataflowTGraphParser = new DataflowTGraphParser(dataflowTaskGraphGenerator);
parsedTaskSet = dataflowTGraphParser.dataflowTGraphParseAndSchedule();
LOG.info("parsed task set:" + parsedTaskSet);
}
// parsedTaskSet = executionGraph.parseTaskGraph(dataflowTaskGraphGenerator);
if (!parsedTaskSet.isEmpty()) {
// newly added for testing
executionGraph = new ExecutionGraph(parsedTaskSet);
String message = executionGraph.generateExecutionGraph(containerId);
// String message = executionGraph.generateExecutionGraph(containerId, parsedTaskSet);
/*TaskExecutorFixedThread taskExecutionGraph =
executionGraph.generateExecutionGraph(containerId, parsedTaskSet);*/
LOG.info(message);
}
}
// It removes only the first tax vertex in the parsedTaskSet.
// dataflowTaskGraphGenerator.removeTaskVertex(parsedTaskSet.iterator().next());
// It is getting concurrent modification exception...!
/*for (TaskGraphMapper processedTask : parsedTaskSet) {
dataflowTaskGraphGenerator.removeTaskVertex(processedTask);
}*/
}
Aggregations