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

Examples of org.elasticsearch.action.admin.cluster.node.info.NodeInfo


        return new ClusterStatsNodeResponse();
    }

    @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
                    shardsStats.add(new ShardStats(indexShard, indexShard.routingEntry(), SHARD_STATS_FLAGS));
                }
            }
        }

        ClusterHealthStatus clusterStatus = null;
        if (clusterService.state().nodes().localNodeMaster()) {
            // populate cluster status
            clusterStatus = ClusterHealthStatus.GREEN;
            for (IndexRoutingTable indexRoutingTable : clusterService.state().routingTable()) {
                IndexMetaData indexMetaData = clusterService.state().metaData().index(indexRoutingTable.index());
                if (indexRoutingTable == null) {
                    continue;
                }

                ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
                switch (indexHealth.getStatus()) {
                    case RED:
                        clusterStatus = ClusterHealthStatus.RED;
                        break;
                    case YELLOW:
                        if (clusterStatus != ClusterHealthStatus.RED) {
                            clusterStatus = ClusterHealthStatus.YELLOW;
                        }
                        break;
                }
            }
        }

        return new ClusterStatsNodeResponse(nodeInfo.getNode(), clusterStatus, nodeInfo, nodeStats, shardsStats.toArray(new ShardStats[shardsStats.size()]));

    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.admin.cluster.node.info.NodeInfo

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.