private List<Map<String, Object>> getShardInformation(IndexStats stats) { List<Map<String, Object>> shards = Lists.newArrayList(); for (Map.Entry<Integer, IndexShardStats> s : stats.getIndexShards().entrySet()) { Iterator<ShardStats> iter = s.getValue().iterator(); while (iter.hasNext()) { ShardStats ss = iter.next(); Map<String, Object> shard = Maps.newHashMap(); shard.put("node_hostname", cluster.nodeIdToHostName(ss.getShardRouting().currentNodeId())); shard.put("node_name", cluster.nodeIdToName(ss.getShardRouting().currentNodeId())); shard.put("id", ss.getShardId()); shard.put("node_id", ss.getShardRouting().currentNodeId()); shard.put("primary", ss.getShardRouting().primary()); shard.put("is_initializing", ss.getShardRouting().initializing()); shard.put("is_started", ss.getShardRouting().started()); shard.put("is_unassigned", ss.getShardRouting().unassigned()); shard.put("is_relocating", ss.getShardRouting().relocating()); shard.put("relocating_to", cluster.nodeIdToName(ss.getShardRouting().relocatingNodeId())); shards.add(shard); } } return shards; }
@Override protected void shutDown() throws Exception { LOG.debug("Stopping BufferSynchronizerService"); if (cluster.isConnected() && cluster.isDeflectorHealthy()) { final ExecutorService executorService = executorService(metricRegistry); executorService.submit( new Runnable() { @Override public void run() { bufferSynchronizer.waitForEmptyBuffers( 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"); }