|
@@ -27,9 +27,10 @@ import org.elasticsearch.action.admin.indices.stats.IndexStats;
|
|
|
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest;
|
|
|
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
|
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
|
-import org.elasticsearch.client.node.NodeClient;
|
|
|
import org.elasticsearch.client.Requests;
|
|
|
+import org.elasticsearch.client.node.NodeClient;
|
|
|
import org.elasticsearch.cluster.ClusterState;
|
|
|
+import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
|
|
import org.elasticsearch.cluster.health.ClusterIndexHealth;
|
|
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|
@@ -314,16 +315,32 @@ public class RestIndicesAction extends AbstractCatAction {
|
|
|
}
|
|
|
|
|
|
// package private for testing
|
|
|
- Table buildTable(RestRequest request, Index[] indices, ClusterHealthResponse health, IndicesStatsResponse stats, MetaData indexMetaDatas) {
|
|
|
+ Table buildTable(RestRequest request, Index[] indices, ClusterHealthResponse response, IndicesStatsResponse stats, MetaData indexMetaDatas) {
|
|
|
+ final String healthParam = request.param("health");
|
|
|
+ final ClusterHealthStatus status;
|
|
|
+ if (healthParam != null) {
|
|
|
+ status = ClusterHealthStatus.fromString(healthParam);
|
|
|
+ } else {
|
|
|
+ status = null;
|
|
|
+ }
|
|
|
+
|
|
|
Table table = getTableWithHeader(request);
|
|
|
|
|
|
for (final Index index : indices) {
|
|
|
final String indexName = index.getName();
|
|
|
- ClusterIndexHealth indexHealth = health.getIndices().get(indexName);
|
|
|
+ ClusterIndexHealth indexHealth = response.getIndices().get(indexName);
|
|
|
IndexStats indexStats = stats.getIndices().get(indexName);
|
|
|
IndexMetaData indexMetaData = indexMetaDatas.getIndices().get(indexName);
|
|
|
IndexMetaData.State state = indexMetaData.getState();
|
|
|
|
|
|
+ if (status != null) {
|
|
|
+ if (state == IndexMetaData.State.CLOSE ||
|
|
|
+ (indexHealth == null && !ClusterHealthStatus.RED.equals(status)) ||
|
|
|
+ !indexHealth.getStatus().equals(status)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
table.startRow();
|
|
|
table.addCell(state == IndexMetaData.State.OPEN ? (indexHealth == null ? "red*" : indexHealth.getStatus().toString().toLowerCase(Locale.ROOT)) : null);
|
|
|
table.addCell(state.toString().toLowerCase(Locale.ROOT));
|