@Override
protected void shutDown() throws Exception {
LOG.debug("Stopping BufferSynchronizerService");
if (indexerAvailable && cluster.isConnectedAndHealthy()) {
final ExecutorService executorService = new InstrumentedExecutorService(Executors.newFixedThreadPool(2), metricRegistry);
executorService.submit(new Runnable() {
@Override
public void run() {
bufferSynchronizer.waitForEmptyBuffers(configuration.getShutdownTimeout(), TimeUnit.MILLISECONDS);
}
});
executorService.submit(new Runnable() {
@Override
public void run() {
cacheSynchronizer.waitForEmptyCaches(configuration.getShutdownTimeout(), TimeUnit.MILLISECONDS);
}
});
executorService.shutdown();
executorService.awaitTermination(configuration.getShutdownTimeout(), TimeUnit.MILLISECONDS);
} else {
LOG.warn("Elasticsearch is unavailable. Not waiting to clear buffers and caches, as we have no healthy cluster.");
}
LOG.debug("Stopped BufferSynchronizerService");
}