Search in sources :

Example 1 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project elasticsearch by elastic.

the class RestNodeAttrsAction method doCatRequest.

@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {

        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(false).os(false).process(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestResponseListener<NodesInfoResponse>(channel) {

                @Override
                public RestResponse buildResponse(NodesInfoResponse nodesInfoResponse) throws Exception {
                    return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse), channel);
                }
            });
        }
    });
}
Also used : DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) GET(org.elasticsearch.rest.RestRequest.Method.GET) RestResponse(org.elasticsearch.rest.RestResponse) Table(org.elasticsearch.common.Table) RestController(org.elasticsearch.rest.RestController) Strings(org.elasticsearch.common.Strings) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) Settings(org.elasticsearch.common.settings.Settings) Map(java.util.Map) RestRequest(org.elasticsearch.rest.RestRequest) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) NodeClient(org.elasticsearch.client.node.NodeClient) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) RestActionListener(org.elasticsearch.rest.action.RestActionListener) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)

Example 2 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project elasticsearch by elastic.

the class RestThreadPoolAction method doCatRequest.

@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {

        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().process(true).threadPool(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {

                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().threadPool(true);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {

                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
Also used : GET(org.elasticsearch.rest.RestRequest.Method.GET) Table(org.elasticsearch.common.Table) HashMap(java.util.HashMap) HashSet(java.util.HashSet) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Settings(org.elasticsearch.common.settings.Settings) Map(java.util.Map) NodesStatsResponse(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) Regex(org.elasticsearch.common.regex.Regex) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ThreadPoolStats(org.elasticsearch.threadpool.ThreadPoolStats) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) RestResponse(org.elasticsearch.rest.RestResponse) Set(java.util.Set) RestController(org.elasticsearch.rest.RestController) NodesStatsRequest(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) TreeMap(java.util.TreeMap) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) Collections(java.util.Collections) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) RestActionListener(org.elasticsearch.rest.action.RestActionListener) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) RestResponse(org.elasticsearch.rest.RestResponse) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) RestActionListener(org.elasticsearch.rest.action.RestActionListener) NodesStatsRequest(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest) NodesStatsResponse(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)

Example 3 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project elasticsearch by elastic.

the class AbstractAzureComputeServiceTestCase method checkNumberOfNodes.

protected void checkNumberOfNodes(int expected) {
    NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().execute().actionGet();
    assertNotNull(nodeInfos);
    assertNotNull(nodeInfos.getNodes());
    assertEquals(expected, nodeInfos.getNodes().size());
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)

Example 4 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project elasticsearch by elastic.

the class SimpleNodesInfoIT method testAllocatedProcessors.

public void testAllocatedProcessors() throws Exception {
    List<String> nodesIds = internalCluster().startNodes(Settings.builder().put(EsExecutors.PROCESSORS_SETTING.getKey(), 3).build(), Settings.builder().put(EsExecutors.PROCESSORS_SETTING.getKey(), 6).build());
    final String node_1 = nodesIds.get(0);
    final String node_2 = nodesIds.get(1);
    ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
    logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());
    String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().getLocalNodeId();
    String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().getLocalNodeId();
    logger.info("--> started nodes: {} and {}", server1NodeId, server2NodeId);
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
    assertThat(response.getNodesMap().get(server1NodeId).getOs().getAvailableProcessors(), equalTo(Runtime.getRuntime().availableProcessors()));
    assertThat(response.getNodesMap().get(server2NodeId).getOs().getAvailableProcessors(), equalTo(Runtime.getRuntime().availableProcessors()));
    assertThat(response.getNodesMap().get(server1NodeId).getOs().getAllocatedProcessors(), equalTo(3));
    assertThat(response.getNodesMap().get(server2NodeId).getOs().getAllocatedProcessors(), equalTo(6));
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterService(org.elasticsearch.cluster.service.ClusterService) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)

Example 5 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project elasticsearch by elastic.

the class SimpleNodesInfoIT method testNodesInfos.

public void testNodesInfos() throws Exception {
    List<String> nodesIds = internalCluster().startNodes(2);
    final String node_1 = nodesIds.get(0);
    final String node_2 = nodesIds.get(1);
    ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
    logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());
    String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().getLocalNodeId();
    String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().getLocalNodeId();
    logger.info("--> started nodes: {} and {}", server1NodeId, server2NodeId);
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
    response = client().admin().cluster().nodesInfo(nodesInfoRequest()).actionGet();
    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server1NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server1NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server2NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server2NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterService(org.elasticsearch.cluster.service.ClusterService) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)

Aggregations

NodesInfoResponse (org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)23 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)15 NodesInfoRequest (org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)7 Settings (org.elasticsearch.common.settings.Settings)6 TransportAddress (org.elasticsearch.common.transport.TransportAddress)5 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)4 ClusterStateRequest (org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)4 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)4 NodeClient (org.elasticsearch.client.node.NodeClient)4 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)4 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)4 Table (org.elasticsearch.common.Table)4 RestController (org.elasticsearch.rest.RestController)4 RestRequest (org.elasticsearch.rest.RestRequest)4 GET (org.elasticsearch.rest.RestRequest.Method.GET)4 RestResponse (org.elasticsearch.rest.RestResponse)4 RestActionListener (org.elasticsearch.rest.action.RestActionListener)4 RestResponseListener (org.elasticsearch.rest.action.RestResponseListener)4 Map (java.util.Map)3 HashMap (java.util.HashMap)2