Search in sources :

Example 36 with Table

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

the class RestTemplatesAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(RestRequest request) {
    Table table = new Table();
    table.startHeaders();
    table.addCell("name", "alias:n;desc:template name");
    table.addCell("index_patterns", "alias:t;desc:template index patterns");
    table.addCell("order", "alias:o;desc:template application order number");
    table.addCell("version", "alias:v;desc:version");
    table.endHeaders();
    return table;
}
Also used : Table(org.elasticsearch.common.Table)

Example 37 with Table

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

the class RestThreadPoolAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(final RestRequest request) {
    final Table table = new Table();
    table.startHeaders();
    table.addCell("node_name", "default:true;alias:nn;desc:node name");
    table.addCell("node_id", "default:false;alias:id;desc:persistent node id");
    table.addCell("ephemeral_node_id", "default:false;alias:eid;desc:ephemeral node id");
    table.addCell("pid", "default:false;alias:p;desc:process id");
    table.addCell("host", "default:false;alias:h;desc:host name");
    table.addCell("ip", "default:false;alias:i;desc:ip address");
    table.addCell("port", "default:false;alias:po;desc:bound transport port");
    table.addCell("name", "default:true;alias:n;desc:thread pool name");
    table.addCell("type", "alias:t;default:false;desc:thread pool type");
    table.addCell("active", "alias:a;default:true;text-align:right;desc:number of active threads");
    table.addCell("size", "alias:s;default:false;text-align:right;desc:number of threads");
    table.addCell("queue", "alias:q;default:true;text-align:right;desc:number of tasks currently in queue");
    table.addCell("queue_size", "alias:qs;default:false;text-align:right;desc:maximum number of tasks permitted in queue");
    table.addCell("rejected", "alias:r;default:true;text-align:right;desc:number of rejected tasks");
    table.addCell("largest", "alias:l;default:false;text-align:right;desc:highest number of seen active threads");
    table.addCell("completed", "alias:c;default:false;text-align:right;desc:number of completed tasks");
    table.addCell("min", "alias:mi;default:false;text-align:right;desc:minimum number of threads");
    table.addCell("max", "alias:ma;default:false;text-align:right;desc:maximum number of threads");
    table.addCell("keep_alive", "alias:ka;default:false;text-align:right;desc:thread keep alive time");
    table.endHeaders();
    return table;
}
Also used : Table(org.elasticsearch.common.Table)

Example 38 with Table

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

the class RestThreadPoolAction method buildTable.

private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
    final String[] threadPools = req.paramAsStringArray("thread_pool_patterns", new String[] { "*" });
    final DiscoveryNodes nodes = state.getState().nodes();
    final Table table = getTableWithHeader(req);
    // collect all thread pool names that we see across the nodes
    final Set<String> candidates = new HashSet<>();
    for (final NodeStats nodeStats : nodesStats.getNodes()) {
        for (final ThreadPoolStats.Stats threadPoolStats : nodeStats.getThreadPool()) {
            candidates.add(threadPoolStats.getName());
        }
    }
    // collect all thread pool names that match the specified thread pool patterns
    final Set<String> included = new HashSet<>();
    for (final String candidate : candidates) {
        if (Regex.simpleMatch(threadPools, candidate)) {
            included.add(candidate);
        }
    }
    for (final DiscoveryNode node : nodes) {
        final NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        final NodeStats stats = nodesStats.getNodesMap().get(node.getId());
        final Map<String, ThreadPoolStats.Stats> poolThreadStats;
        final Map<String, ThreadPool.Info> poolThreadInfo;
        if (stats == null) {
            poolThreadStats = Collections.emptyMap();
            poolThreadInfo = Collections.emptyMap();
        } else {
            // we use a sorted map to ensure that thread pools are sorted by name
            poolThreadStats = new TreeMap<>();
            poolThreadInfo = new HashMap<>();
            ThreadPoolStats threadPoolStats = stats.getThreadPool();
            for (ThreadPoolStats.Stats threadPoolStat : threadPoolStats) {
                poolThreadStats.put(threadPoolStat.getName(), threadPoolStat);
            }
            if (info != null) {
                for (ThreadPool.Info threadPoolInfo : info.getThreadPool()) {
                    poolThreadInfo.put(threadPoolInfo.getName(), threadPoolInfo);
                }
            }
        }
        for (Map.Entry<String, ThreadPoolStats.Stats> entry : poolThreadStats.entrySet()) {
            if (!included.contains(entry.getKey()))
                continue;
            table.startRow();
            table.addCell(node.getName());
            table.addCell(node.getId());
            table.addCell(node.getEphemeralId());
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            table.addCell(node.getAddress().address().getPort());
            final ThreadPoolStats.Stats poolStats = entry.getValue();
            final ThreadPool.Info poolInfo = poolThreadInfo.get(entry.getKey());
            Long maxQueueSize = null;
            String keepAlive = null;
            Integer minThreads = null;
            Integer maxThreads = null;
            if (poolInfo != null) {
                if (poolInfo.getQueueSize() != null) {
                    maxQueueSize = poolInfo.getQueueSize().singles();
                }
                if (poolInfo.getKeepAlive() != null) {
                    keepAlive = poolInfo.getKeepAlive().toString();
                }
                if (poolInfo.getMin() >= 0) {
                    minThreads = poolInfo.getMin();
                }
                if (poolInfo.getMax() >= 0) {
                    maxThreads = poolInfo.getMax();
                }
            }
            table.addCell(entry.getKey());
            table.addCell(poolInfo == null ? null : poolInfo.getThreadPoolType().getType());
            table.addCell(poolStats == null ? null : poolStats.getActive());
            table.addCell(poolStats == null ? null : poolStats.getThreads());
            table.addCell(poolStats == null ? null : poolStats.getQueue());
            table.addCell(maxQueueSize == null ? -1 : maxQueueSize);
            table.addCell(poolStats == null ? null : poolStats.getRejected());
            table.addCell(poolStats == null ? null : poolStats.getLargest());
            table.addCell(poolStats == null ? null : poolStats.getCompleted());
            table.addCell(minThreads);
            table.addCell(maxThreads);
            table.addCell(keepAlive);
            table.endRow();
        }
    }
    return table;
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Table(org.elasticsearch.common.Table) ThreadPool(org.elasticsearch.threadpool.ThreadPool) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) ThreadPoolStats(org.elasticsearch.threadpool.ThreadPoolStats) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) ThreadPoolStats(org.elasticsearch.threadpool.ThreadPoolStats) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) HashSet(java.util.HashSet)

Example 39 with Table

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

the class RestPluginsAction method buildTable.

private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);
    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) {
            table.startRow();
            table.addCell(node.getId());
            table.addCell(node.getName());
            table.addCell(pluginInfo.getName());
            table.addCell(pluginInfo.getVersion());
            table.addCell(pluginInfo.getDescription());
            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) PluginInfo(org.elasticsearch.plugins.PluginInfo) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes)

Example 40 with Table

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

the class RestPluginsAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(final RestRequest request) {
    Table table = new Table();
    table.startHeaders();
    table.addCell("id", "default:false;desc:unique node id");
    table.addCell("name", "alias:n;desc:node name");
    table.addCell("component", "alias:c;desc:component");
    table.addCell("version", "alias:v;desc:component version");
    table.addCell("description", "alias:d;default:false;desc:plugin details");
    table.endHeaders();
    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