diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java index 5aeefa934d0..f46118ff40f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java @@ -34,25 +34,67 @@ import org.elasticsearch.rest.action.RestResponseListener; import java.io.IOException; import java.util.List; +import java.util.Locale; import static java.util.Arrays.asList; import static java.util.Collections.unmodifiableList; 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 deprecatedRoutes() { + return unmodifiableList(asList( + new DeprecatedRoute(GET, "/_cluster/nodes/hot_threads", + DEPRECATED_MESSAGE_CLUSTER_NODES_HOT_THREADS), + new DeprecatedRoute(GET, "/_cluster/nodes/{nodeId}/hot_threads", + DEPRECATED_MESSAGE_CLUSTER_NODES_NODEID_HOT_THREADS), + new DeprecatedRoute(GET, "/_cluster/nodes/hotthreads", + DEPRECATED_MESSAGE_CLUSTER_NODES_HOTTHREADS), + new DeprecatedRoute(GET, "/_cluster/nodes/{nodeId}/hotthreads", + DEPRECATED_MESSAGE_CLUSTER_NODES_NODEID_HOTTHREADS), + new DeprecatedRoute(GET, "/_nodes/hotthreads", + DEPRECATED_MESSAGE_NODES_HOTTHREADS), + new DeprecatedRoute(GET, "/_nodes/{nodeId}/hotthreads", + DEPRECATED_MESSAGE_NODES_NODEID_HOTTHREADS) + )); + } + @Override public List routes() { return unmodifiableList(asList( - new Route(GET, "/_cluster/nodes/hotthreads"), - new Route(GET, "/_cluster/nodes/hot_threads"), - new Route(GET, "/_cluster/nodes/{nodeId}/hotthreads"), - new Route(GET, "/_cluster/nodes/{nodeId}/hot_threads"), - new Route(GET, "/_nodes/hotthreads"), new Route(GET, "/_nodes/hot_threads"), - new Route(GET, "/_nodes/{nodeId}/hotthreads"), - new Route(GET, "/_nodes/{nodeId}/hot_threads"))); + new Route(GET, "/_nodes/{nodeId}/hot_threads") + )); } @Override