use of edu.iu.dsc.tws.comms.batch.BGather in project twister2 by DSC-SPIDAL.
the class BGatherExample method compute.
@Override
protected void compute(WorkerEnvironment workerEnv) {
if (jobParameters.getTargets() != 1) {
LOG.warning("Setting no of targets to 1. Found " + jobParameters.getTargets());
jobParameters.getTaskStages().set(1, 1);
}
LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv);
// create the communication
gather = new BGather(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER_ARRAY, new FinalReduceReceiver(), false);
Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
for (int t : tasksOfExecutor) {
finishedSources.put(t, false);
}
if (tasksOfExecutor.size() == 0) {
sourcesDone = true;
}
this.resultsVerifier = new ResultsVerifier<>(inputDataArray, (ints, args) -> {
List<Tuple<Integer, int[]>> expectedData = new ArrayList<>();
for (Integer source : logicalPlanBuilder.getSources()) {
for (int i = 0; i < jobParameters.getTotalIterations(); i++) {
expectedData.add(new Tuple<>(source, ints));
}
}
return expectedData.iterator();
}, new IteratorComparator<>(new TupleComparator<>(IntComparator.getInstance(), IntArrayComparator.getInstance())));
LOG.log(Level.INFO, String.format("%d Sources %s target %d this %s", workerId, logicalPlanBuilder.getSources(), logicalPlanBuilder.getTargets().iterator().next(), tasksOfExecutor));
// now initialize the workers
for (int t : tasksOfExecutor) {
// the map thread where data is produced
Thread mapThread = new Thread(new MapWorker(t));
mapThread.start();
}
}
Aggregations