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

Deprecate the 'local' parameter of /_cat/nodes #50499

Merged
merged 4 commits into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions docs/reference/cat/nodes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ Number of suggest operations, such as `0`.
include::{docdir}/rest-api/common-parms.asciidoc[tag=help]

include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
+
--
deprecated::[8.0, Parameter `local` is deprecated. It has no effect on the API call locality.]
olegbonar marked this conversation as resolved.
Show resolved Hide resolved
--

include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
},
"local":{
"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)"
"description":"Return local information, do not retrieve the state from master node (default: false)",
olegbonar marked this conversation as resolved.
Show resolved Hide resolved
"deprecated":{
"version":"8.0.0",
"description":"Parameter `local` is deprecated. It has no effect on the API call locality."
olegbonar marked this conversation as resolved.
Show resolved Hide resolved
}
},
"master_timeout":{
"type":"time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.rest.action.cat;

import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
Expand All @@ -33,6 +34,7 @@
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.ByteSizeValue;
Expand Down Expand Up @@ -67,6 +69,10 @@
import static org.elasticsearch.rest.RestRequest.Method.GET;

public class RestNodesAction extends AbstractCatAction {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(RestNodesAction.class));
static final String LOCAL_DEPRECATED_MESSAGE = "Deprecated parameter [local] used, it has no effect the API call locality. " +
olegbonar marked this conversation as resolved.
Show resolved Hide resolved
"Will be removed in 8.0";

public RestNodesAction(RestController controller) {
controller.registerHandler(GET, "/_cat/nodes", this);
Expand All @@ -86,6 +92,9 @@ protected void documentation(StringBuilder sb) {
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
clusterStateRequest.clear().nodes(true);
if (request.hasParam("local")) {
deprecationLogger.deprecatedAndMaybeLog("cat_nodes_local_deprecation", LOCAL_DEPRECATED_MESSAGE);
olegbonar marked this conversation as resolved.
Show resolved Hide resolved
}
clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
final boolean fullId = request.paramAsBoolean("full_id", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.usage.UsageService;
import org.junit.Before;

Expand Down Expand Up @@ -65,4 +68,16 @@ public void testBuildTableDoesNotThrowGivenNullNodeInfoAndStats() {

action.buildTable(false, new FakeRestRequest(), clusterStateResponse, nodesInfoResponse, nodesStatsResponse);
}

public void testCatNodesWithLocalDeprecationWarning() {
TestThreadPool threadPool = new TestThreadPool(RestNodesActionTests.class.getName());
NodeClient client = new NodeClient(Settings.EMPTY, threadPool);
FakeRestRequest request = new FakeRestRequest();
request.params().put("local", "");
olegbonar marked this conversation as resolved.
Show resolved Hide resolved

action.doCatRequest(request, client);
assertWarnings(RestNodesAction.LOCAL_DEPRECATED_MESSAGE);

terminate(threadPool);
}
}