use of edu.iu.dsc.tws.comms.batch.BPartition in project twister2 by DSC-SPIDAL.
the class BPartitionExample method compute.
@Override
protected void compute(WorkerEnvironment workerEnv) {
LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
// create the communication
partition = new BPartition(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER_ARRAY, new PartitionReceiver(), new LoadBalanceSelector(), false);
this.resultsVerifier = new ResultsVerifier<>(inputDataArray, (ints, args) -> {
int lowestTarget = logicalPlanBuilder.getTargets().stream().min(Comparator.comparingInt(o -> (Integer) o)).get();
int target = Integer.parseInt(args.get("target").toString());
int toThisFromOneSource = jobParameters.getTotalIterations() / logicalPlanBuilder.getTargets().size();
if (jobParameters.getTotalIterations() % logicalPlanBuilder.getTargets().size() > (target - lowestTarget)) {
toThisFromOneSource++;
}
List<int[]> expectedData = new ArrayList<>();
for (int i = 0; i < toThisFromOneSource * logicalPlanBuilder.getSources().size(); i++) {
expectedData.add(ints);
}
return expectedData.iterator();
}, new IteratorComparator<>(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 BenchWorker.MapWorker(t));
mapThread.start();
}
}
Aggregations