Package org.elasticsearch.action.admin.cluster.node.stats

Examples of org.elasticsearch.action.admin.cluster.node.stats.NodeStats


            when(mem.freePercent()).thenReturn((short) 78);

            bind(OsService.class).toInstance(osService);

            NodeService nodeService = mock(NodeService.class);
            NodeStats nodeStats = mock(NodeStats.class);
            when(nodeService.stats()).thenReturn(nodeStats);
            when(nodeStats.getHostname()).thenReturn("localhost");

            DiscoveryNode node = mock(DiscoveryNode.class);
            when(nodeStats.getNode()).thenReturn(node);

            when(nodeStats.getOs()).thenReturn(osStats);
            when(osStats.uptime()).thenReturn(new TimeValue(3600000));
            OsStats.Cpu cpu = mock(OsStats.Cpu.class);
            when(osStats.cpu()).thenReturn(cpu);
            when(cpu.sys()).thenReturn((short) 2);
            when(cpu.user()).thenReturn((short) 4);
            when(cpu.idle()).thenReturn((short) 94);
            when(cpu.stolen()).thenReturn((short) 10);

            ProcessStats processStats = mock(ProcessStats.class);
            when(nodeStats.getProcess()).thenReturn(processStats);
            when(processStats.getOpenFileDescriptors()).thenReturn(42L);

            NodeInfo nodeInfo = mock(NodeInfo.class);
            when(nodeService.info()).thenReturn(nodeInfo);
View Full Code Here


        DiscoveryNodes nodes = state.getState().nodes();
        Table table = getTableWithHeader(req);

        for (DiscoveryNode node : nodes) {
            NodeInfo info = nodesInfo.getNodesMap().get(node.id());
            NodeStats stats = nodesStats.getNodesMap().get(node.id());
            table.startRow();

            table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().id());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            if (node.address() instanceof InetSocketTransportAddress) {
                table.addCell(((InetSocketTransportAddress) node.address()).address().getPort());
            } else {
                table.addCell("-");
            }

            final Map<String, ThreadPoolStats.Stats> poolThreadStats;
            final Map<String, ThreadPool.Info> poolThreadInfo;

            if (stats == null) {
                poolThreadStats = Collections.emptyMap();
                poolThreadInfo = Collections.emptyMap();
            } else {
                poolThreadStats = new HashMap<>(14);
                poolThreadInfo = new HashMap<>(14);

                ThreadPoolStats threadPoolStats = stats.getThreadPool();
                for (ThreadPoolStats.Stats threadPoolStat : threadPoolStats) {
                    poolThreadStats.put(threadPoolStat.getName(), threadPoolStat);
                }
                if (info != null) {
                    for (ThreadPool.Info threadPoolInfo : info.getThreadPool()) {
View Full Code Here

        String masterId = nodes.masterNodeId();
        Table table = getTableWithHeader(req);

        for (DiscoveryNode node : nodes) {
            NodeInfo info = nodesInfo.getNodesMap().get(node.id());
            NodeStats stats = nodesStats.getNodesMap().get(node.id());

            table.startRow();

            table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().id());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            if (node.address() instanceof InetSocketTransportAddress) {
                table.addCell(((InetSocketTransportAddress) node.address()).address().getPort());
            } else {
                table.addCell("-");
            }

            table.addCell(node.getVersion().number());
            table.addCell(info == null ? null : info.getBuild().hashShort());
            table.addCell(info == null ? null : info.getJvm().version());
            table.addCell(stats == null ? null : stats.getFs() == null ? null : stats.getFs().total().getAvailable());
            table.addCell(stats == null ? null : stats.getJvm().getMem().getHeapUsed());
            table.addCell(stats == null ? null : stats.getJvm().getMem().getHeapUsedPrecent());
            table.addCell(info == null ? null : info.getJvm().getMem().getHeapMax());
            table.addCell(stats == null ? null : stats.getOs().mem() == null ? null : stats.getOs().mem().used());
            table.addCell(stats == null ? null : stats.getOs().mem() == null ? null : stats.getOs().mem().usedPercent());
            table.addCell(info == null ? null : info.getOs().mem() == null ? null : info.getOs().mem().total()); // sigar fails to load in IntelliJ
            table.addCell(stats == null ? null : stats.getProcess().getOpenFileDescriptors());
            table.addCell(stats == null || info == null ? null :
                          calculatePercentage(stats.getProcess().getOpenFileDescriptors(), info.getProcess().getMaxFileDescriptors()));
            table.addCell(info == null ? null : info.getProcess().getMaxFileDescriptors());

            table.addCell(stats == null ? null : stats.getOs() == null ? null : stats.getOs().getLoadAverage().length < 1 ? null : String.format(Locale.ROOT, "%.2f", stats.getOs().getLoadAverage()[0]));
            table.addCell(stats == null ? null : stats.getJvm().uptime());
            table.addCell(node.clientNode() ? "c" : node.dataNode() ? "d" : "-");
            table.addCell(masterId == null ? "x" : masterId.equals(node.id()) ? "*" : node.masterNode() ? "m" : "-");
            table.addCell(node.name());

            table.addCell(stats == null ? null : stats.getIndices().getCompletion().getSize());

            table.addCell(stats == null ? null : stats.getIndices().getFieldData().getMemorySize());
            table.addCell(stats == null ? null : stats.getIndices().getFieldData().getEvictions());

            table.addCell(stats == null ? null : stats.getIndices().getFilterCache().getMemorySize());
            table.addCell(stats == null ? null : stats.getIndices().getFilterCache().getEvictions());

            table.addCell(stats == null ? null : stats.getIndices().getQueryCache().getMemorySize());
            table.addCell(stats == null ? null : stats.getIndices().getQueryCache().getEvictions());
            table.addCell(stats == null ? null : stats.getIndices().getQueryCache().getHitCount());
            table.addCell(stats == null ? null : stats.getIndices().getQueryCache().getMissCount());

            table.addCell(stats == null ? null : stats.getIndices().getFlush().getTotal());
            table.addCell(stats == null ? null : stats.getIndices().getFlush().getTotalTime());

            table.addCell(stats == null ? null : stats.getIndices().getGet().current());
            table.addCell(stats == null ? null : stats.getIndices().getGet().getTime());
            table.addCell(stats == null ? null : stats.getIndices().getGet().getCount());
            table.addCell(stats == null ? null : stats.getIndices().getGet().getExistsTime());
            table.addCell(stats == null ? null : stats.getIndices().getGet().getExistsCount());
            table.addCell(stats == null ? null : stats.getIndices().getGet().getMissingTime());
            table.addCell(stats == null ? null : stats.getIndices().getGet().getMissingCount());

            table.addCell(stats == null ? null : stats.getIndices().getIdCache().getMemorySize());

            table.addCell(stats == null ? null : stats.getIndices().getIndexing().getTotal().getDeleteCurrent());
            table.addCell(stats == null ? null : stats.getIndices().getIndexing().getTotal().getDeleteTime());
            table.addCell(stats == null ? null : stats.getIndices().getIndexing().getTotal().getDeleteCount());
            table.addCell(stats == null ? null : stats.getIndices().getIndexing().getTotal().getIndexCurrent());
            table.addCell(stats == null ? null : stats.getIndices().getIndexing().getTotal().getIndexTime());
            table.addCell(stats == null ? null : stats.getIndices().getIndexing().getTotal().getIndexCount());

            table.addCell(stats == null ? null : stats.getIndices().getMerge().getCurrent());
            table.addCell(stats == null ? null : stats.getIndices().getMerge().getCurrentNumDocs());
            table.addCell(stats == null ? null : stats.getIndices().getMerge().getCurrentSize());
            table.addCell(stats == null ? null : stats.getIndices().getMerge().getTotal());
            table.addCell(stats == null ? null : stats.getIndices().getMerge().getTotalNumDocs());
            table.addCell(stats == null ? null : stats.getIndices().getMerge().getTotalSize());
            table.addCell(stats == null ? null : stats.getIndices().getMerge().getTotalTime());

            table.addCell(stats == null ? null : stats.getIndices().getPercolate().getCurrent());
            table.addCell(stats == null ? null : stats.getIndices().getPercolate().getMemorySize());
            table.addCell(stats == null ? null : stats.getIndices().getPercolate().getNumQueries());
            table.addCell(stats == null ? null : stats.getIndices().getPercolate().getTime());
            table.addCell(stats == null ? null : stats.getIndices().getPercolate().getCount());

            table.addCell(stats == null ? null : stats.getIndices().getRefresh().getTotal());
            table.addCell(stats == null ? null : stats.getIndices().getRefresh().getTotalTime());

            table.addCell(stats == null ? null : stats.getIndices().getSearch().getTotal().getFetchCurrent());
            table.addCell(stats == null ? null : stats.getIndices().getSearch().getTotal().getFetchTime());
            table.addCell(stats == null ? null : stats.getIndices().getSearch().getTotal().getFetchCount());
            table.addCell(stats == null ? null : stats.getIndices().getSearch().getOpenContexts());
            table.addCell(stats == null ? null : stats.getIndices().getSearch().getTotal().getQueryCurrent());
            table.addCell(stats == null ? null : stats.getIndices().getSearch().getTotal().getQueryTime());
            table.addCell(stats == null ? null : stats.getIndices().getSearch().getTotal().getQueryCount());

            table.addCell(stats == null ? null : stats.getIndices().getSegments().getCount());
            table.addCell(stats == null ? null : stats.getIndices().getSegments().getMemory());
            table.addCell(stats == null ? null : stats.getIndices().getSegments().getIndexWriterMemory());
            table.addCell(stats == null ? null : stats.getIndices().getSegments().getIndexWriterMaxMemory());
            table.addCell(stats == null ? null : stats.getIndices().getSegments().getVersionMapMemory());
            table.addCell(stats == null ? null : stats.getIndices().getSegments().getBitsetMemory());

            table.addCell(stats == null ? null : stats.getIndices().getSuggest().getCurrent());
            table.addCell(stats == null ? null : stats.getIndices().getSuggest().getTime());
            table.addCell(stats == null ? null : stats.getIndices().getSuggest().getCount());

            table.endRow();
        }

        return table;
View Full Code Here

    }

    public NodeStats stats() {
        // for indices stats we want to include previous allocated shards stats as well (it will
        // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats)
        return new NodeStats(discovery.localNode(), System.currentTimeMillis(),
                indicesService.stats(true),
                monitorService.osService().stats(),
                monitorService.processService().stats(),
                monitorService.jvmService().stats(),
                threadPool.stats(),
View Full Code Here

    public NodeStats stats(CommonStatsFlags indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean network,
                           boolean fs, boolean transport, boolean http, boolean circuitBreaker) {
        // for indices stats we want to include previous allocated shards stats as well (it will
        // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats)
        return new NodeStats(discovery.localNode(), System.currentTimeMillis(),
                indices.anySet() ? indicesService.stats(true, indices) : null,
                os ? monitorService.osService().stats() : null,
                process ? monitorService.processService().stats() : null,
                jvm ? monitorService.jvmService().stats() : null,
                threadPool ? this.threadPool.stats() : null,
View Full Code Here

        FsStats.Info[] infos = new FsStats.Info[1];
        FsStats.Info info = new FsStats.Info("/path.data", null, null,
                usage.getTotalBytes(), usage.getFreeBytes(), usage.getFreeBytes(), -1, -1, -1, -1, -1, -1);
        infos[0] = info;
        FsStats fsStats = new FsStats(System.currentTimeMillis(), infos);
        return new NodeStats(new DiscoveryNode(nodeName, null, Version.V_2_0_0),
                System.currentTimeMillis(),
                null, null, null, null, null, null,
                fsStats,
                null, null, null);
    }
View Full Code Here

        table.endHeaders();

        for (Map.Entry<NodeStats, ObjectLongMap<String>> statsEntry : nodesFields.entrySet()) {
            table.startRow();
            // add the node info and field data total before each individual field
            NodeStats ns = statsEntry.getKey();
            table.addCell(ns.getNode().id());
            table.addCell(ns.getNode().getHostName());
            table.addCell(ns.getNode().getHostAddress());
            table.addCell(ns.getNode().getName());
            table.addCell(ns.getIndices().getFieldData().getMemorySize());
            ObjectLongMap<String> fields = statsEntry.getValue();
            for (String fieldName : fieldNames) {
                table.addCell(new ByteSizeValue(fields == null ? 0L : fields.getOrDefault(fieldName, 0L)));
            }
            table.endRow();
View Full Code Here

    }

    @Override
    protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeRequest) throws ElasticsearchException {
        NodeInfo nodeInfo = nodeService.info(false, true, false, true, false, false, true, false, true);
        NodeStats nodeStats = nodeService.stats(CommonStatsFlags.NONE, false, true, true, false, false, true, false, false, false);
        List<ShardStats> shardsStats = new ArrayList<>();
        for (IndexService indexService : indicesService.indices().values()) {
            for (IndexShard indexShard : indexService) {
                if (indexShard.routingEntry() != null && indexShard.routingEntry().active()) {
                    // only report on fully started shards
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.admin.cluster.node.stats.NodeStats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.