Source:
public void onNext(final RunningTask runningTask) { LOG.log(Level.INFO, "Task {0} is running", runningTask.getId()); if (isMasterRunning.compareAndSet(false, true)) { int taskCount = 0; while (taskCount < mistDriverConfigs.getNumTasks()) { final ActiveContext taskContext = mistTaskContextQueue.remove(); final Configuration taskConf = mistTaskConfQueue.remove(); taskContext.submitTask(taskConf); taskCount += 1; } final String masterHostAddress = runningTask.getActiveContext().getEvaluatorDescriptor().getNodeDescriptor() .getInetSocketAddress().getHostName(); final int driverToMasterPort = mistDriverConfigs.getDriverToMasterPort(); try { final NettyTransceiver driverToMaster = new NettyTransceiver(new InetSocketAddress(masterHostAddress, driverToMasterPort)); proxyToMaster = SpecificRequestor.getClient(DriverToMasterMessage.class, driverToMaster); } catch (final IOException e) { LOG.log(Level.SEVERE, "IOException occurred during setting up driver-to-master avro connection!"); throw new RuntimeException("driver-to-master avro connection failed"); } } else { final String taskHostAddress = runningTask.getActiveContext().getEvaluatorDescriptor().getNodeDescriptor() .getInetSocketAddress().getHostName(); try { proxyToMaster.addTask(taskHostAddress); proxyToMaster.setupMasterToTaskConn(taskHostAddress); if (runningTaskNum.incrementAndGet() == mistDriverConfigs.getNumTasks()) { proxyToMaster.taskSetupFinished(); } } catch (final AvroRemoteException e) { LOG.log(Level.SEVERE, "AvroRemoteException occurred during adding a task to master!"); throw new RuntimeException("Avro addTask failed!"); } } }

Target:
public void onNext(final RunningTask runningTask) { LOG.log(Level.INFO, "Task {0} is running", runningTask.getId()); if (isMasterRunning.compareAndSet(false, true)) { int taskCount = 0; while (taskCount < mistDriverConfigs.getNumTasks()) { final ActiveContext taskContext = mistTaskContextQueue.remove(); final Configuration taskConf = mistTaskConfQueue.remove(); taskContext.submitTask(taskConf); taskCount += 1; } final String masterHostname = runningTask.getActiveContext().getEvaluatorDescriptor().getNodeDescriptor() .getInetSocketAddress().getHostName(); final int driverToMasterPort = mistDriverConfigs.getDriverToMasterPort(); try { final NettyTransceiver driverToMaster = new NettyTransceiver(new InetSocketAddress(masterHostname, driverToMasterPort)); proxyToMaster = SpecificRequestor.getClient(DriverToMasterMessage.class, driverToMaster); } catch (final IOException e) { LOG.log(Level.SEVERE, "IOException occurred during setting up driver-to-master avro connection!"); throw new RuntimeException("driver-to-master avro connection failed"); } } else { final String taskHostname = runningTask.getActiveContext().getEvaluatorDescriptor().getNodeDescriptor() .getInetSocketAddress().getHostName(); try { proxyToMaster.addTask(taskHostname); proxyToMaster.setupMasterToTaskConn(taskHostname); if (runningTaskNum.incrementAndGet() == mistDriverConfigs.getNumTasks()) { proxyToMaster.taskSetupFinished(); } } catch (final AvroRemoteException e) { LOG.log(Level.SEVERE, "AvroRemoteException occurred during adding a task to master!"); throw new RuntimeException("Avro addTask failed!"); } } }