Skip to content

Commit

Permalink
[Rest] Add the cluster name to the "/" endpoint
Browse files Browse the repository at this point in the history
The root endpoint returns basic information about this node, like it's name and ES version etc. The cluster name is an important information that belongs in that list.

Closes #7524
  • Loading branch information
bleskes authored and areek committed Sep 8, 2014
1 parent 2fe9ea6 commit 19b59bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions rest-api-spec/test/info/10_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- do: {info: {}}
- match: {status: 200}
- is_true: name
- is_true: cluster_name
- is_true: tagline
- is_true: version
- is_true: version.number
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
Expand All @@ -41,11 +42,13 @@
public class RestMainAction extends BaseRestHandler {

private final Version version;
private final ClusterName clusterName;

@Inject
public RestMainAction(Settings settings, Version version, Client client, RestController controller) {
public RestMainAction(Settings settings, Version version, Client client, RestController controller, ClusterName clusterName) {
super(settings, client);
this.version = version;
this.clusterName = clusterName;
controller.registerHandler(GET, "/", this);
controller.registerHandler(HEAD, "/", this);
}
Expand Down Expand Up @@ -80,6 +83,7 @@ public RestResponse buildResponse(ClusterStateResponse response) throws Exceptio
if (settings.get("name") != null) {
builder.field("name", settings.get("name"));
}
builder.field("cluster_name", clusterName.value());
builder.startObject("version")
.field("number", version.number())
.field("build_hash", Build.CURRENT.hash())
Expand Down

0 comments on commit 19b59bc

Please sign in to comment.