private Table buildTable(RestRequest request, ClusterStateResponse state, IndicesStatsResponse stats) {
Table table = getTableWithHeader(request);
for (ShardRouting shard : state.getState().routingTable().allShards()) {
CommonStats shardStats = stats.asMap().get(shard);
table.startRow();
table.addCell(shard.index());
table.addCell(shard.id());
table.addCell(shard.primary() ? "p" : "r");
table.addCell(shard.state());
table.addCell(shardStats == null ? null : shardStats.getDocs().getCount());
table.addCell(shardStats == null ? null : shardStats.getStore().getSize());
if (shard.assignedToNode()) {
String ip = state.getState().nodes().get(shard.currentNodeId()).getHostAddress();
StringBuilder name = new StringBuilder();
name.append(state.getState().nodes().get(shard.currentNodeId()).name());
if (shard.relocating()) {
String reloIp = state.getState().nodes().get(shard.relocatingNodeId()).getHostAddress();
String reloNme = state.getState().nodes().get(shard.relocatingNodeId()).name();
name.append(" -> ");
name.append(reloIp);
name.append(" ");
name.append(reloNme);
}
table.addCell(ip);
table.addCell(name);
} else {
table.addCell(null);
table.addCell(null);
}
table.addCell(shardStats == null ? null : shardStats.getCompletion().getSize());
table.addCell(shardStats == null ? null : shardStats.getFieldData().getMemorySize());
table.addCell(shardStats == null ? null : shardStats.getFieldData().getEvictions());
table.addCell(shardStats == null ? null : shardStats.getFilterCache().getMemorySize());
table.addCell(shardStats == null ? null : shardStats.getFilterCache().getEvictions());
table.addCell(shardStats == null ? null : shardStats.getFlush().getTotal());
table.addCell(shardStats == null ? null : shardStats.getFlush().getTotalTime());
table.addCell(shardStats == null ? null : shardStats.getGet().current());
table.addCell(shardStats == null ? null : shardStats.getGet().getTime());
table.addCell(shardStats == null ? null : shardStats.getGet().getCount());
table.addCell(shardStats == null ? null : shardStats.getGet().getExistsTime());
table.addCell(shardStats == null ? null : shardStats.getGet().getExistsCount());
table.addCell(shardStats == null ? null : shardStats.getGet().getMissingTime());
table.addCell(shardStats == null ? null : shardStats.getGet().getMissingCount());
table.addCell(shardStats == null ? null : shardStats.getIdCache().getMemorySize());
table.addCell(shardStats == null ? null : shardStats.getIndexing().getTotal().getDeleteCurrent());
table.addCell(shardStats == null ? null : shardStats.getIndexing().getTotal().getDeleteTime());
table.addCell(shardStats == null ? null : shardStats.getIndexing().getTotal().getDeleteCount());
table.addCell(shardStats == null ? null : shardStats.getIndexing().getTotal().getIndexCurrent());
table.addCell(shardStats == null ? null : shardStats.getIndexing().getTotal().getIndexTime());
table.addCell(shardStats == null ? null : shardStats.getIndexing().getTotal().getIndexCount());
table.addCell(shardStats == null ? null : shardStats.getMerge().getCurrent());
table.addCell(shardStats == null ? null : shardStats.getMerge().getCurrentNumDocs());
table.addCell(shardStats == null ? null : shardStats.getMerge().getCurrentSize());
table.addCell(shardStats == null ? null : shardStats.getMerge().getTotal());
table.addCell(shardStats == null ? null : shardStats.getMerge().getTotalNumDocs());
table.addCell(shardStats == null ? null : shardStats.getMerge().getTotalSize());
table.addCell(shardStats == null ? null : shardStats.getMerge().getTotalTime());
table.addCell(shardStats == null ? null : shardStats.getPercolate().getCurrent());
table.addCell(shardStats == null ? null : shardStats.getPercolate().getMemorySize());
table.addCell(shardStats == null ? null : shardStats.getPercolate().getNumQueries());
table.addCell(shardStats == null ? null : shardStats.getPercolate().getTime());
table.addCell(shardStats == null ? null : shardStats.getPercolate().getCount());
table.addCell(shardStats == null ? null : shardStats.getRefresh().getTotal());
table.addCell(shardStats == null ? null : shardStats.getRefresh().getTotalTime());
table.addCell(shardStats == null ? null : shardStats.getSearch().getTotal().getFetchCurrent());
table.addCell(shardStats == null ? null : shardStats.getSearch().getTotal().getFetchTime());
table.addCell(shardStats == null ? null : shardStats.getSearch().getTotal().getFetchCount());
table.addCell(shardStats == null ? null : shardStats.getSearch().getOpenContexts());
table.addCell(shardStats == null ? null : shardStats.getSearch().getTotal().getQueryCurrent());
table.addCell(shardStats == null ? null : shardStats.getSearch().getTotal().getQueryTime());
table.addCell(shardStats == null ? null : shardStats.getSearch().getTotal().getQueryCount());
table.addCell(shardStats == null ? null : shardStats.getSegments().getCount());
table.addCell(shardStats == null ? null : shardStats.getSegments().getMemory());
table.addCell(shardStats == null ? null : shardStats.getSegments().getIndexWriterMemory());
table.addCell(shardStats == null ? null : shardStats.getSegments().getIndexWriterMaxMemory());
table.addCell(shardStats == null ? null : shardStats.getSegments().getVersionMapMemory());
table.addCell(shardStats == null ? null : shardStats.getSegments().getBitsetMemory());
table.addCell(shardStats == null ? null : shardStats.getWarmer().current());
table.addCell(shardStats == null ? null : shardStats.getWarmer().total());
table.addCell(shardStats == null ? null : shardStats.getWarmer().totalTime());
table.endRow();
}
return table;