diff --git a/rest-api-spec/api/cluster.state.json b/rest-api-spec/api/cluster.state.json index 9eb2a1f62b8..0f4bf6f21ad 100644 --- a/rest-api-spec/api/cluster.state.json +++ b/rest-api-spec/api/cluster.state.json @@ -16,7 +16,7 @@ }, "metric" : { "type" : "list", - "options" : ["_all", "blocks", "metadata", "nodes", "routing_table", "master_node", "version"], + "options" : ["_all", "blocks", "metadata", "nodes", "routing_table", "routing_nodes", "master_node", "version"], "description" : "Limit the information returned to the specified metrics" } }, diff --git a/rest-api-spec/test/cluster.state/20_filtering.yaml b/rest-api-spec/test/cluster.state/20_filtering.yaml index ee8df1a5331..fa8523a7bb1 100644 --- a/rest-api-spec/test/cluster.state/20_filtering.yaml +++ b/rest-api-spec/test/cluster.state/20_filtering.yaml @@ -83,6 +83,18 @@ setup: - is_true: routing_table - is_true: routing_nodes +--- +"Filtering the cluster state by routing nodes only should work": + - do: + cluster.state: + metric: [ routing_nodes ] + + - is_false: blocks + - is_false: nodes + - is_false: metadata + - is_false: routing_table + - is_true: routing_nodes + --- "Filtering the cluster state by indices should work in routing table and metadata": - do: diff --git a/src/main/java/org/elasticsearch/cluster/ClusterState.java b/src/main/java/org/elasticsearch/cluster/ClusterState.java index c7c3b3da3c3..5452b36142b 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -23,7 +23,6 @@ import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.ImmutableSet; import org.elasticsearch.ElasticsearchIllegalArgumentException; -import org.elasticsearch.Version; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -33,7 +32,6 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.routing.*; - import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; @@ -261,6 +259,7 @@ public class ClusterState implements ToXContent { NODES("nodes"), METADATA("metadata"), ROUTING_TABLE("routing_table"), + ROUTING_NODES("routing_nodes"), CUSTOMS("customs"); private static Map valueToEnum; @@ -465,7 +464,8 @@ public class ClusterState implements ToXContent { } // routing nodes - if (metrics.contains(Metric.ROUTING_TABLE)) { + // gets printed out even if only routing_table was requested for bw comp reasons + if (metrics.contains(Metric.ROUTING_TABLE) || metrics.contains(Metric.ROUTING_NODES)) { builder.startObject("routing_nodes"); builder.startArray("unassigned"); for (ShardRouting shardRouting : readOnlyRoutingNodes().unassigned()) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java index 4826bb9cff0..bac21dd13e4 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java @@ -72,7 +72,8 @@ public class RestClusterStateAction extends BaseRestHandler { EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); // do not ask for what we do not need. clusterStateRequest.nodes(metrics.contains(ClusterState.Metric.NODES) || metrics.contains(ClusterState.Metric.MASTER_NODE)); - clusterStateRequest.routingTable(metrics.contains(ClusterState.Metric.ROUTING_TABLE)); + //there is no distinction in Java api between routing_table and routing_nodes, it's the same info set over the wire, one single flag to ask for it + clusterStateRequest.routingTable(metrics.contains(ClusterState.Metric.ROUTING_TABLE) || metrics.contains(ClusterState.Metric.ROUTING_NODES)); clusterStateRequest.metaData(metrics.contains(ClusterState.Metric.METADATA)); clusterStateRequest.blocks(metrics.contains(ClusterState.Metric.BLOCKS)); }