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); } }
public void stopJob(Batcher batcher, ConcurrentHashMap<String, JobTicket> activeJobs) { if ( batcher instanceof QueryBatcherImpl ) { ((QueryBatcherImpl) batcher).stop(); } else if ( batcher instanceof WriteBatcherImpl ) { ((WriteBatcherImpl) batcher).stop(); } if (batcher.getJobId() != null) activeJobs.remove(batcher.getJobId()); }
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); }
boolean shouldWeRetry = isHostUnavailableException; if ( isHostUnavailableException == true ) { ForestConfiguration existingForestConfig = batcher.getForestConfig(); Set<String> preferredHostsList = new HashSet<String>(Arrays.asList(existingForestConfig.getPreferredHosts())); if(existingForestConfig instanceof FilteredForestConfiguration) { filteredForestConfig = filteredForestConfig.withRenamedHost(host, randomAvailableHost); batcher.withForestConfig(filteredForestConfig); scheduleForestResynch(batcher, host); } else { logger.error("Encountered [" + throwable + "] on host \"" + host + "\" but black-listing it would drop job below minHosts (" + minHosts + "), so stopping job \"" + batcher.getJobName() + "\"", throwable); moveMgr.stopJob(batcher);
JobTicket ticket = moveMgr.getActiveJob(queryBatcherJobId); assertTrue("Job should be started now", queryBatcher.isStarted()); assertEquals(queryBatcherJobName, ticket.getBatcher().getJobName());