org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest Java Examples

The following examples show how to use org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticsearchQueryStore.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
@Override
public NodesStatsResponse getNodeStats() throws ExecutionException, InterruptedException {
    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
    nodesStatsRequest.clear()
            .jvm(true)
            .os(true)
            .fs(true)
            .indices(true)
            .process(true)
            .breaker(true);
    return connection.getClient()
            .admin()
            .cluster()
            .nodesStats(nodesStatsRequest)
            .actionGet();
}
 
Example #2
Source File: RestFielddataAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected void doRequest(final RestRequest request, final RestChannel channel, final Client client) {

    final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest("data:true");
    nodesStatsRequest.clear();
    nodesStatsRequest.indices(true);
    String[] fields = request.paramAsStringArray("fields", null);
    nodesStatsRequest.indices().fieldDataFields(fields == null ? new String[] {"*"} : fields);

    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
        @Override
        public RestResponse buildResponse(NodesStatsResponse nodeStatses) throws Exception {
            return RestTable.buildResponse(buildTable(request, nodeStatses), channel);
        }
    });
}
 
Example #3
Source File: InternalClusterInfoService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the latest nodes stats, calling the listener when complete
 * @return a latch that can be used to wait for the nodes stats to complete if desired
 */
protected CountDownLatch updateNodeStats(final ActionListener<NodesStatsResponse> listener) {
    final CountDownLatch latch = new CountDownLatch(1);
    final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest("data:true");
    nodesStatsRequest.clear();
    nodesStatsRequest.fs(true);
    nodesStatsRequest.timeout(fetchTimeout);

    transportNodesStatsAction.execute(nodesStatsRequest, new LatchedActionListener<>(listener, latch));
    return latch;
}
 
Example #4
Source File: InternalClusterInfoService.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the latest nodes stats, calling the listener when complete
 * @return a latch that can be used to wait for the nodes stats to complete if desired
 */
protected CountDownLatch updateNodeStats(final ActionListener<NodesStatsResponse> listener) {
    final CountDownLatch latch = new CountDownLatch(1);
    ObjectContainer<DiscoveryNode> allDataNodes = this.clusterService.state().getNodes().getDataNodes().values();
    final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(allDataNodes.toArray(DiscoveryNode.class));
    nodesStatsRequest.timeout(fetchTimeout);
    client.admin().cluster().nodesStats(nodesStatsRequest, new LatchedActionListener<>(listener, latch));
    return latch;
}
 
Example #5
Source File: ElasticSearchService.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected NodesStatsResponse getNodesStats() {
    final NodesInfoResponse nodesInfoResponse = client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
    final String[] nodes = new String[nodesInfoResponse.getNodes().length];

    int i = 0;

    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        nodes[i++] = nodeInfo.getNode().getName();
    }

    return client.admin().cluster().nodesStats(new NodesStatsRequest(nodes)).actionGet();
}
 
Example #6
Source File: ElasticSearchService.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected NodesStatsResponse getNodesStats() {
    final NodesInfoResponse nodesInfoResponse = client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
    final String[] nodes = new String[nodesInfoResponse.getNodes().length];

    int i = 0;

    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        nodes[i++] = nodeInfo.getNode().getName();
    }

    return client.admin().cluster().nodesStats(new NodesStatsRequest(nodes)).actionGet();
}
 
Example #7
Source File: RestThreadPoolAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client 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()));

    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);
                        }
                    });
                }
            });
        }
    });
}
 
Example #8
Source File: RestNodesAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client 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()));

    client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(true).os(true).process(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true).script(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);
                        }
                    });
                }
            });
        }
    });
}
 
Example #9
Source File: RestNodeAttrsAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client 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()));

    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 RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().jvm(false).os(false).fs(false).indices(false).process(false);
                    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);
                        }
                    });
                }
            });
        }
    });
}
 
Example #10
Source File: RestNodesStatsAction.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    String[] nodesIds = Strings.splitStringByCommaToArray(request.param("nodeId"));
    Set<String> metrics = Strings.splitStringByCommaToSet(request.param("metric", "_all"));

    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(nodesIds);
    nodesStatsRequest.timeout(request.param("timeout"));

    if (metrics.size() == 1 && metrics.contains("_all")) {
        nodesStatsRequest.all();
        nodesStatsRequest.indices(CommonStatsFlags.ALL);
    } else {
        nodesStatsRequest.clear();
        nodesStatsRequest.os(metrics.contains("os"));
        nodesStatsRequest.jvm(metrics.contains("jvm"));
        nodesStatsRequest.threadPool(metrics.contains("thread_pool"));
        nodesStatsRequest.fs(metrics.contains("fs"));
        nodesStatsRequest.transport(metrics.contains("transport"));
        nodesStatsRequest.http(metrics.contains("http"));
        nodesStatsRequest.indices(metrics.contains("indices"));
        nodesStatsRequest.process(metrics.contains("process"));
        nodesStatsRequest.breaker(metrics.contains("breaker"));
        nodesStatsRequest.script(metrics.contains("script"));

        // check for index specific metrics
        if (metrics.contains("indices")) {
            Set<String> indexMetrics = Strings.splitStringByCommaToSet(request.param("indexMetric", "_all"));
            if (indexMetrics.size() == 1 && indexMetrics.contains("_all")) {
                nodesStatsRequest.indices(CommonStatsFlags.ALL);
            } else {
                CommonStatsFlags flags = new CommonStatsFlags();
                for (Flag flag : CommonStatsFlags.Flag.values()) {
                    flags.set(flag, indexMetrics.contains(flag.getRestName()));
                }
                nodesStatsRequest.indices(flags);
            }
        }
    }

    if (nodesStatsRequest.indices().isSet(Flag.FieldData) && (request.hasParam("fields") || request.hasParam("fielddata_fields"))) {
        nodesStatsRequest.indices().fieldDataFields(request.paramAsStringArray("fielddata_fields", request.paramAsStringArray("fields", null)));
    }
    if (nodesStatsRequest.indices().isSet(Flag.Completion) && (request.hasParam("fields") || request.hasParam("completion_fields"))) {
        nodesStatsRequest.indices().completionDataFields(request.paramAsStringArray("completion_fields", request.paramAsStringArray("fields", null)));
    }
    if (nodesStatsRequest.indices().isSet(Flag.Search) && (request.hasParam("groups"))) {
        nodesStatsRequest.indices().groups(request.paramAsStringArray("groups", null));
    }
    if (nodesStatsRequest.indices().isSet(Flag.Indexing) && (request.hasParam("types"))) {
        nodesStatsRequest.indices().types(request.paramAsStringArray("types", null));
    }

    client.admin().cluster().nodesStats(nodesStatsRequest, new RestToXContentListener<NodesStatsResponse>(channel));
}
 
Example #11
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void nodesStats(final NodesStatsRequest request, final ActionListener<NodesStatsResponse> listener) {
    execute(NodesStatsAction.INSTANCE, request, listener);
}
 
Example #12
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<NodesStatsResponse> nodesStats(final NodesStatsRequest request) {
    return execute(NodesStatsAction.INSTANCE, request);
}
 
Example #13
Source File: NodesStatsRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
public NodesStatsRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) {
    super(client, new NodesStatsRequest(), jsonToString, stringToJson);
}
 
Example #14
Source File: NodesStatsRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<NodesStatsResponse> doExecute(NodesStatsRequest request) {
    return client.admin().cluster().nodesStats(request);
}
 
Example #15
Source File: NodesStatsRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected XContentBuilder toXContent(NodesStatsRequest request, NodesStatsResponse response, XContentBuilder builder) throws IOException {
    return super.toXContent(request, response, builder.startObject()).endObject();
}
 
Example #16
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void nodesStats(final NodesStatsRequest request, final ActionListener<NodesStatsResponse> listener) {
    execute(NodesStatsAction.INSTANCE, request, listener);
}
 
Example #17
Source File: ClusterAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Nodes stats of the cluster.
 *
 * @param request The nodes stats request
 * @return The result future
 * @see org.elasticsearch.client.Requests#nodesStatsRequest(String...)
 */
ActionFuture<NodesStatsResponse> nodesStats(NodesStatsRequest request);
 
Example #18
Source File: Requests.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a nodes stats request against one or more nodes. Pass <tt>null</tt> or an empty array for all nodes.
 *
 * @param nodesIds The nodes ids to get the stats for
 * @return The nodes info request
 * @see org.elasticsearch.client.ClusterAdminClient#nodesStats(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest)
 */
public static NodesStatsRequest nodesStatsRequest(String... nodesIds) {
    return new NodesStatsRequest(nodesIds);
}
 
Example #19
Source File: ClusterAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Nodes stats of the cluster.
 *
 * @param request  The nodes info request
 * @param listener A listener to be notified with a result
 * @see org.elasticsearch.client.Requests#nodesStatsRequest(String...)
 */
void nodesStats(NodesStatsRequest request, ActionListener<NodesStatsResponse> listener);
 
Example #20
Source File: ClusterAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Nodes stats of the cluster.
 *
 * @param request  The nodes info request
 * @param listener A listener to be notified with a result
 * @see org.elasticsearch.client.Requests#nodesStatsRequest(String...)
 */
void nodesStats(NodesStatsRequest request, ActionListener<NodesStatsResponse> listener);