Search in sources :

Example 1 with ClusterStatsNodes

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes 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)

Example 2 with ClusterStatsNodes

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes in project yacy_grid_mcp by yacy.

the class ElasticsearchClient method getClusterStatsNodes.

public ClusterStatsNodes getClusterStatsNodes() {
    ClusterStatsRequest clusterStatsRequest = new ClusterStatsRequestBuilder(elasticsearchClient.admin().cluster(), ClusterStatsAction.INSTANCE).request();
    ClusterStatsResponse clusterStatsResponse = elasticsearchClient.admin().cluster().clusterStats(clusterStatsRequest).actionGet();
    ClusterStatsNodes clusterStatsNodes = clusterStatsResponse.getNodesStats();
    return clusterStatsNodes;
}
Also used : ClusterStatsRequestBuilder(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder) ClusterStatsRequest(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest) ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse) ClusterStatsNodes(org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes)

Example 3 with ClusterStatsNodes

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes in project yacy_grid_mcp by yacy.

the class ElasticsearchClient method getStats.

/**
 * Retrieve a statistic object from the connected elasticsearch cluster
 *
 * @return cluster stats from connected cluster
 */
public ClusterStatsNodes getStats() {
    final ClusterStatsRequest clusterStatsRequest = new ClusterStatsRequestBuilder(elasticsearchClient.admin().cluster(), ClusterStatsAction.INSTANCE).request();
    final ClusterStatsResponse clusterStatsResponse = elasticsearchClient.admin().cluster().clusterStats(clusterStatsRequest).actionGet();
    final ClusterStatsNodes clusterStatsNodes = clusterStatsResponse.getNodesStats();
    return clusterStatsNodes;
}
Also used : ClusterStatsRequestBuilder(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder) ClusterStatsRequest(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest) ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse) ClusterStatsNodes(org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes)

Aggregations

ClusterStatsNodes (org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes)3 ClusterStatsRequest (org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest)3 ClusterStatsResponse (org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse)3 ClusterStatsRequestBuilder (org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder)2 ClusterHealthRequest (org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)1 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)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 PendingClusterTask (org.elasticsearch.cluster.service.PendingClusterTask)1