use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class RestFielddataAction method buildTable.
private Table buildTable(final RestRequest request, final NodesStatsResponse nodeStatses) {
Table table = getTableWithHeader(request);
for (NodeStats nodeStats : nodeStatses.getNodes()) {
if (nodeStats.getIndices().getFieldData().getFields() != null) {
for (ObjectLongCursor<String> cursor : nodeStats.getIndices().getFieldData().getFields()) {
table.startRow();
table.addCell(nodeStats.getNode().getId());
table.addCell(nodeStats.getNode().getHostName());
table.addCell(nodeStats.getNode().getHostAddress());
table.addCell(nodeStats.getNode().getName());
table.addCell(cursor.key);
table.addCell(new ByteSizeValue(cursor.value));
table.endRow();
}
}
}
return table;
}
use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class RestIndicesAction method buildTable.
// package private for testing
Table buildTable(RestRequest request, Index[] indices, ClusterHealthResponse response, IndicesStatsResponse stats, MetaData indexMetaDatas) {
final String healthParam = request.param("health");
final ClusterHealthStatus status;
if (healthParam != null) {
status = ClusterHealthStatus.fromString(healthParam);
} else {
status = null;
}
Table table = getTableWithHeader(request);
for (final Index index : indices) {
final String indexName = index.getName();
ClusterIndexHealth indexHealth = response.getIndices().get(indexName);
IndexStats indexStats = stats.getIndices().get(indexName);
IndexMetaData indexMetaData = indexMetaDatas.getIndices().get(indexName);
IndexMetaData.State state = indexMetaData.getState();
if (status != null) {
if (state == IndexMetaData.State.CLOSE || (indexHealth == null && !ClusterHealthStatus.RED.equals(status)) || !indexHealth.getStatus().equals(status)) {
continue;
}
}
table.startRow();
table.addCell(state == IndexMetaData.State.OPEN ? (indexHealth == null ? "red*" : indexHealth.getStatus().toString().toLowerCase(Locale.ROOT)) : null);
table.addCell(state.toString().toLowerCase(Locale.ROOT));
table.addCell(indexName);
table.addCell(index.getUUID());
table.addCell(indexHealth == null ? null : indexHealth.getNumberOfShards());
table.addCell(indexHealth == null ? null : indexHealth.getNumberOfReplicas());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getDocs().getCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getDocs().getDeleted());
table.addCell(indexMetaData.getCreationDate());
table.addCell(new DateTime(indexMetaData.getCreationDate(), DateTimeZone.UTC));
table.addCell(indexStats == null ? null : indexStats.getTotal().getStore().size());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getStore().size());
table.addCell(indexStats == null ? null : indexStats.getTotal().getCompletion().getSize());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getCompletion().getSize());
table.addCell(indexStats == null ? null : indexStats.getTotal().getFieldData().getMemorySize());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFieldData().getMemorySize());
table.addCell(indexStats == null ? null : indexStats.getTotal().getFieldData().getEvictions());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFieldData().getEvictions());
table.addCell(indexStats == null ? null : indexStats.getTotal().getQueryCache().getMemorySize());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getQueryCache().getMemorySize());
table.addCell(indexStats == null ? null : indexStats.getTotal().getQueryCache().getEvictions());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getQueryCache().getEvictions());
table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getMemorySize());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getMemorySize());
table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getEvictions());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getEvictions());
table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getHitCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getHitCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getMissCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getMissCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getFlush().getTotal());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFlush().getTotal());
table.addCell(indexStats == null ? null : indexStats.getTotal().getFlush().getTotalTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFlush().getTotalTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().current());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().current());
table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getExistsTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getExistsTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getExistsCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getExistsCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getMissingTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getMissingTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getMissingCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getMissingCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getDeleteCurrent());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getDeleteCurrent());
table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getDeleteTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getDeleteTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getDeleteCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getDeleteCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexCurrent());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexCurrent());
table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexFailedCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexFailedCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getCurrent());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getCurrent());
table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getCurrentNumDocs());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getCurrentNumDocs());
table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getCurrentSize());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getCurrentSize());
table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotal());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotal());
table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotalNumDocs());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotalNumDocs());
table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotalSize());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotalSize());
table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotalTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotalTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getRefresh().getTotal());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRefresh().getTotal());
table.addCell(indexStats == null ? null : indexStats.getTotal().getRefresh().getTotalTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRefresh().getTotalTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getRefresh().getListeners());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRefresh().getListeners());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getFetchCurrent());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getFetchCurrent());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getFetchTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getFetchTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getFetchCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getFetchCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getOpenContexts());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getOpenContexts());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getQueryCurrent());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getQueryCurrent());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getQueryTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getQueryTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getQueryCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getQueryCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getScrollCurrent());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getScrollCurrent());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getScrollTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getScrollTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getScrollCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getScrollCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getMemory());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getMemory());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getIndexWriterMemory());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getIndexWriterMemory());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getVersionMapMemory());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getVersionMapMemory());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getBitsetMemory());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getBitsetMemory());
table.addCell(indexStats == null ? null : indexStats.getTotal().getWarmer().current());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getWarmer().current());
table.addCell(indexStats == null ? null : indexStats.getTotal().getWarmer().total());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getWarmer().total());
table.addCell(indexStats == null ? null : indexStats.getTotal().getWarmer().totalTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getWarmer().totalTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getSuggestCurrent());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getSuggestCurrent());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getSuggestTime());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getSuggestTime());
table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getSuggestCount());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getSuggestCount());
table.addCell(indexStats == null ? null : indexStats.getTotal().getTotalMemory());
table.addCell(indexStats == null ? null : indexStats.getPrimaries().getTotalMemory());
table.endRow();
}
return table;
}
use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class RestRecoveryAction method buildRecoveryTable.
/**
* buildRecoveryTable will build a table of recovery information suitable
* for displaying at the command line.
*
* @param request A Rest request
* @param response A recovery status response
* @return A table containing index, shardId, node, target size, recovered size and percentage for each recovering replica
*/
public Table buildRecoveryTable(RestRequest request, RecoveryResponse response) {
Table t = getTableWithHeader(request);
for (String index : response.shardRecoveryStates().keySet()) {
List<RecoveryState> shardRecoveryStates = response.shardRecoveryStates().get(index);
if (shardRecoveryStates.size() == 0) {
continue;
}
// Sort ascending by shard id for readability
CollectionUtil.introSort(shardRecoveryStates, new Comparator<RecoveryState>() {
@Override
public int compare(RecoveryState o1, RecoveryState o2) {
int id1 = o1.getShardId().id();
int id2 = o2.getShardId().id();
if (id1 < id2) {
return -1;
} else if (id1 > id2) {
return 1;
} else {
return 0;
}
}
});
for (RecoveryState state : shardRecoveryStates) {
t.startRow();
t.addCell(index);
t.addCell(state.getShardId().id());
t.addCell(new TimeValue(state.getTimer().time()));
t.addCell(state.getRecoverySource().getType().toString().toLowerCase(Locale.ROOT));
t.addCell(state.getStage().toString().toLowerCase(Locale.ROOT));
t.addCell(state.getSourceNode() == null ? "n/a" : state.getSourceNode().getHostName());
t.addCell(state.getSourceNode() == null ? "n/a" : state.getSourceNode().getName());
t.addCell(state.getTargetNode().getHostName());
t.addCell(state.getTargetNode().getName());
t.addCell(state.getRecoverySource() == null || state.getRecoverySource().getType() != RecoverySource.Type.SNAPSHOT ? "n/a" : ((SnapshotRecoverySource) state.getRecoverySource()).snapshot().getRepository());
t.addCell(state.getRecoverySource() == null || state.getRecoverySource().getType() != RecoverySource.Type.SNAPSHOT ? "n/a" : ((SnapshotRecoverySource) state.getRecoverySource()).snapshot().getSnapshotId().getName());
t.addCell(state.getIndex().totalRecoverFiles());
t.addCell(state.getIndex().recoveredFileCount());
t.addCell(String.format(Locale.ROOT, "%1.1f%%", state.getIndex().recoveredFilesPercent()));
t.addCell(state.getIndex().totalFileCount());
t.addCell(state.getIndex().totalRecoverBytes());
t.addCell(state.getIndex().recoveredBytes());
t.addCell(String.format(Locale.ROOT, "%1.1f%%", state.getIndex().recoveredBytesPercent()));
t.addCell(state.getIndex().totalBytes());
t.addCell(state.getTranslog().totalOperations());
t.addCell(state.getTranslog().recoveredOperations());
t.addCell(String.format(Locale.ROOT, "%1.1f%%", state.getTranslog().recoveredPercent()));
t.endRow();
}
}
return t;
}
use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class RestRecoveryAction method getTableWithHeader.
@Override
protected Table getTableWithHeader(RestRequest request) {
Table t = new Table();
t.startHeaders().addCell("index", "alias:i,idx;desc:index name").addCell("shard", "alias:s,sh;desc:shard name").addCell("time", "alias:t,ti;desc:recovery time").addCell("type", "alias:ty;desc:recovery type").addCell("stage", "alias:st;desc:recovery stage").addCell("source_host", "alias:shost;desc:source host").addCell("source_node", "alias:snode;desc:source node name").addCell("target_host", "alias:thost;desc:target host").addCell("target_node", "alias:tnode;desc:target node name").addCell("repository", "alias:rep;desc:repository").addCell("snapshot", "alias:snap;desc:snapshot").addCell("files", "alias:f;desc:number of files to recover").addCell("files_recovered", "alias:fr;desc:files recovered").addCell("files_percent", "alias:fp;desc:percent of files recovered").addCell("files_total", "alias:tf;desc:total number of files").addCell("bytes", "alias:b;desc:number of bytes to recover").addCell("bytes_recovered", "alias:br;desc:bytes recovered").addCell("bytes_percent", "alias:bp;desc:percent of bytes recovered").addCell("bytes_total", "alias:tb;desc:total number of bytes").addCell("translog_ops", "alias:to;desc:number of translog ops to recover").addCell("translog_ops_recovered", "alias:tor;desc:translog ops recovered").addCell("translog_ops_percent", "alias:top;desc:percent of translog ops recovered").endHeaders();
return t;
}
use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class RestRepositoriesAction method buildTable.
private Table buildTable(RestRequest req, GetRepositoriesResponse getRepositoriesResponse) {
Table table = getTableWithHeader(req);
for (RepositoryMetaData repositoryMetaData : getRepositoriesResponse.repositories()) {
table.startRow();
table.addCell(repositoryMetaData.name());
table.addCell(repositoryMetaData.type());
table.endRow();
}
return table;
}
Aggregations