use of edu.iu.dsc.tws.comms.batch.BBroadcast in project twister2 by DSC-SPIDAL.
the class BBroadcastExample method compute.
@Override
protected void compute(WorkerEnvironment workerEnv) {
if (jobParameters.getTaskStages().get(0) != 1) {
LOG.warning("Setting no of senders to 1");
jobParameters.getTaskStages().set(0, 1);
}
int source = 0;
LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
// create the communication
bcast = new BBroadcast(workerEnv.getCommunicator(), logicalPlanBuilder, new BCastReceiver(), MessageTypes.INTEGER_ARRAY, true);
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<int[]> expectedData = new ArrayList<>();
for (int i = 0; i < jobParameters.getTotalIterations(); i++) {
expectedData.add(ints);
}
return expectedData.iterator();
}, new IteratorComparator<>(IntArrayComparator.getInstance()));
// the map thread where data is produced
if (workerId == 0) {
Thread mapThread = new Thread(new MapWorker(source));
mapThread.start();
}
}
Aggregations