Source:
private SortedMap<TServerInstance,TabletServerStatus> gatherTableInformation(Set<TServerInstance> currentServers) { long start = System.currentTimeMillis(); int threads = Math.max(getConfiguration().getCount(Property.MASTER_STATUS_THREAD_POOL_SIZE), 1); long timeout = getConfiguration().getTimeInMillis(Property.MASTER_STATUS_THREAD_TIMEOUT); final SortedMap<TServerInstance,TabletServerStatus> results = new ConcurrentSkipListMap<>(); try (TimeoutTaskExecutor<TabletServerStatus,GetTServerStatus> executor = new TimeoutTaskExecutor<>(threads, timeout, currentServers.size())) { executor.onSuccess(new SuccessCallback<TabletServerStatus,GetTServerStatus>() { @Override public void accept(GetTServerStatus task, TabletServerStatus result) { results.put(task.server, result); } }); executor.onException(new ExceptionCallback<GetTServerStatus>() { @Override public void accept(GetTServerStatus task, Exception e) { log.error("Exception occurred while getting status from " + task.server, e); handleBadServer(task.server); } }); executor.onTimeout(new TimeoutCallback<GetTServerStatus>() { @Override public void accept(GetTServerStatus task) { log.warn("Timed out while fetching status from " + task.server); handleBadServer(task.server); } }); for (TServerInstance server : currentServers) { executor.submit(new GetTServerStatus(server)); } executor.complete(); } catch (InterruptedException e) { log.debug("StatusThread interrupted while waiting for tserver status collection.", e); } synchronized (badServers) { badServers.keySet().retainAll(currentServers); badServers.keySet().removeAll(results.keySet()); } log.debug(String.format("Finished gathering information from %d servers in %.2f seconds", currentServers.size(), (System.currentTimeMillis() - start) / 1000.)); return results; }

Target:
private SortedMap<TServerInstance,TabletServerStatus> gatherTableInformation( Set<TServerInstance> currentServers) { long start = System.currentTimeMillis(); int threads = Math.max(getConfiguration().getCount(Property.MASTER_STATUS_THREAD_POOL_SIZE), 1); long timeout = getConfiguration().getTimeInMillis(Property.MASTER_STATUS_THREAD_TIMEOUT); final SortedMap<TServerInstance,TabletServerStatus> results = new TreeMap<>(); try ( TimeoutTaskExecutor<TabletServerStatus,GetTServerStatus> executor = new TimeoutTaskExecutor<>( threads, timeout, currentServers.size())) { executor.onSuccess(new SuccessCallback<TabletServerStatus,GetTServerStatus>() { @Override public void accept(GetTServerStatus task, TabletServerStatus result) { results.put(task.server, result); } }); executor.onException(new ExceptionCallback<GetTServerStatus>() { @Override public void accept(GetTServerStatus task, Exception e) { log.error("Exception occurred while getting status from " + task.server, e); handleBadServer(task.server); } }); executor.onTimeout(new TimeoutCallback<GetTServerStatus>() { @Override public void accept(GetTServerStatus task) { log.warn("Timed out while fetching status from " + task.server); handleBadServer(task.server); } }); for (TServerInstance server : currentServers) { executor.submit(new GetTServerStatus(server)); } executor.complete(); } catch (InterruptedException e) { log.debug("StatusThread interrupted while waiting for tserver status collection.", e); } synchronized (badServers) { badServers.keySet().retainAll(currentServers); badServers.keySet().removeAll(results.keySet()); } log.debug(String.format("Finished gathering information from %d servers in %.2f seconds", currentServers.size(), (System.currentTimeMillis() - start) / 1000.)); return results; }