waitForCounter++; if (request.waitForNoInitializingShards() && response.getInitializingShards() == 0) { waitForCounter++; "waitForActiveShards must not be DEFAULT on the request object, instead it should be NONE"; if (waitForActiveShards.equals(ActiveShardCount.ALL)) { if (response.getUnassignedShards() == 0 && response.getInitializingShards() == 0) {
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(CLUSTER_NAME, getClusterName()); builder.field(STATUS, getStatus().name().toLowerCase(Locale.ROOT)); builder.field(TIMED_OUT, isTimedOut()); builder.field(NUMBER_OF_NODES, getNumberOfNodes()); builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes()); builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards()); builder.field(ACTIVE_SHARDS, getActiveShards()); builder.field(RELOCATING_SHARDS, getRelocatingShards()); builder.field(INITIALIZING_SHARDS, getInitializingShards()); builder.field(UNASSIGNED_SHARDS, getUnassignedShards()); builder.field(DELAYED_UNASSIGNED_SHARDS, getDelayedUnassignedShards()); builder.field(NUMBER_OF_PENDING_TASKS, getNumberOfPendingTasks()); builder.field(NUMBER_OF_IN_FLIGHT_FETCH, getNumberOfInFlightFetch()); builder.humanReadableField(TASK_MAX_WAIT_TIME_IN_QUEUE_IN_MILLIS, TASK_MAX_WAIT_TIME_IN_QUEUE, getTaskMaxWaitingTime()); builder.percentageField(ACTIVE_SHARDS_PERCENT_AS_NUMBER, ACTIVE_SHARDS_PERCENT, getActiveShardsPercent()); String level = params.param("level", "cluster"); boolean outputIndices = "indices".equals(level) || "shards".equals(level); if (outputIndices) { builder.startObject(INDICES); for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) { indexHealth.toXContent(builder, params); } builder.endObject(); } builder.endObject(); return builder; }
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { ClusterHealthRequest request = Requests.clusterHealthRequest( ObjectUtils.isEmpty(this.indices) ? ALL_INDICES : this.indices); ClusterHealthResponse response = this.client.admin().cluster().health(request) .actionGet(this.responseTimeout); switch (response.getStatus()) { case GREEN: case YELLOW: builder.up(); break; case RED: default: builder.down(); break; } builder.withDetail("clusterName", response.getClusterName()); builder.withDetail("numberOfNodes", response.getNumberOfNodes()); builder.withDetail("numberOfDataNodes", response.getNumberOfDataNodes()); builder.withDetail("activePrimaryShards", response.getActivePrimaryShards()); builder.withDetail("activeShards", response.getActiveShards()); builder.withDetail("relocatingShards", response.getRelocatingShards()); builder.withDetail("initializingShards", response.getInitializingShards()); builder.withDetail("unassignedShards", response.getUnassignedShards()); }
private Table buildTable(final ClusterHealthResponse health, final RestRequest request) { Table t = getTableWithHeader(request); t.startRow(); t.addCell(health.getClusterName()); t.addCell(health.getStatus().name().toLowerCase(Locale.ROOT)); t.addCell(health.getNumberOfNodes()); t.addCell(health.getNumberOfDataNodes()); t.addCell(health.getActiveShards()); t.addCell(health.getActivePrimaryShards()); t.addCell(health.getRelocatingShards()); t.addCell(health.getInitializingShards()); t.addCell(health.getUnassignedShards()); t.addCell(health.getNumberOfPendingTasks()); t.addCell(health.getTaskMaxWaitingTime().millis() == 0 ? "-" : health.getTaskMaxWaitingTime()); t.addCell(String.format(Locale.ROOT, "%1.1f%%", health.getActiveShardsPercent())); t.endRow(); return t; } }
/** * Clusterの状態取得. * @return 状態Map */ public Map<String, Object> checkHealth() { ClusterHealthResponse clusterHealth; clusterHealth = esTransportClient.admin().cluster().health(new ClusterHealthRequest()).actionGet(); HashMap<String, Object> map = new HashMap<String, Object>(); map.put("cluster_name", clusterHealth.getClusterName()); map.put("status", clusterHealth.getStatus().name()); map.put("timed_out", clusterHealth.isTimedOut()); map.put("number_of_nodes", clusterHealth.getNumberOfNodes()); map.put("number_of_data_nodes", clusterHealth.getNumberOfDataNodes()); map.put("active_primary_shards", clusterHealth.getActivePrimaryShards()); map.put("active_shards", clusterHealth.getActiveShards()); map.put("relocating_shards", clusterHealth.getRelocatingShards()); map.put("initializing_shards", clusterHealth.getInitializingShards()); map.put("unassigned_shards", clusterHealth.getUnassignedShards()); return map; }
waitForCounter++; if (request.waitForNoInitializingShards() && response.getInitializingShards() == 0) { waitForCounter++; "waitForActiveShards must not be DEFAULT on the request object, instead it should be NONE"; if (waitForActiveShards.equals(ActiveShardCount.ALL)) { if (response.getUnassignedShards() == 0 && response.getInitializingShards() == 0) {
waitForCounter++; if (request.waitForNoInitializingShards() && response.getInitializingShards() == 0) { waitForCounter++; "waitForActiveShards must not be DEFAULT on the request object, instead it should be NONE"; if (waitForActiveShards.equals(ActiveShardCount.ALL)) { if (response.getUnassignedShards() == 0 && response.getInitializingShards() == 0) {
if (waitForActiveShards.equals(ActiveShardCount.ALL) && response.getUnassignedShards() == 0 && response.getInitializingShards() == 0) {
builder.field(ACTIVE_SHARDS, getActiveShards()); builder.field(RELOCATING_SHARDS, getRelocatingShards()); builder.field(INITIALIZING_SHARDS, getInitializingShards()); builder.field(UNASSIGNED_SHARDS, getUnassignedShards()); builder.field(DELAYED_UNASSIGNED_SHARDS, getDelayedUnassignedShards());
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(CLUSTER_NAME, getClusterName()); builder.field(STATUS, getStatus().name().toLowerCase(Locale.ROOT)); builder.field(TIMED_OUT, isTimedOut()); builder.field(NUMBER_OF_NODES, getNumberOfNodes()); builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes()); builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards()); builder.field(ACTIVE_SHARDS, getActiveShards()); builder.field(RELOCATING_SHARDS, getRelocatingShards()); builder.field(INITIALIZING_SHARDS, getInitializingShards()); builder.field(UNASSIGNED_SHARDS, getUnassignedShards()); builder.field(DELAYED_UNASSIGNED_SHARDS, getDelayedUnassignedShards()); builder.field(NUMBER_OF_PENDING_TASKS, getNumberOfPendingTasks()); builder.field(NUMBER_OF_IN_FLIGHT_FETCH, getNumberOfInFlightFetch()); builder.humanReadableField(TASK_MAX_WAIT_TIME_IN_QUEUE_IN_MILLIS, TASK_MAX_WAIT_TIME_IN_QUEUE, getTaskMaxWaitingTime()); builder.percentageField(ACTIVE_SHARDS_PERCENT_AS_NUMBER, ACTIVE_SHARDS_PERCENT, getActiveShardsPercent()); String level = params.param("level", "cluster"); boolean outputIndices = "indices".equals(level) || "shards".equals(level); if (outputIndices) { builder.startObject(INDICES); for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) { indexHealth.toXContent(builder, params); } builder.endObject(); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(CLUSTER_NAME, getClusterName()); builder.field(STATUS, getStatus().name().toLowerCase(Locale.ROOT)); builder.field(TIMED_OUT, isTimedOut()); builder.field(NUMBER_OF_NODES, getNumberOfNodes()); builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes()); builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards()); builder.field(ACTIVE_SHARDS, getActiveShards()); builder.field(RELOCATING_SHARDS, getRelocatingShards()); builder.field(INITIALIZING_SHARDS, getInitializingShards()); builder.field(UNASSIGNED_SHARDS, getUnassignedShards()); builder.field(DELAYED_UNASSIGNED_SHARDS, getDelayedUnassignedShards()); builder.field(NUMBER_OF_PENDING_TASKS, getNumberOfPendingTasks()); builder.field(NUMBER_OF_IN_FLIGHT_FETCH, getNumberOfInFlightFetch()); builder.humanReadableField(TASK_MAX_WAIT_TIME_IN_QUEUE_IN_MILLIS, TASK_MAX_WAIT_TIME_IN_QUEUE, getTaskMaxWaitingTime()); builder.percentageField(ACTIVE_SHARDS_PERCENT_AS_NUMBER, ACTIVE_SHARDS_PERCENT, getActiveShardsPercent()); String level = params.param("level", "cluster"); boolean outputIndices = "indices".equals(level) || "shards".equals(level); if (outputIndices) { builder.startObject(INDICES); for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) { indexHealth.toXContent(builder, params); } builder.endObject(); } builder.endObject(); return builder; }
builder.field(Fields.ACTIVE_SHARDS, getActiveShards()); builder.field(Fields.RELOCATING_SHARDS, getRelocatingShards()); builder.field(Fields.INITIALIZING_SHARDS, getInitializingShards()); builder.field(Fields.UNASSIGNED_SHARDS, getUnassignedShards()); builder.field(Fields.DELAYED_UNASSIGNED_SHARDS, getDelayedUnassignedShards());
builder.field(Fields.ACTIVE_SHARDS, response.getActiveShards()); builder.field(Fields.RELOCATING_SHARDS, response.getRelocatingShards()); builder.field(Fields.INITIALIZING_SHARDS, response.getInitializingShards()); builder.field(Fields.UNASSIGNED_SHARDS, response.getUnassignedShards());
private Table buildTable(final ClusterHealthResponse health, final RestRequest request) { long time = System.currentTimeMillis(); Table t = getTableWithHeader(request); t.startRow(); t.addCell(TimeUnit.SECONDS.convert(time, TimeUnit.MILLISECONDS)); t.addCell(dateFormat.print(time)); t.addCell(health.getClusterName()); t.addCell(health.getStatus().name().toLowerCase(Locale.ROOT)); t.addCell(health.getNumberOfNodes()); t.addCell(health.getNumberOfDataNodes()); t.addCell(health.getActiveShards()); t.addCell(health.getActivePrimaryShards()); t.addCell(health.getRelocatingShards()); t.addCell(health.getInitializingShards()); t.addCell(health.getUnassignedShards()); t.addCell(health.getNumberOfPendingTasks()); t.addCell(health.getTaskMaxWaitingTime().millis() == 0 ? "-" : health.getTaskMaxWaitingTime()); t.addCell(String.format(Locale.ROOT, "%1.1f%%", health.getActiveShardsPercent())); t.endRow(); return t; } }
collector.metric("es_initializing_shards", "ES-InitializingShards", res.getInitializingShards(), null, res.getInitializingShards() > 0 ? MetricState.YELLOW : MetricState.GRAY); collector.metric("es_relocating_shards", "ES-RelocatingShards",
private Table buildTable(final ClusterHealthResponse health, final RestRequest request) { Table t = getTableWithHeader(request); t.startRow(); t.addCell(health.getClusterName()); t.addCell(health.getStatus().name().toLowerCase(Locale.ROOT)); t.addCell(health.getNumberOfNodes()); t.addCell(health.getNumberOfDataNodes()); t.addCell(health.getActiveShards()); t.addCell(health.getActivePrimaryShards()); t.addCell(health.getRelocatingShards()); t.addCell(health.getInitializingShards()); t.addCell(health.getUnassignedShards()); t.addCell(health.getNumberOfPendingTasks()); t.addCell(health.getTaskMaxWaitingTime().millis() == 0 ? "-" : health.getTaskMaxWaitingTime()); t.addCell(String.format(Locale.ROOT, "%1.1f%%", health.getActiveShardsPercent())); t.endRow(); return t; } }
private Table buildTable(final ClusterHealthResponse health, final RestRequest request) { Table t = getTableWithHeader(request); t.startRow(); t.addCell(health.getClusterName()); t.addCell(health.getStatus().name().toLowerCase(Locale.ROOT)); t.addCell(health.getNumberOfNodes()); t.addCell(health.getNumberOfDataNodes()); t.addCell(health.getActiveShards()); t.addCell(health.getActivePrimaryShards()); t.addCell(health.getRelocatingShards()); t.addCell(health.getInitializingShards()); t.addCell(health.getUnassignedShards()); t.addCell(health.getNumberOfPendingTasks()); t.addCell(health.getTaskMaxWaitingTime().millis() == 0 ? "-" : health.getTaskMaxWaitingTime()); t.addCell(String.format(Locale.ROOT, "%1.1f%%", health.getActiveShardsPercent())); t.endRow(); return t; } }
private Table buildTable(final ClusterHealthResponse health, final RestRequest request) { Table t = getTableWithHeader(request); t.startRow(); t.addCell(health.getClusterName()); t.addCell(health.getStatus().name().toLowerCase(Locale.ROOT)); t.addCell(health.getNumberOfNodes()); t.addCell(health.getNumberOfDataNodes()); t.addCell(health.getActiveShards()); t.addCell(health.getActivePrimaryShards()); t.addCell(health.getRelocatingShards()); t.addCell(health.getInitializingShards()); t.addCell(health.getUnassignedShards()); t.addCell(health.getNumberOfPendingTasks()); t.addCell(health.getTaskMaxWaitingTime().millis() == 0 ? "-" : health.getTaskMaxWaitingTime()); t.addCell(String.format(Locale.ROOT, "%1.1f%%", health.getActiveShardsPercent())); t.endRow(); return t; } }