diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java index 92f3a488fc5..35f553e9e93 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.cluster.state; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.util.io.stream.StreamInput; import org.elasticsearch.util.io.stream.StreamOutput; @@ -31,12 +32,15 @@ import java.io.IOException; */ public class ClusterStateResponse implements ActionResponse { + private ClusterName clusterName; + private ClusterState clusterState; ClusterStateResponse() { } - ClusterStateResponse(ClusterState clusterState) { + ClusterStateResponse(ClusterName clusterName, ClusterState clusterState) { + this.clusterName = clusterName; this.clusterState = clusterState; } @@ -48,11 +52,21 @@ public class ClusterStateResponse implements ActionResponse { return state(); } + public ClusterName clusterName() { + return this.clusterName; + } + + public ClusterName getClusterName() { + return clusterName(); + } + @Override public void readFrom(StreamInput in) throws IOException { + clusterName = ClusterName.readClusterName(in); clusterState = ClusterState.Builder.readFrom(in, null, null); } @Override public void writeTo(StreamOutput out) throws IOException { + clusterName.writeTo(out); ClusterState.Builder.writeTo(clusterState, out); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java index 8e034c146c8..5a60551e0c7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java @@ -22,6 +22,7 @@ package org.elasticsearch.action.admin.cluster.state; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction; +import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -33,8 +34,12 @@ import org.elasticsearch.util.settings.Settings; */ public class TransportClusterStateAction extends TransportMasterNodeOperationAction { - @Inject public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool) { + private final ClusterName clusterName; + + @Inject public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, + ClusterName clusterName) { super(settings, transportService, clusterService, threadPool); + this.clusterName = clusterName; } @Override protected String transportAction() { @@ -50,6 +55,6 @@ public class TransportClusterStateAction extends TransportMasterNodeOperationAct } @Override protected ClusterStateResponse masterOperation(ClusterStateRequest request) throws ElasticSearchException { - return new ClusterStateResponse(clusterService.state()); + return new ClusterStateResponse(clusterName, clusterService.state()); } } \ No newline at end of file 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 f574aa67f03..92eabec8287 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 @@ -63,6 +63,8 @@ public class RestClusterStateAction extends BaseRestHandler { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); + builder.field("cluster_name", response.clusterName().value()); + // nodes builder.startObject("nodes"); builder.field("_master", state.nodes().masterNodeId());