Search in sources :

Example 1 with DataFlowOperation

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();
}
Also used : BKeyedReduce(edu.iu.dsc.tws.comms.batch.BKeyedReduce) Config(edu.iu.dsc.tws.api.config.Config) DataFlowOperation(edu.iu.dsc.tws.api.comms.DataFlowOperation) ReduceFunction(edu.iu.dsc.tws.api.comms.ReduceFunction) HashingSelector(edu.iu.dsc.tws.comms.selectors.HashingSelector) Map(java.util.Map)

Aggregations

DataFlowOperation (edu.iu.dsc.tws.api.comms.DataFlowOperation)1 ReduceFunction (edu.iu.dsc.tws.api.comms.ReduceFunction)1 Config (edu.iu.dsc.tws.api.config.Config)1 BKeyedReduce (edu.iu.dsc.tws.comms.batch.BKeyedReduce)1 HashingSelector (edu.iu.dsc.tws.comms.selectors.HashingSelector)1 Map (java.util.Map)1