Search in sources :

Example 1 with PendingClusterTask

use of org.elasticsearch.cluster.service.PendingClusterTask in project elasticsearch by elastic.

the class PendingClusterTasksResponse method writeTo.

@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeVInt(pendingTasks.size());
    for (PendingClusterTask task : pendingTasks) {
        task.writeTo(out);
    }
}
Also used : PendingClusterTask(org.elasticsearch.cluster.service.PendingClusterTask)

Example 2 with PendingClusterTask

use of org.elasticsearch.cluster.service.PendingClusterTask 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 3 with PendingClusterTask

use of org.elasticsearch.cluster.service.PendingClusterTask in project crate by crate.

the class PendingClusterTasksResponse method toXContent.

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.startArray(Fields.TASKS);
    for (PendingClusterTask pendingClusterTask : this) {
        builder.startObject();
        builder.field(Fields.INSERT_ORDER, pendingClusterTask.getInsertOrder());
        builder.field(Fields.PRIORITY, pendingClusterTask.getPriority());
        builder.field(Fields.SOURCE, pendingClusterTask.getSource());
        builder.field(Fields.EXECUTING, pendingClusterTask.isExecuting());
        builder.field(Fields.TIME_IN_QUEUE_MILLIS, pendingClusterTask.getTimeInQueueInMillis());
        builder.field(Fields.TIME_IN_QUEUE, pendingClusterTask.getTimeInQueue());
        builder.endObject();
    }
    builder.endArray();
    builder.endObject();
    return builder;
}
Also used : PendingClusterTask(org.elasticsearch.cluster.service.PendingClusterTask)

Example 4 with PendingClusterTask

use of org.elasticsearch.cluster.service.PendingClusterTask in project elasticsearch by elastic.

the class PendingClusterTasksResponse method toXContent.

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.startArray(Fields.TASKS);
    for (PendingClusterTask pendingClusterTask : this) {
        builder.startObject();
        builder.field(Fields.INSERT_ORDER, pendingClusterTask.getInsertOrder());
        builder.field(Fields.PRIORITY, pendingClusterTask.getPriority());
        builder.field(Fields.SOURCE, pendingClusterTask.getSource());
        builder.field(Fields.EXECUTING, pendingClusterTask.isExecuting());
        builder.field(Fields.TIME_IN_QUEUE_MILLIS, pendingClusterTask.getTimeInQueueInMillis());
        builder.field(Fields.TIME_IN_QUEUE, pendingClusterTask.getTimeInQueue());
        builder.endObject();
    }
    builder.endArray();
    builder.endObject();
    return builder;
}
Also used : PendingClusterTask(org.elasticsearch.cluster.service.PendingClusterTask)

Example 5 with PendingClusterTask

use of org.elasticsearch.cluster.service.PendingClusterTask in project elasticsearch by elastic.

the class PendingClusterTasksResponse method toString.

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("tasks: (").append(pendingTasks.size()).append("):\n");
    for (PendingClusterTask pendingClusterTask : this) {
        sb.append(pendingClusterTask.getInsertOrder()).append("/").append(pendingClusterTask.getPriority()).append("/").append(pendingClusterTask.getSource()).append("/").append(pendingClusterTask.getTimeInQueue()).append("\n");
    }
    return sb.toString();
}
Also used : PendingClusterTask(org.elasticsearch.cluster.service.PendingClusterTask)

Aggregations

PendingClusterTask (org.elasticsearch.cluster.service.PendingClusterTask)8 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 ClusterStatsRequest (org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest)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 Table (org.elasticsearch.common.Table)1