|
@@ -18,6 +18,7 @@ package org.codelibs.fess.entity;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
import org.apache.commons.text.StringEscapeUtils;
|
|
import org.apache.commons.text.StringEscapeUtils;
|
|
import org.codelibs.core.lang.StringUtil;
|
|
import org.codelibs.core.lang.StringUtil;
|
|
@@ -28,6 +29,22 @@ import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
|
import org.elasticsearch.common.xcontent.XContentType;
|
|
import org.elasticsearch.common.xcontent.XContentType;
|
|
|
|
|
|
public class PingResponse {
|
|
public class PingResponse {
|
|
|
|
+ private static final String CLUSTER_NAME = "cluster_name";
|
|
|
|
+ private static final String STATUS = "status";
|
|
|
|
+ private static final String TIMED_OUT = "timed_out";
|
|
|
|
+ private static final String NUMBER_OF_NODES = "number_of_nodes";
|
|
|
|
+ private static final String NUMBER_OF_DATA_NODES = "number_of_data_nodes";
|
|
|
|
+ private static final String NUMBER_OF_PENDING_TASKS = "number_of_pending_tasks";
|
|
|
|
+ private static final String NUMBER_OF_IN_FLIGHT_FETCH = "number_of_in_flight_fetch";
|
|
|
|
+ private static final String DELAYED_UNASSIGNED_SHARDS = "delayed_unassigned_shards";
|
|
|
|
+ private static final String TASK_MAX_WAIT_TIME_IN_QUEUE_IN_MILLIS = "task_max_waiting_in_queue_millis";
|
|
|
|
+ private static final String ACTIVE_SHARDS_PERCENT_AS_NUMBER = "active_shards_percent_as_number";
|
|
|
|
+ private static final String ACTIVE_PRIMARY_SHARDS = "active_primary_shards";
|
|
|
|
+ private static final String ACTIVE_SHARDS = "active_shards";
|
|
|
|
+ private static final String RELOCATING_SHARDS = "relocating_shards";
|
|
|
|
+ private static final String INITIALIZING_SHARDS = "initializing_shards";
|
|
|
|
+ private static final String UNASSIGNED_SHARDS = "unassigned_shards";
|
|
|
|
+
|
|
private final int status;
|
|
private final int status;
|
|
|
|
|
|
private final String clusterName;
|
|
private final String clusterName;
|
|
@@ -40,7 +57,26 @@ public class PingResponse {
|
|
status = response.getStatus() == ClusterHealthStatus.RED ? 1 : 0;
|
|
status = response.getStatus() == ClusterHealthStatus.RED ? 1 : 0;
|
|
clusterName = response.getClusterName();
|
|
clusterName = response.getClusterName();
|
|
clusterStatus = response.getStatus().toString();
|
|
clusterStatus = response.getStatus().toString();
|
|
- try (OutputStream out = EsUtil.getXContentOutputStream(response, XContentType.JSON)) {
|
|
|
|
|
|
+ try (OutputStream out = EsUtil.getXContentBuilderOutputStream((builder, params) -> {
|
|
|
|
+ builder.startObject();
|
|
|
|
+ builder.field(CLUSTER_NAME, response.getClusterName());
|
|
|
|
+ builder.field(STATUS, response.getStatus().name().toLowerCase(Locale.ROOT));
|
|
|
|
+ builder.field(TIMED_OUT, response.isTimedOut());
|
|
|
|
+ builder.field(NUMBER_OF_NODES, response.getNumberOfNodes());
|
|
|
|
+ builder.field(NUMBER_OF_DATA_NODES, response.getNumberOfDataNodes());
|
|
|
|
+ builder.field(ACTIVE_PRIMARY_SHARDS, response.getActivePrimaryShards());
|
|
|
|
+ builder.field(ACTIVE_SHARDS, response.getActiveShards());
|
|
|
|
+ builder.field(RELOCATING_SHARDS, response.getRelocatingShards());
|
|
|
|
+ builder.field(INITIALIZING_SHARDS, response.getInitializingShards());
|
|
|
|
+ builder.field(UNASSIGNED_SHARDS, response.getUnassignedShards());
|
|
|
|
+ builder.field(DELAYED_UNASSIGNED_SHARDS, response.getDelayedUnassignedShards());
|
|
|
|
+ builder.field(NUMBER_OF_PENDING_TASKS, response.getNumberOfPendingTasks());
|
|
|
|
+ builder.field(NUMBER_OF_IN_FLIGHT_FETCH, response.getNumberOfInFlightFetch());
|
|
|
|
+ builder.field(TASK_MAX_WAIT_TIME_IN_QUEUE_IN_MILLIS, response.getTaskMaxWaitingTime().getMillis());
|
|
|
|
+ builder.field(ACTIVE_SHARDS_PERCENT_AS_NUMBER, response.getActiveShardsPercent());
|
|
|
|
+ builder.endObject();
|
|
|
|
+ return builder;
|
|
|
|
+ }, XContentType.JSON)) {
|
|
message = ((ByteArrayOutputStream) out).toString(Constants.UTF_8);
|
|
message = ((ByteArrayOutputStream) out).toString(Constants.UTF_8);
|
|
if (StringUtil.isBlank(message)) {
|
|
if (StringUtil.isBlank(message)) {
|
|
message = "{}";
|
|
message = "{}";
|