private void scheduleForestResynch(Batcher batcher, String host) { // cancel any previously scheduled re-sync if ( future != null ) future.cancel(false); // schedule a re-sync with the server forest config future = Executors.newScheduledThreadPool(1) .schedule( () -> { if ( batcher.isStopped() ) { logger.debug("Job \"{}\" is stopped, so cancelling re-sync with the server forest config", batcher.getJobName()); } else { ForestConfiguration updatedForestConfig = moveMgr.readForestConfig(); logger.info("it's been {} since host {} failed, opening communication to all server hosts [{}]", suspendTimeForHostUnavailable.toString(), host, Arrays.asList(updatedForestConfig.getPreferredHosts())); // set the forestConfig back to whatever the server says it is batcher.withForestConfig(updatedForestConfig); } } , suspendTimeForHostUnavailable.toMillis(), TimeUnit.MILLISECONDS); }
public void prepareBatcher(Batcher batcher) { if (jobName != null) { batcher.withJobName(jobName); } if (batchSize != null && batchSize > 0) { batcher.withBatchSize(batchSize); } if (threadCount != null && threadCount > 0) { batcher.withThreadCount(threadCount); } if (forestConfig != null) { batcher.withForestConfig(forestConfig); } }
filteredForestConfig = filteredForestConfig.withRenamedHost(host, randomAvailableHost); batcher.withForestConfig(filteredForestConfig); scheduleForestResynch(batcher, host); } else {