Skip to content

Commit

Permalink
Re-enable deprecated hot_threads routes via REST compatibility (#73855)
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo authored Jun 8, 2021
1 parent db36b6c commit 4bb1f28
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
setup:
- skip:
version: "9.0.0 - "
reason: "compatible from 8.x to 7.x"
features:
- "headers"
- "allowed_warnings_regex"

---
"Get hot threads":

- do:
headers:
Content-Type: "application/vnd.elasticsearch+json;compatible-with=7"
Accept: "application/vnd.elasticsearch+json;compatible-with=7"
nodes.hot_threads: {}
allowed_warnings_regex:
- ".*hot_?threads.* is a deprecated endpoint.*"
- match:
$body: /:::/
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
Expand All @@ -23,16 +24,59 @@

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import static org.elasticsearch.rest.RestRequest.Method.GET;

public class RestNodesHotThreadsAction extends BaseRestHandler {

private static final String formatDeprecatedMessageWithoutNodeID = "[%s] is a deprecated endpoint. " +
"Please use [/_nodes/hot_threads] instead.";
private static final String formatDeprecatedMessageWithNodeID = "[%s] is a deprecated endpoint. " +
"Please use [/_nodes/{nodeId}/hot_threads] instead.";
private static final String DEPRECATED_MESSAGE_CLUSTER_NODES_HOT_THREADS = String.format(Locale.ROOT,
formatDeprecatedMessageWithoutNodeID,
"/_cluster/nodes/hot_threads"
);
private static final String DEPRECATED_MESSAGE_CLUSTER_NODES_NODEID_HOT_THREADS = String.format(Locale.ROOT,
formatDeprecatedMessageWithNodeID,
"/_cluster/nodes/{nodeId}/hot_threads"
);
private static final String DEPRECATED_MESSAGE_CLUSTER_NODES_HOTTHREADS = String.format(Locale.ROOT,
formatDeprecatedMessageWithoutNodeID,
"/_cluster/nodes/hotthreads"
);
private static final String DEPRECATED_MESSAGE_CLUSTER_NODES_NODEID_HOTTHREADS = String.format(Locale.ROOT,
formatDeprecatedMessageWithNodeID,
"/_cluster/nodes/{nodeId}/hotthreads"
);
private static final String DEPRECATED_MESSAGE_NODES_HOTTHREADS = String.format(Locale.ROOT,
formatDeprecatedMessageWithoutNodeID,
"/_nodes/hotthreads"
);
private static final String DEPRECATED_MESSAGE_NODES_NODEID_HOTTHREADS = String.format(Locale.ROOT,
formatDeprecatedMessageWithNodeID,
"/_nodes/{nodeId}/hotthreads"
);

@Override
public List<Route> routes() {
return List.of(
new Route(GET, "/_nodes/hot_threads"),
new Route(GET, "/_nodes/{nodeId}/hot_threads")
new Route(GET, "/_nodes/{nodeId}/hot_threads"),

Route.builder(GET, "/_cluster/nodes/hot_threads")
.deprecated(DEPRECATED_MESSAGE_CLUSTER_NODES_HOT_THREADS, RestApiVersion.V_7).build(),
Route.builder(GET, "/_cluster/nodes/{nodeId}/hot_threads")
.deprecated(DEPRECATED_MESSAGE_CLUSTER_NODES_NODEID_HOT_THREADS, RestApiVersion.V_7).build(),
Route.builder(GET, "/_cluster/nodes/hotthreads")
.deprecated(DEPRECATED_MESSAGE_CLUSTER_NODES_HOTTHREADS, RestApiVersion.V_7).build(),
Route.builder(GET, "/_cluster/nodes/{nodeId}/hotthreads")
.deprecated(DEPRECATED_MESSAGE_CLUSTER_NODES_NODEID_HOTTHREADS, RestApiVersion.V_7).build(),
Route.builder(GET, "/_nodes/hotthreads")
.deprecated(DEPRECATED_MESSAGE_NODES_HOTTHREADS, RestApiVersion.V_7).build(),
Route.builder(GET, "/_nodes/{nodeId}/hotthreads")
.deprecated(DEPRECATED_MESSAGE_NODES_NODEID_HOTTHREADS, RestApiVersion.V_7).build()
);
}

Expand Down

0 comments on commit 4bb1f28

Please sign in to comment.