Source:
<code>private void startWorkersHandling() throws InterruptedException { final CountDownLatch workerViewInitialized = new CountDownLatch(1); DruidNodeDiscovery druidNodeDiscovery = druidNodeDiscoveryProvider.getForNodeType(NodeType.MIDDLE_MANAGER); druidNodeDiscovery.registerListener( new DruidNodeDiscovery.Listener() { @Override public void nodesAdded(Collection<DiscoveryDruidNode> nodes) { nodes.forEach(node -> addWorker(toWorker(node))); } @Override public void nodesRemoved(Collection<DiscoveryDruidNode> nodes) { nodes.forEach(node -> removeWorker(toWorker(node))); } @Override public void nodeViewInitialized() { workerViewInitialized.countDown(); } } ); <START> DruidNodeDiscovery druidNodeDiscoveryIndexer = druidNodeDiscoveryProvider.getForNodeType(NodeType.INDEXER); <END> druidNodeDiscoveryIndexer.registerListener( new DruidNodeDiscovery.Listener() { @Override public void nodesAdded(Collection<DiscoveryDruidNode> nodes) { nodes.forEach(node -> addWorker(toWorker(node))); } @Override public void nodesRemoved(Collection<DiscoveryDruidNode> nodes) { nodes.forEach(node -> removeWorker(toWorker(node))); } @Override public void nodeViewInitialized() { workerViewInitialized.countDown(); } } ); long workerDiscoveryStartTime = System.currentTimeMillis(); while (!workerViewInitialized.await(30, TimeUnit.SECONDS)) { if (System.currentTimeMillis() - workerDiscoveryStartTime > TimeUnit.MINUTES.toMillis(5)) { throw new ISE("WTF! Couldn't discover workers."); } else { log.info("Waiting for worker discovery..."); } } log.info("[%s] Workers are discovered.", workers.size()); for (WorkerHolder worker : workers.values()) { log.info("Waiting for worker[%s] to sync state...", worker.getWorker().getHost()); worker.waitForInitialization(); } log.info("Workers have sync'd state successfully."); }</code><technical_language>Instead of repeated code change line 441 DruidNodeDiscovery druidNodeDiscovery = druidNodeDiscoveryProvider.getForService(WorkerNodeService.DISCOVERY_SERVICE_KEY);</technical_language>

Target:
private void startWorkersHandling() throws InterruptedException { final CountDownLatch workerViewInitialized = new CountDownLatch(1); DruidNodeDiscovery druidNodeDiscovery = druidNodeDiscoveryProvider.getForService( WorkerNodeService.DISCOVERY_SERVICE_KEY ); druidNodeDiscovery.registerListener( new DruidNodeDiscovery.Listener() { @Override public void nodesAdded(Collection<DiscoveryDruidNode> nodes) { nodes.forEach(node -> addWorker(toWorker(node))); } @Override public void nodesRemoved(Collection<DiscoveryDruidNode> nodes) { nodes.forEach(node -> removeWorker(toWorker(node))); } @Override public void nodeViewInitialized() { workerViewInitialized.countDown(); } } ); long workerDiscoveryStartTime = System.currentTimeMillis(); while (!workerViewInitialized.await(30, TimeUnit.SECONDS)) { if (System.currentTimeMillis() - workerDiscoveryStartTime > TimeUnit.MINUTES.toMillis(5)) { throw new ISE("WTF! Couldn't discover workers."); } else { log.info("Waiting for worker discovery..."); } } log.info("[%s] Workers are discovered.", workers.size()); for (WorkerHolder worker : workers.values()) { log.info("Waiting for worker[%s] to sync state...", worker.getWorker().getHost()); worker.waitForInitialization(); } log.info("Workers have sync'd state successfully."); }