Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating NodesInfo API to use plugins instead of singular plugin #5072

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/reference/cluster/nodes-info.asciidoc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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