use of edu.iu.dsc.tws.comms.stream.SBroadCast in project twister2 by DSC-SPIDAL.
the class SBroadcastExample method compute.
@Override
protected void compute(WorkerEnvironment workerEnv) {
if (jobParameters.getTaskStages().get(0) != 1) {
LOG.warning("Setting task stages to 1");
jobParameters.getTaskStages().set(0, 1);
}
LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
// create the communication
bcast = new SBroadCast(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER_ARRAY, new BCastReceiver());
Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
for (int t : tasksOfExecutor) {
finishedSources.put(t, false);
}
if (tasksOfExecutor.size() == 0) {
sourcesDone = true;
}
Set<Integer> targetTasksOfExecutor = logicalPlanBuilder.getTargetsOnThisWorker();
for (int taskId : targetTasksOfExecutor) {
if (logicalPlanBuilder.getTargets().contains(taskId)) {
bCastDone = false;
if (workerId == 0) {
receiverInWorker0 = taskId;
}
}
}
this.resultsVerifier = new ResultsVerifier<>(inputDataArray, (array, args) -> array, IntArrayComparator.getInstance());
// the map thread where data is produced
if (workerId == 0) {
Thread mapThread = new Thread(new MapWorker(logicalPlanBuilder.getSources().iterator().next()));
mapThread.start();
}
}
Aggregations