Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Migrating NodesInfo API to use plugins instead of singular plugin
In order to be consistent (and because in 1.0 we switched from
parameter driven information to specifzing the metrics as part of the URI)
this patch moves from 'plugin' to 'plugins' in the Nodes Info API.
  • Loading branch information
spinscale committed Feb 11, 2014
1 parent d58118c commit b02e6dc
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions docs/reference/cluster/nodes-info.asciidoc
Expand Up @@ -17,7 +17,7 @@ The second command selectively retrieves nodes information of only

By default, it just returns all attributes and core settings for a node.
It also allows to get only information on `settings`, `os`, `process`, `jvm`,
`thread_pool`, `network`, `transport`, `http` and `plugin`:
`thread_pool`, `network`, `transport`, `http` and `plugins`:

[source,js]
--------------------------------------------------
Expand All @@ -30,9 +30,9 @@ curl -XGET 'http://localhost:9200/_nodes/nodeId1,nodeId2/info/jvm,process'
curl -XGET 'http://localhost:9200/_nodes/nodeId1,nodeId2/_all
--------------------------------------------------

The `all` flag can be set to return all the information - or you can simply omit it.
The `_all` flag can be set to return all the information - or you can simply omit it.

`plugin` - if set, the result will contain details about the loaded
`plugins` - if set, the result will contain details about the loaded
plugins per node:

* `name`: plugin name
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/api/nodes.info.json
Expand Up @@ -12,7 +12,7 @@
},
"metric": {
"type": "list",
"options": ["settings", "os", "process", "jvm", "thread_pool", "network", "transport", "http", "plugin"],
"options": ["settings", "os", "process", "jvm", "thread_pool", "network", "transport", "http", "plugins"],
"description": "A comma-separated list of metrics you wish returned. Leave empty to return all."
}
},
Expand Down
Expand Up @@ -38,7 +38,7 @@ public class NodesInfoRequest extends NodesOperationRequest<NodesInfoRequest> {
private boolean network = true;
private boolean transport = true;
private boolean http = true;
private boolean plugin = true;
private boolean plugins = true;

public NodesInfoRequest() {
}
Expand All @@ -63,7 +63,7 @@ public NodesInfoRequest clear() {
network = false;
transport = false;
http = false;
plugin = false;
plugins = false;
return this;
}

Expand All @@ -79,7 +79,7 @@ public NodesInfoRequest all() {
network = true;
transport = true;
http = true;
plugin = true;
plugins = true;
return this;
}

Expand Down Expand Up @@ -205,19 +205,19 @@ public NodesInfoRequest http(boolean http) {

/**
* Should information about plugins be returned
* @param plugin true if you want info
* @param plugins true if you want info
* @return The request
*/
public NodesInfoRequest plugin(boolean plugin) {
this.plugin = plugin;
public NodesInfoRequest plugins(boolean plugins) {
this.plugins = plugins;
return this;
}

/**
* @return true if information about plugins is requested
*/
public boolean plugin() {
return plugin;
public boolean plugins() {
return plugins;
}

@Override
Expand All @@ -231,7 +231,7 @@ public void readFrom(StreamInput in) throws IOException {
network = in.readBoolean();
transport = in.readBoolean();
http = in.readBoolean();
plugin = in.readBoolean();
plugins = in.readBoolean();
}

@Override
Expand All @@ -245,6 +245,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(network);
out.writeBoolean(transport);
out.writeBoolean(http);
out.writeBoolean(plugin);
out.writeBoolean(plugins);
}
}
Expand Up @@ -113,8 +113,11 @@ public NodesInfoRequestBuilder setHttp(boolean http) {
return this;
}

public NodesInfoRequestBuilder setPlugin(boolean plugin) {
request().plugin(plugin);
/**
* Should the node plugins info be returned.
*/
public NodesInfoRequestBuilder setPlugins(boolean plugins) {
request().plugins(plugins);
return this;
}

Expand Down
Expand Up @@ -98,7 +98,7 @@ protected NodeInfo newNodeResponse() {
protected NodeInfo nodeOperation(NodeInfoRequest nodeRequest) throws ElasticsearchException {
NodesInfoRequest request = nodeRequest.request;
return nodeService.info(request.settings(), request.os(), request.process(), request.jvm(), request.threadPool(),
request.network(), request.transport(), request.http(), request.plugin());
request.network(), request.transport(), request.http(), request.plugins());
}

@Override
Expand Down
Expand Up @@ -44,7 +44,7 @@
public class RestNodesInfoAction extends BaseRestHandler {

private final SettingsFilter settingsFilter;
private final static Set<String> ALLOWED_METRICS = Sets.newHashSet("http", "jvm", "network", "os", "plugin", "process", "settings", "thread_pool", "transport");
private final static Set<String> ALLOWED_METRICS = Sets.newHashSet("http", "jvm", "network", "os", "plugins", "process", "settings", "thread_pool", "transport");

@Inject
public RestNodesInfoAction(Settings settings, Client client, RestController controller,
Expand Down Expand Up @@ -99,7 +99,7 @@ public void handleRequest(final RestRequest request, final RestChannel channel)
nodesInfoRequest.network(metrics.contains("network"));
nodesInfoRequest.transport(metrics.contains("transport"));
nodesInfoRequest.http(metrics.contains("http"));
nodesInfoRequest.plugin(metrics.contains("plugin"));
nodesInfoRequest.plugins(metrics.contains("plugins"));
}

client.admin().cluster().nodesInfo(nodesInfoRequest, new ActionListener<NodesInfoResponse>() {
Expand Down
Expand Up @@ -129,7 +129,7 @@ public void testNodeInfoPlugin() throws URISyntaxException {
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());

NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().clear().setPlugin(true).execute().actionGet();
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).execute().actionGet();
logger.info("--> full json answer, status " + response.toString());

assertNodeContainsPlugins(response, server1NodeId,
Expand Down
Expand Up @@ -143,7 +143,7 @@ private static void downloadAndExtract(String pluginName, String pluginUrl) thro
}

private void assertPluginLoaded(String pluginName) {
NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().clear().setPlugin(true).get();
NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get();
assertThat(nodesInfoResponse.getNodes().length, equalTo(1));
assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getInfos(), notNullValue());
assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getInfos().size(), equalTo(1));
Expand Down

0 comments on commit b02e6dc

Please sign in to comment.