Search in sources :

Example 1 with ClusterStatsRequest

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest in project elasticsearch by elastic.

the class RestClusterStatsAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    ClusterStatsRequest clusterStatsRequest = new ClusterStatsRequest().nodesIds(request.paramAsStringArray("nodeId", null));
    clusterStatsRequest.timeout(request.param("timeout"));
    return channel -> client.admin().cluster().clusterStats(clusterStatsRequest, new NodesResponseRestListener<>(channel));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) NodesResponseRestListener(org.elasticsearch.rest.action.RestActions.NodesResponseRestListener) Settings(org.elasticsearch.common.settings.Settings) ClusterStatsRequest(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) ClusterStatsRequest(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest)

Example 2 with ClusterStatsRequest

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest in project graylog2-server by Graylog2.

the class ElasticsearchProbe method elasticsearchStats.

public ElasticsearchStats elasticsearchStats() {
    final ClusterAdminClient adminClient = client.admin().cluster();
    final ClusterStatsResponse clusterStatsResponse = adminClient.clusterStats(new ClusterStatsRequest()).actionGet();
    final String clusterName = clusterStatsResponse.getClusterNameAsString();
    final ClusterStatsNodes clusterNodesStats = clusterStatsResponse.getNodesStats();
    final NodesStats nodesStats = NodesStats.create(clusterNodesStats.getCounts().getTotal(), clusterNodesStats.getCounts().getMasterOnly(), clusterNodesStats.getCounts().getDataOnly(), clusterNodesStats.getCounts().getMasterData(), clusterNodesStats.getCounts().getClient());
    final IndicesStats indicesStats = IndicesStats.create(clusterStatsResponse.getIndicesStats().getIndexCount(), clusterStatsResponse.getIndicesStats().getStore().sizeInBytes(), clusterStatsResponse.getIndicesStats().getFieldData().getMemorySizeInBytes());
    final PendingClusterTasksResponse pendingClusterTasksResponse = adminClient.pendingClusterTasks(new PendingClusterTasksRequest()).actionGet();
    final int pendingTasksSize = pendingClusterTasksResponse.pendingTasks().size();
    final List<Long> pendingTasksTimeInQueue = Lists.newArrayListWithCapacity(pendingTasksSize);
    for (PendingClusterTask pendingClusterTask : pendingClusterTasksResponse) {
        pendingTasksTimeInQueue.add(pendingClusterTask.getTimeInQueueInMillis());
    }
    final ClusterHealthResponse clusterHealthResponse = adminClient.health(new ClusterHealthRequest(indexSetRegistry.getIndexWildcards())).actionGet();
    final ClusterHealth clusterHealth = ClusterHealth.create(clusterHealthResponse.getNumberOfNodes(), clusterHealthResponse.getNumberOfDataNodes(), clusterHealthResponse.getActiveShards(), clusterHealthResponse.getRelocatingShards(), clusterHealthResponse.getActivePrimaryShards(), clusterHealthResponse.getInitializingShards(), clusterHealthResponse.getUnassignedShards(), clusterHealthResponse.isTimedOut(), pendingTasksSize, pendingTasksTimeInQueue);
    return ElasticsearchStats.create(clusterName, clusterHealthResponse.getStatus(), clusterHealth, nodesStats, indicesStats);
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) ClusterAdminClient(org.elasticsearch.client.ClusterAdminClient) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) ClusterStatsNodes(org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes) PendingClusterTask(org.elasticsearch.cluster.service.PendingClusterTask) PendingClusterTasksResponse(org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse) ClusterStatsRequest(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest) PendingClusterTasksRequest(org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest) ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse)

Aggregations

ClusterStatsRequest (org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest)2 IOException (java.io.IOException)1 ClusterHealthRequest (org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)1 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)1 ClusterStatsNodes (org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes)1 ClusterStatsResponse (org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse)1 PendingClusterTasksRequest (org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest)1 PendingClusterTasksResponse (org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse)1 ClusterAdminClient (org.elasticsearch.client.ClusterAdminClient)1 NodeClient (org.elasticsearch.client.node.NodeClient)1 PendingClusterTask (org.elasticsearch.cluster.service.PendingClusterTask)1 Settings (org.elasticsearch.common.settings.Settings)1 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)1 RestController (org.elasticsearch.rest.RestController)1 RestRequest (org.elasticsearch.rest.RestRequest)1 NodesResponseRestListener (org.elasticsearch.rest.action.RestActions.NodesResponseRestListener)1