Search in sources :

Example 26 with Table

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

the class RestMasterAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(final RestRequest request) {
    Table table = new Table();
    table.startHeaders().addCell("id", "desc:node id").addCell("host", "alias:h;desc:host name").addCell("ip", "desc:ip address ").addCell("node", "alias:n;desc:node name").endHeaders();
    return table;
}
Also used : Table(org.elasticsearch.common.Table)

Example 27 with Table

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

the class RestNodeAttrsAction method buildTable.

private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    boolean fullId = req.paramAsBoolean("full_id", false);
    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);
    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        for (Map.Entry<String, String> attrEntry : node.getAttributes().entrySet()) {
            table.startRow();
            table.addCell(node.getName());
            table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            table.addCell(node.getAddress().address().getPort());
            table.addCell(attrEntry.getKey());
            table.addCell(attrEntry.getValue());
            table.endRow();
        }
    }
    return table;
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Table(org.elasticsearch.common.Table) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) Map(java.util.Map) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes)

Example 28 with Table

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

the class RestNodesAction method buildTable.

private Table buildTable(boolean fullId, RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
    DiscoveryNodes nodes = state.getState().nodes();
    String masterId = nodes.getMasterNodeId();
    Table table = getTableWithHeader(req);
    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        NodeStats stats = nodesStats.getNodesMap().get(node.getId());
        JvmInfo jvmInfo = info == null ? null : info.getJvm();
        JvmStats jvmStats = stats == null ? null : stats.getJvm();
        FsInfo fsInfo = stats == null ? null : stats.getFs();
        OsStats osStats = stats == null ? null : stats.getOs();
        ProcessStats processStats = stats == null ? null : stats.getProcess();
        NodeIndicesStats indicesStats = stats == null ? null : stats.getIndices();
        table.startRow();
        table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
        table.addCell(info == null ? null : info.getProcess().getId());
        table.addCell(node.getHostAddress());
        table.addCell(node.getAddress().address().getPort());
        final HttpInfo httpInfo = info == null ? null : info.getHttp();
        if (httpInfo != null) {
            TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
            table.addCell(NetworkAddress.format(transportAddress.address()));
        } else {
            table.addCell("-");
        }
        table.addCell(node.getVersion().toString());
        table.addCell(info == null ? null : info.getBuild().shortHash());
        table.addCell(jvmInfo == null ? null : jvmInfo.version());
        table.addCell(fsInfo == null ? null : fsInfo.getTotal().getAvailable());
        table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsed());
        table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsedPercent());
        table.addCell(jvmInfo == null ? null : jvmInfo.getMem().getHeapMax());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsed());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsedPercent());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getTotal());
        table.addCell(processStats == null ? null : processStats.getOpenFileDescriptors());
        table.addCell(processStats == null ? null : calculatePercentage(processStats.getOpenFileDescriptors(), processStats.getMaxFileDescriptors()));
        table.addCell(processStats == null ? null : processStats.getMaxFileDescriptors());
        table.addCell(osStats == null ? null : Short.toString(osStats.getCpu().getPercent()));
        boolean hasLoadAverage = osStats != null && osStats.getCpu().getLoadAverage() != null;
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[0] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[0]));
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[1] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[1]));
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[2] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[2]));
        table.addCell(jvmStats == null ? null : jvmStats.getUptime());
        final String roles;
        if (node.getRoles().isEmpty()) {
            roles = "-";
        } else {
            roles = node.getRoles().stream().map(DiscoveryNode.Role::getAbbreviation).collect(Collectors.joining());
        }
        table.addCell(roles);
        table.addCell(masterId == null ? "x" : masterId.equals(node.getId()) ? "*" : "-");
        table.addCell(node.getName());
        CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion();
        table.addCell(completionStats == null ? null : completionStats.getSize());
        FieldDataStats fdStats = indicesStats == null ? null : stats.getIndices().getFieldData();
        table.addCell(fdStats == null ? null : fdStats.getMemorySize());
        table.addCell(fdStats == null ? null : fdStats.getEvictions());
        QueryCacheStats fcStats = indicesStats == null ? null : indicesStats.getQueryCache();
        table.addCell(fcStats == null ? null : fcStats.getMemorySize());
        table.addCell(fcStats == null ? null : fcStats.getEvictions());
        RequestCacheStats qcStats = indicesStats == null ? null : indicesStats.getRequestCache();
        table.addCell(qcStats == null ? null : qcStats.getMemorySize());
        table.addCell(qcStats == null ? null : qcStats.getEvictions());
        table.addCell(qcStats == null ? null : qcStats.getHitCount());
        table.addCell(qcStats == null ? null : qcStats.getMissCount());
        FlushStats flushStats = indicesStats == null ? null : indicesStats.getFlush();
        table.addCell(flushStats == null ? null : flushStats.getTotal());
        table.addCell(flushStats == null ? null : flushStats.getTotalTime());
        GetStats getStats = indicesStats == null ? null : indicesStats.getGet();
        table.addCell(getStats == null ? null : getStats.current());
        table.addCell(getStats == null ? null : getStats.getTime());
        table.addCell(getStats == null ? null : getStats.getCount());
        table.addCell(getStats == null ? null : getStats.getExistsTime());
        table.addCell(getStats == null ? null : getStats.getExistsCount());
        table.addCell(getStats == null ? null : getStats.getMissingTime());
        table.addCell(getStats == null ? null : getStats.getMissingCount());
        IndexingStats indexingStats = indicesStats == null ? null : indicesStats.getIndexing();
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCurrent());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteTime());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCount());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCurrent());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexTime());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCount());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexFailedCount());
        MergeStats mergeStats = indicesStats == null ? null : indicesStats.getMerge();
        table.addCell(mergeStats == null ? null : mergeStats.getCurrent());
        table.addCell(mergeStats == null ? null : mergeStats.getCurrentNumDocs());
        table.addCell(mergeStats == null ? null : mergeStats.getCurrentSize());
        table.addCell(mergeStats == null ? null : mergeStats.getTotal());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalNumDocs());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalSize());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalTime());
        RefreshStats refreshStats = indicesStats == null ? null : indicesStats.getRefresh();
        table.addCell(refreshStats == null ? null : refreshStats.getTotal());
        table.addCell(refreshStats == null ? null : refreshStats.getTotalTime());
        table.addCell(refreshStats == null ? null : refreshStats.getListeners());
        ScriptStats scriptStats = stats == null ? null : stats.getScriptStats();
        table.addCell(scriptStats == null ? null : scriptStats.getCompilations());
        table.addCell(scriptStats == null ? null : scriptStats.getCacheEvictions());
        SearchStats searchStats = indicesStats == null ? null : indicesStats.getSearch();
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCount());
        table.addCell(searchStats == null ? null : searchStats.getOpenContexts());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCount());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCount());
        SegmentsStats segmentsStats = indicesStats == null ? null : indicesStats.getSegments();
        table.addCell(segmentsStats == null ? null : segmentsStats.getCount());
        table.addCell(segmentsStats == null ? null : segmentsStats.getMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getIndexWriterMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getVersionMapMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getBitsetMemory());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCount());
        table.endRow();
    }
    return table;
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) RefreshStats(org.elasticsearch.index.refresh.RefreshStats) TransportAddress(org.elasticsearch.common.transport.TransportAddress) GetStats(org.elasticsearch.index.get.GetStats) SegmentsStats(org.elasticsearch.index.engine.SegmentsStats) HttpInfo(org.elasticsearch.http.HttpInfo) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) FsInfo(org.elasticsearch.monitor.fs.FsInfo) FlushStats(org.elasticsearch.index.flush.FlushStats) QueryCacheStats(org.elasticsearch.index.cache.query.QueryCacheStats) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) FieldDataStats(org.elasticsearch.index.fielddata.FieldDataStats) JvmStats(org.elasticsearch.monitor.jvm.JvmStats) ScriptStats(org.elasticsearch.script.ScriptStats) ProcessStats(org.elasticsearch.monitor.process.ProcessStats) Table(org.elasticsearch.common.Table) IndexingStats(org.elasticsearch.index.shard.IndexingStats) OsStats(org.elasticsearch.monitor.os.OsStats) SearchStats(org.elasticsearch.index.search.stats.SearchStats) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) MergeStats(org.elasticsearch.index.merge.MergeStats) NodeIndicesStats(org.elasticsearch.indices.NodeIndicesStats) RequestCacheStats(org.elasticsearch.index.cache.request.RequestCacheStats) CompletionStats(org.elasticsearch.search.suggest.completion.CompletionStats)

Example 29 with Table

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

the class RestPendingClusterTasksAction method buildTable.

private Table buildTable(RestRequest request, PendingClusterTasksResponse tasks) {
    Table t = getTableWithHeader(request);
    for (PendingClusterTask task : tasks) {
        t.startRow();
        t.addCell(task.getInsertOrder());
        t.addCell(task.getTimeInQueue());
        t.addCell(task.getPriority());
        t.addCell(task.getSource());
        t.endRow();
    }
    return t;
}
Also used : PendingClusterTask(org.elasticsearch.cluster.service.PendingClusterTask) Table(org.elasticsearch.common.Table)

Example 30 with Table

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

the class RestPendingClusterTasksAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(final RestRequest request) {
    Table t = new Table();
    t.startHeaders();
    t.addCell("insertOrder", "alias:o;text-align:right;desc:task insertion order");
    t.addCell("timeInQueue", "alias:t;text-align:right;desc:how long task has been in queue");
    t.addCell("priority", "alias:p;desc:task priority");
    t.addCell("source", "alias:s;desc:task source");
    t.endHeaders();
    return t;
}
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