Skip to content

Commit

Permalink
add version and master_node flags to cluster state
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Feb 10, 2014
1 parent 152edd1 commit e5f43a1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion docs/reference/cluster/state.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ $ curl -XGET 'http://localhost:9200/_cluster/state/{metrics}/{indices}'

`metrics` can be a comma-separated list of

`version`::
Shows the cluster state version.

`master_node`::
Shows the elected `master_node` part of the response

`nodes`::
Shows the `nodes` part of the response

`routing_table`::
`routing_table`::
Shows the `routing_table` part of the response. If you supply a comma separated list of indices, the returned output will only contain the indices listed.

`metadata`::
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/elasticsearch/cluster/ClusterState.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
Set<String> metrics = Strings.splitStringByCommaToSet(params.param("metric", "_all"));
boolean isAllMetricsOnly = metrics.size() == 1 && metrics.contains("_all");

if (isAllMetricsOnly || metrics.contains("nodes")) {
if (isAllMetricsOnly || metrics.contains("version")) {
builder.field("version", version);
}

if (isAllMetricsOnly || metrics.contains("master_node")) {
builder.field("master_node", nodes().masterNodeId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void handleRequest(final RestRequest request, final RestChannel channel)
Set<String> metrics = Strings.splitStringByCommaToSet(request.param("metric", "_all"));
boolean isAllMetricsOnly = metrics.size() == 1 && metrics.contains("_all");
if (!isAllMetricsOnly) {
clusterStateRequest.nodes(metrics.contains("nodes"));
clusterStateRequest.nodes(metrics.contains("nodes") || metrics.contains("master_node"));
clusterStateRequest.routingTable(metrics.contains("routing_table"));
clusterStateRequest.metaData(metrics.contains("metadata"));
clusterStateRequest.blocks(metrics.contains("blocks"));
Expand Down

0 comments on commit e5f43a1

Please sign in to comment.