use of edu.iu.dsc.tws.api.comms.DataFlowOperation in project twister2 by DSC-SPIDAL.
the class WordCountWorker method execute.
@Override
public void execute(WorkerEnvironment wEnv) {
this.workerEnv = wEnv;
this.workerId = workerEnv.getWorkerId();
taskStages.add(NO_OF_TASKS);
taskStages.add(NO_OF_TASKS);
// lets create the task plan
this.logicalPlan = Utils.createStageLogicalPlan(workerEnv, taskStages);
setupTasks();
// create the communication
wordAggregator = new WordAggregator();
keyGather = new BKeyedReduce(workerEnv.getCommunicator(), logicalPlan, sources, destinations, new ReduceFunction() {
@Override
public void init(Config cfg, DataFlowOperation op, Map<Integer, List<Integer>> expectedIds) {
}
@Override
public Object reduce(Object t1, Object t2) {
return (Integer) t1 + (Integer) t2;
}
}, wordAggregator, MessageTypes.OBJECT, MessageTypes.INTEGER, new HashingSelector());
// assign the task ids to the workers, and run them using threads
scheduleTasks();
// progress the communication
progress();
// close communication
workerEnv.close();
}
Aggregations