REST API does not expose node-master status, closes #203.
This commit is contained in:
parent
6c8f49c37d
commit
b2f90a2133
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.action.admin.cluster.state;
|
package org.elasticsearch.action.admin.cluster.state;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.util.io.stream.StreamInput;
|
import org.elasticsearch.util.io.stream.StreamInput;
|
||||||
import org.elasticsearch.util.io.stream.StreamOutput;
|
import org.elasticsearch.util.io.stream.StreamOutput;
|
||||||
|
@ -31,12 +32,15 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class ClusterStateResponse implements ActionResponse {
|
public class ClusterStateResponse implements ActionResponse {
|
||||||
|
|
||||||
|
private ClusterName clusterName;
|
||||||
|
|
||||||
private ClusterState clusterState;
|
private ClusterState clusterState;
|
||||||
|
|
||||||
ClusterStateResponse() {
|
ClusterStateResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterStateResponse(ClusterState clusterState) {
|
ClusterStateResponse(ClusterName clusterName, ClusterState clusterState) {
|
||||||
|
this.clusterName = clusterName;
|
||||||
this.clusterState = clusterState;
|
this.clusterState = clusterState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +52,21 @@ public class ClusterStateResponse implements ActionResponse {
|
||||||
return state();
|
return state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClusterName clusterName() {
|
||||||
|
return this.clusterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClusterName getClusterName() {
|
||||||
|
return clusterName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void readFrom(StreamInput in) throws IOException {
|
@Override public void readFrom(StreamInput in) throws IOException {
|
||||||
|
clusterName = ClusterName.readClusterName(in);
|
||||||
clusterState = ClusterState.Builder.readFrom(in, null, null);
|
clusterState = ClusterState.Builder.readFrom(in, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
clusterName.writeTo(out);
|
||||||
ClusterState.Builder.writeTo(clusterState, out);
|
ClusterState.Builder.writeTo(clusterState, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.action.admin.cluster.state;
|
||||||
import org.elasticsearch.ElasticSearchException;
|
import org.elasticsearch.ElasticSearchException;
|
||||||
import org.elasticsearch.action.TransportActions;
|
import org.elasticsearch.action.TransportActions;
|
||||||
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
|
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
|
||||||
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
@ -33,8 +34,12 @@ import org.elasticsearch.util.settings.Settings;
|
||||||
*/
|
*/
|
||||||
public class TransportClusterStateAction extends TransportMasterNodeOperationAction<ClusterStateRequest, ClusterStateResponse> {
|
public class TransportClusterStateAction extends TransportMasterNodeOperationAction<ClusterStateRequest, ClusterStateResponse> {
|
||||||
|
|
||||||
@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);
|
super(settings, transportService, clusterService, threadPool);
|
||||||
|
this.clusterName = clusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected String transportAction() {
|
@Override protected String transportAction() {
|
||||||
|
@ -50,6 +55,6 @@ public class TransportClusterStateAction extends TransportMasterNodeOperationAct
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected ClusterStateResponse masterOperation(ClusterStateRequest request) throws ElasticSearchException {
|
@Override protected ClusterStateResponse masterOperation(ClusterStateRequest request) throws ElasticSearchException {
|
||||||
return new ClusterStateResponse(clusterService.state());
|
return new ClusterStateResponse(clusterName, clusterService.state());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -63,6 +63,8 @@ public class RestClusterStateAction extends BaseRestHandler {
|
||||||
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
|
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
|
|
||||||
|
builder.field("cluster_name", response.clusterName().value());
|
||||||
|
|
||||||
// nodes
|
// nodes
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
builder.field("_master", state.nodes().masterNodeId());
|
builder.field("_master", state.nodes().masterNodeId());
|
||||||
|
|
Loading…
Reference in New Issue