From 8e62bb6934762e0f88b54ad995f4d81906740408 Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 22 Jun 2010 16:19:10 +0300 Subject: [PATCH] Cluster State API: Allow to filter the state on nodes, routing_table, metadata, and indices, closes #234. --- .../action/admin/cluster/state/RestClusterStateAction.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java index a41886303fd..b4a4c505172 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.client.Client; +import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -37,6 +38,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.builder.XContentBuilder; import org.elasticsearch.rest.*; +import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; @@ -58,6 +60,11 @@ public class RestClusterStateAction extends BaseRestHandler { } @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + ClusterStateRequest clusterStateRequest = Requests.clusterState(); + clusterStateRequest.filterNodes(request.paramAsBoolean("filter_nodes", clusterStateRequest.filterNodes())); + clusterStateRequest.filterRoutingTable(request.paramAsBoolean("filter_routing_table", clusterStateRequest.filterRoutingTable())); + clusterStateRequest.filterMetaData(request.paramAsBoolean("filter_metadata", clusterStateRequest.filterMetaData())); + clusterStateRequest.filteredIndices(RestActions.splitIndices(request.param("filter_indices", null))); client.admin().cluster().state(new ClusterStateRequest(), new ActionListener() { @Override public void onResponse(ClusterStateResponse response) { try {