Search in sources :

Example 41 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class RestSegmentsAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(RestRequest request) {
    Table table = new Table();
    table.startHeaders();
    table.addCell("index", "default:true;alias:i,idx;desc:index name");
    table.addCell("shard", "default:true;alias:s,sh;desc:shard name");
    table.addCell("prirep", "alias:p,pr,primaryOrReplica;default:true;desc:primary or replica");
    table.addCell("ip", "default:true;desc:ip of node where it lives");
    table.addCell("id", "default:false;desc:unique id of node where it lives");
    table.addCell("segment", "default:true;alias:seg;desc:segment name");
    table.addCell("generation", "default:true;alias:g,gen;text-align:right;desc:segment generation");
    table.addCell("docs.count", "default:true;alias:dc,docsCount;text-align:right;desc:number of docs in segment");
    table.addCell("docs.deleted", "default:true;alias:dd,docsDeleted;text-align:right;desc:number of deleted docs in segment");
    table.addCell("size", "default:true;alias:si;text-align:right;desc:segment size in bytes");
    table.addCell("size.memory", "default:true;alias:sm,sizeMemory;text-align:right;desc:segment memory in bytes");
    table.addCell("committed", "default:true;alias:ic,isCommitted;desc:is segment committed");
    table.addCell("searchable", "default:true;alias:is,isSearchable;desc:is segment searched");
    table.addCell("version", "default:true;alias:v,ver;desc:version");
    table.addCell("compound", "default:true;alias:ico,isCompound;desc:is segment compound");
    table.endHeaders();
    return table;
}
Also used : Table(org.elasticsearch.common.Table)

Example 42 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class RestSegmentsAction method doCatRequest.

@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    clusterStateRequest.clear().nodes(true).routingTable(true).indices(indices);
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {

        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            final IndicesSegmentsRequest indicesSegmentsRequest = new IndicesSegmentsRequest();
            indicesSegmentsRequest.indices(indices);
            client.admin().indices().segments(indicesSegmentsRequest, new RestResponseListener<IndicesSegmentResponse>(channel) {

                @Override
                public RestResponse buildResponse(final IndicesSegmentResponse indicesSegmentResponse) throws Exception {
                    final Map<String, IndexSegments> indicesSegments = indicesSegmentResponse.getIndices();
                    Table tab = buildTable(request, clusterStateResponse, indicesSegments);
                    return RestTable.buildResponse(tab, channel);
                }
            });
        }
    });
}
Also used : IndicesSegmentResponse(org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) GET(org.elasticsearch.rest.RestRequest.Method.GET) IndicesSegmentsRequest(org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest) RestResponse(org.elasticsearch.rest.RestResponse) ShardSegments(org.elasticsearch.action.admin.indices.segments.ShardSegments) Table(org.elasticsearch.common.Table) RestController(org.elasticsearch.rest.RestController) Strings(org.elasticsearch.common.Strings) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) Segment(org.elasticsearch.index.engine.Segment) List(java.util.List) Settings(org.elasticsearch.common.settings.Settings) IndexSegments(org.elasticsearch.action.admin.indices.segments.IndexSegments) Map(java.util.Map) RestRequest(org.elasticsearch.rest.RestRequest) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IndexShardSegments(org.elasticsearch.action.admin.indices.segments.IndexShardSegments) RestActionListener(org.elasticsearch.rest.action.RestActionListener) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) Table(org.elasticsearch.common.Table) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) IndicesSegmentResponse(org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse) IndicesSegmentsRequest(org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest) IndexSegments(org.elasticsearch.action.admin.indices.segments.IndexSegments)

Example 43 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class RestAllocationAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(final RestRequest request) {
    final Table table = new Table();
    table.startHeaders();
    table.addCell("shards", "alias:s;text-align:right;desc:number of shards on node");
    table.addCell("disk.indices", "alias:di,diskIndices;text-align:right;desc:disk used by ES indices");
    table.addCell("disk.used", "alias:du,diskUsed;text-align:right;desc:disk used (total, not just ES)");
    table.addCell("disk.avail", "alias:da,diskAvail;text-align:right;desc:disk available");
    table.addCell("disk.total", "alias:dt,diskTotal;text-align:right;desc:total capacity of all volumes");
    table.addCell("disk.percent", "alias:dp,diskPercent;text-align:right;desc:percent disk used");
    table.addCell("host", "alias:h;desc:host of node");
    table.addCell("ip", "desc:ip of node");
    table.addCell("node", "alias:n;desc:name of node");
    table.endHeaders();
    return table;
}
Also used : Table(org.elasticsearch.common.Table)

Example 44 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class RestAllocationAction method buildTable.

private Table buildTable(RestRequest request, final ClusterStateResponse state, final NodesStatsResponse stats) {
    final ObjectIntScatterMap<String> allocs = new ObjectIntScatterMap<>();
    for (ShardRouting shard : state.getState().routingTable().allShards()) {
        String nodeId = "UNASSIGNED";
        if (shard.assignedToNode()) {
            nodeId = shard.currentNodeId();
        }
        allocs.addTo(nodeId, 1);
    }
    Table table = getTableWithHeader(request);
    for (NodeStats nodeStats : stats.getNodes()) {
        DiscoveryNode node = nodeStats.getNode();
        int shardCount = allocs.getOrDefault(node.getId(), 0);
        ByteSizeValue total = nodeStats.getFs().getTotal().getTotal();
        ByteSizeValue avail = nodeStats.getFs().getTotal().getAvailable();
        //if we don't know how much we use (non data nodes), it means 0
        long used = 0;
        short diskPercent = -1;
        if (total.getBytes() > 0) {
            used = total.getBytes() - avail.getBytes();
            if (used >= 0 && avail.getBytes() >= 0) {
                diskPercent = (short) (used * 100 / (used + avail.getBytes()));
            }
        }
        table.startRow();
        table.addCell(shardCount);
        table.addCell(nodeStats.getIndices().getStore().getSize());
        table.addCell(used < 0 ? null : new ByteSizeValue(used));
        table.addCell(avail.getBytes() < 0 ? null : avail);
        table.addCell(total.getBytes() < 0 ? null : total);
        table.addCell(diskPercent < 0 ? null : diskPercent);
        table.addCell(node.getHostName());
        table.addCell(node.getHostAddress());
        table.addCell(node.getName());
        table.endRow();
    }
    final String UNASSIGNED = "UNASSIGNED";
    if (allocs.containsKey(UNASSIGNED)) {
        table.startRow();
        table.addCell(allocs.get(UNASSIGNED));
        table.addCell(null);
        table.addCell(null);
        table.addCell(null);
        table.addCell(null);
        table.addCell(null);
        table.addCell(null);
        table.addCell(null);
        table.addCell(UNASSIGNED);
        table.endRow();
    }
    return table;
}
Also used : NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ObjectIntScatterMap(com.carrotsearch.hppc.ObjectIntScatterMap) Table(org.elasticsearch.common.Table) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting)

Example 45 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class RestCountAction method buildTable.

private Table buildTable(RestRequest request, SearchResponse response) {
    Table table = getTableWithHeader(request);
    table.startRow();
    table.addCell(response.getHits().getTotalHits());
    table.endRow();
    return table;
}
Also used : Table(org.elasticsearch.common.Table)

Aggregations

Table (org.elasticsearch.common.Table)54 Settings (org.elasticsearch.common.settings.Settings)9 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)8 RestController (org.elasticsearch.rest.RestController)8 NodeClient (org.elasticsearch.client.node.NodeClient)7 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)7 RestRequest (org.elasticsearch.rest.RestRequest)7 GET (org.elasticsearch.rest.RestRequest.Method.GET)6 List (java.util.List)5 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)5 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)4 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)4 Strings (org.elasticsearch.common.Strings)4 RestResponse (org.elasticsearch.rest.RestResponse)4 RestResponseListener (org.elasticsearch.rest.action.RestResponseListener)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ClusterStateRequest (org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)3 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)3 MetaData (org.elasticsearch.cluster.metadata.MetaData)3