Search in sources :

Example 1 with HashingSelector

use of edu.iu.dsc.tws.comms.selectors.HashingSelector 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)

Example 2 with HashingSelector

use of edu.iu.dsc.tws.comms.selectors.HashingSelector in project twister2 by DSC-SPIDAL.

the class WordCountWorker method execute.

@Override
public void execute(Config cfg, JobAPI.Job job, IWorkerController workerController, IPersistentVolume persistentVolume, IVolatileVolume volatileVolume) {
    this.config = cfg;
    this.id = workerController.getWorkerInfo().getWorkerID();
    this.noOfTasksPerExecutor = NO_OF_TASKS / workerController.getNumberOfWorkers();
    setupTasks(workerController);
    setupNetwork(workerController);
    // create the communication
    keyedPartition = new SPartition(channel, logicalPlan, sources, destinations, MessageTypes.OBJECT, new WordAggregate(), new HashingSelector());
    scheduleTasks();
    progress();
}
Also used : HashingSelector(edu.iu.dsc.tws.comms.selectors.HashingSelector) SPartition(edu.iu.dsc.tws.comms.stream.SPartition)

Example 3 with HashingSelector

use of edu.iu.dsc.tws.comms.selectors.HashingSelector in project twister2 by DSC-SPIDAL.

the class SKeyedPartitionExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    // create the communication
    partition = new SKeyedPartition(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER, MessageTypes.INTEGER_ARRAY, new PartitionReceiver(), new HashingSelector());
    this.resultsVerifier = new ResultsVerifier<>(inputDataArray, (ints, args) -> new Tuple<>(-1, ints), new TupleComparator<>(// any int
    (d1, d2) -> true, IntArrayComparator.getInstance()));
    Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
    // now initialize the workers
    for (int t : tasksOfExecutor) {
        // the map thread where data is produced
        Thread mapThread = new Thread(new MapWorker(t));
        mapThread.start();
    }
}
Also used : IntArrayComparator(edu.iu.dsc.tws.examples.verification.comparators.IntArrayComparator) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) SingularReceiver(edu.iu.dsc.tws.api.comms.SingularReceiver) Set(java.util.Set) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) Config(edu.iu.dsc.tws.api.config.Config) MessageTypes(edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes) Logger(java.util.logging.Logger) Level(java.util.logging.Level) TupleComparator(edu.iu.dsc.tws.examples.verification.comparators.TupleComparator) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) KeyedBenchWorker(edu.iu.dsc.tws.examples.comms.KeyedBenchWorker) SKeyedPartition(edu.iu.dsc.tws.comms.stream.SKeyedPartition) ResultsVerifier(edu.iu.dsc.tws.examples.verification.ResultsVerifier) HashingSelector(edu.iu.dsc.tws.comms.selectors.HashingSelector) SKeyedPartition(edu.iu.dsc.tws.comms.stream.SKeyedPartition) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) TupleComparator(edu.iu.dsc.tws.examples.verification.comparators.TupleComparator) HashingSelector(edu.iu.dsc.tws.comms.selectors.HashingSelector) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple)

Aggregations

HashingSelector (edu.iu.dsc.tws.comms.selectors.HashingSelector)3 Config (edu.iu.dsc.tws.api.config.Config)2 DataFlowOperation (edu.iu.dsc.tws.api.comms.DataFlowOperation)1 ReduceFunction (edu.iu.dsc.tws.api.comms.ReduceFunction)1 SingularReceiver (edu.iu.dsc.tws.api.comms.SingularReceiver)1 MessageTypes (edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes)1 Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)1 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)1 BKeyedReduce (edu.iu.dsc.tws.comms.batch.BKeyedReduce)1 SKeyedPartition (edu.iu.dsc.tws.comms.stream.SKeyedPartition)1 SPartition (edu.iu.dsc.tws.comms.stream.SPartition)1 LogicalPlanBuilder (edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder)1 KeyedBenchWorker (edu.iu.dsc.tws.examples.comms.KeyedBenchWorker)1 ResultsVerifier (edu.iu.dsc.tws.examples.verification.ResultsVerifier)1 IntArrayComparator (edu.iu.dsc.tws.examples.verification.comparators.IntArrayComparator)1 TupleComparator (edu.iu.dsc.tws.examples.verification.comparators.TupleComparator)1 Map (java.util.Map)1 Set (java.util.Set)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1