Source:
public void onNext(final CompletedTask completedTask) { completedTask.getActiveContext().close(); final String taskId = completedTask.getId(); final ByteBuffer byteBuffer = ByteBuffer.wrap(completedTask.get()); if (taskId.startsWith(SENDER_PREFIX)) { final int numSentTuples = byteBuffer.getInt(); LOG.log(Level.INFO, "{0} completed. It sent {1} tuples", new Object[]{taskId, numSentTuples}); totalNumSentTuples.addAndGet(numSentTuples); } else if (taskId.startsWith(RECEIVER_PREFIX)) { final int numReceivedTuples = byteBuffer.getInt(); LOG.log(Level.INFO, "{0} completed. It received {1} tuples", new Object[]{taskId, numReceivedTuples}); totalNumReceivedTuples.addAndGet(numReceivedTuples); } else if (taskId.startsWith(SENDER_AND_RECEIVER_PREFIX)) { final int numSentTuples = byteBuffer.getInt(); final int numReceivedTuples = byteBuffer.getInt(); LOG.log(Level.INFO, "{0} completed. It sent {1} tuples", new Object[]{taskId, numSentTuples}); LOG.log(Level.INFO, "{0} completed. It received {1} tuples", new Object[]{taskId, numReceivedTuples}); totalNumSentTuples.addAndGet(numSentTuples); totalNumReceivedTuples.addAndGet(numReceivedTuples); } else { throw new RuntimeException("Unknown task identifier " + taskId); } if (numCompletedTasks.incrementAndGet() == totalNumSenders + totalNumReceivers + totalNumSendersAndReceivers) { LOG.log(Level.INFO, "Total sent tuple number : {0}, total received tuple number : {1}", new Object[]{totalNumSentTuples.get(), totalNumReceivedTuples.get()}); if (totalNumSentTuples.get() != totalNumReceivedTuples.get()) { throw new RuntimeException("Total sent tuple number " + totalNumSentTuples.get() + " have to be same as " + " total received tuple number " + totalNumReceivedTuples.get()); } } }

Target:
public void onNext(final CompletedTask completedTask) { completedTask.getActiveContext().close(); final String taskId = completedTask.getId(); final ByteBuffer byteBuffer = ByteBuffer.wrap(completedTask.get()); if (taskId.startsWith(SENDER_PREFIX)) { final int numSentTuples = byteBuffer.getInt(); LOG.log(Level.INFO, "{0} completed. It sent {1} tuples", new Object[]{taskId, numSentTuples}); totalNumSentTuples.addAndGet(numSentTuples); } else if (taskId.startsWith(RECEIVER_PREFIX)) { final int numReceivedTuples = byteBuffer.getInt(); LOG.log(Level.INFO, "{0} completed. It received {1} tuples", new Object[]{taskId, numReceivedTuples}); totalNumReceivedTuples.addAndGet(numReceivedTuples); } else if (taskId.startsWith(SENDER_AND_RECEIVER_PREFIX)) { final int numSentTuples = byteBuffer.getInt(); final int numReceivedTuples = byteBuffer.getInt(); LOG.log(Level.INFO, "{0} completed. It sent {1} tuples and received {2} tuples", new Object[]{taskId, numSentTuples, numReceivedTuples}); totalNumSentTuples.addAndGet(numSentTuples); totalNumReceivedTuples.addAndGet(numReceivedTuples); } else { throw new RuntimeException("Unknown task identifier " + taskId); } if (numCompletedTasks.incrementAndGet() == totalNumOnlySenders + totalNumOnlyReceivers + totalNumSendersAndReceivers) { LOG.log(Level.INFO, "Total sent tuple number : {0}, total received tuple number : {1}", new Object[]{totalNumSentTuples.get(), totalNumReceivedTuples.get()}); if (totalNumSentTuples.get() != totalNumReceivedTuples.get()) { throw new RuntimeException("Total sent tuple number " + totalNumSentTuples.get() + " have to be same as " + " total received tuple number " + totalNumReceivedTuples.get()); } } }