Просмотр исходного кода

Remove more unnecessary ActionType subclasses (#101053)

Relates #97721
David Turner 2 лет назад
Родитель
Сommit
3ce905b754
60 измененных файлов с 223 добавлено и 392 удалено
  1. 9 4
      client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/NoopPlugin.java
  2. 0 21
      client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/NoopBulkAction.java
  3. 2 1
      client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java
  4. 0 20
      client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/NoopSearchAction.java
  5. 2 1
      client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java
  6. 2 1
      client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/TransportNoopSearchAction.java
  7. 6 6
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/DeleteDataStreamLifecycleAction.java
  8. 7 6
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/ExplainDataStreamLifecycleAction.java
  9. 6 6
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/GetDataStreamLifecycleAction.java
  10. 6 6
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/PutDataStreamLifecycleAction.java
  11. 1 1
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportDeleteDataStreamLifecycleAction.java
  12. 1 1
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportExplainDataStreamLifecycleAction.java
  13. 1 1
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportGetDataStreamLifecycleAction.java
  14. 1 1
      modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportPutDataStreamLifecycleAction.java
  15. 7 7
      modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java
  16. 4 7
      modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsAction.java
  17. 1 1
      modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsTransportAction.java
  18. 3 2
      modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/MultiSearchTemplateIT.java
  19. 4 4
      modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchTemplateIT.java
  20. 0 21
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateAction.java
  21. 12 2
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustachePlugin.java
  22. 1 1
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java
  23. 1 1
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestRenderSearchTemplateAction.java
  24. 1 1
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java
  25. 0 21
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateAction.java
  26. 3 2
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateRequestBuilder.java
  27. 1 1
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportMultiSearchTemplateAction.java
  28. 7 1
      modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java
  29. 10 7
      modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java
  30. 4 7
      modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessExecuteAction.java
  31. 22 22
      modules/rank-eval/src/internalClusterTest/java/org/elasticsearch/index/rankeval/RankEvalRequestIT.java
  32. 0 24
      modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalAction.java
  33. 4 1
      modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalPlugin.java
  34. 1 1
      modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RestRankEvalAction.java
  35. 1 1
      modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java
  36. 1 2
      modules/reindex/src/internalClusterTest/java/org/elasticsearch/client/documentation/ReindexDocumentationIT.java
  37. 8 1
      modules/reindex/src/main/java/org/elasticsearch/reindex/ReindexPlugin.java
  38. 1 1
      modules/reindex/src/main/java/org/elasticsearch/reindex/RestRethrottleAction.java
  39. 0 21
      modules/reindex/src/main/java/org/elasticsearch/reindex/RethrottleAction.java
  40. 2 2
      modules/reindex/src/main/java/org/elasticsearch/reindex/TransportRethrottleAction.java
  41. 1 1
      modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexTestCase.java
  42. 1 1
      modules/reindex/src/test/java/org/elasticsearch/reindex/TransportRethrottleActionTests.java
  43. 0 22
      modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainAction.java
  44. 5 1
      modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainRestPlugin.java
  45. 1 1
      modules/rest-root/src/main/java/org/elasticsearch/rest/root/RestMainAction.java
  46. 1 1
      modules/rest-root/src/main/java/org/elasticsearch/rest/root/TransportMainAction.java
  47. 1 1
      server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java
  48. 30 34
      server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java
  49. 2 2
      server/src/main/java/org/elasticsearch/action/ActionType.java
  50. 1 6
      server/src/test/java/org/elasticsearch/action/ActionModuleTests.java
  51. 3 8
      server/src/test/java/org/elasticsearch/action/ActionTests.java
  52. 10 24
      server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java
  53. 6 8
      server/src/test/java/org/elasticsearch/indices/settings/InternalOrPrivateSettingsPlugin.java
  54. 9 16
      server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java
  55. 1 1
      test/external-modules/seek-tracking-directory/src/internalClusterTest/java/org/elasticsearch/test/seektracker/SeekTrackerPluginIT.java
  56. 1 1
      test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/RestSeekStatsAction.java
  57. 0 22
      test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekStatsAction.java
  58. 4 1
      test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekTrackerPlugin.java
  59. 1 1
      test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/TransportSeekStatsAction.java
  60. 2 2
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

+ 9 - 4
client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/NoopPlugin.java

@@ -9,16 +9,17 @@ package org.elasticsearch.plugin.noop;
 
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.ActionType;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
 import org.elasticsearch.common.settings.ClusterSettings;
 import org.elasticsearch.common.settings.IndexScopedSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.settings.SettingsFilter;
-import org.elasticsearch.plugin.noop.action.bulk.NoopBulkAction;
 import org.elasticsearch.plugin.noop.action.bulk.RestNoopBulkAction;
 import org.elasticsearch.plugin.noop.action.bulk.TransportNoopBulkAction;
-import org.elasticsearch.plugin.noop.action.search.NoopSearchAction;
 import org.elasticsearch.plugin.noop.action.search.RestNoopSearchAction;
 import org.elasticsearch.plugin.noop.action.search.TransportNoopSearchAction;
 import org.elasticsearch.plugins.ActionPlugin;
@@ -31,11 +32,15 @@ import java.util.List;
 import java.util.function.Supplier;
 
 public class NoopPlugin extends Plugin implements ActionPlugin {
+
+    public static final ActionType<SearchResponse> NOOP_SEARCH_ACTION = new ActionType<>("mock:data/read/search", SearchResponse::new);
+    public static final ActionType<BulkResponse> NOOP_BULK_ACTION = new ActionType<>("mock:data/write/bulk", BulkResponse::new);
+
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
         return Arrays.asList(
-            new ActionHandler<>(NoopBulkAction.INSTANCE, TransportNoopBulkAction.class),
-            new ActionHandler<>(NoopSearchAction.INSTANCE, TransportNoopSearchAction.class)
+            new ActionHandler<>(NOOP_BULK_ACTION, TransportNoopBulkAction.class),
+            new ActionHandler<>(NOOP_SEARCH_ACTION, TransportNoopSearchAction.class)
         );
     }
 

+ 0 - 21
client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/NoopBulkAction.java

@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-package org.elasticsearch.plugin.noop.action.bulk;
-
-import org.elasticsearch.action.ActionType;
-import org.elasticsearch.action.bulk.BulkResponse;
-
-public class NoopBulkAction extends ActionType<BulkResponse> {
-    public static final String NAME = "mock:data/write/bulk";
-
-    public static final NoopBulkAction INSTANCE = new NoopBulkAction();
-
-    private NoopBulkAction() {
-        super(NAME, BulkResponse::new);
-    }
-}

+ 2 - 1
client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java

@@ -19,6 +19,7 @@ import org.elasticsearch.action.update.UpdateResponse;
 import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.common.util.concurrent.EsExecutors;
 import org.elasticsearch.index.shard.ShardId;
+import org.elasticsearch.plugin.noop.NoopPlugin;
 import org.elasticsearch.tasks.Task;
 import org.elasticsearch.transport.TransportService;
 
@@ -31,7 +32,7 @@ public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest,
 
     @Inject
     public TransportNoopBulkAction(TransportService transportService, ActionFilters actionFilters) {
-        super(NoopBulkAction.NAME, transportService, actionFilters, BulkRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
+        super(NoopPlugin.NOOP_BULK_ACTION.name(), transportService, actionFilters, BulkRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
     }
 
     @Override

+ 0 - 20
client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/NoopSearchAction.java

@@ -1,20 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-package org.elasticsearch.plugin.noop.action.search;
-
-import org.elasticsearch.action.ActionType;
-import org.elasticsearch.action.search.SearchResponse;
-
-public class NoopSearchAction extends ActionType<SearchResponse> {
-    public static final NoopSearchAction INSTANCE = new NoopSearchAction();
-    public static final String NAME = "mock:data/read/search";
-
-    private NoopSearchAction() {
-        super(NAME, SearchResponse::new);
-    }
-}

+ 2 - 1
client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java

@@ -9,6 +9,7 @@ package org.elasticsearch.plugin.noop.action.search;
 
 import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.client.internal.node.NodeClient;
+import org.elasticsearch.plugin.noop.NoopPlugin;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.action.RestChunkedToXContentListener;
@@ -38,6 +39,6 @@ public class RestNoopSearchAction extends BaseRestHandler {
     @Override
     public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) {
         SearchRequest searchRequest = new SearchRequest();
-        return channel -> client.execute(NoopSearchAction.INSTANCE, searchRequest, new RestChunkedToXContentListener<>(channel));
+        return channel -> client.execute(NoopPlugin.NOOP_SEARCH_ACTION, searchRequest, new RestChunkedToXContentListener<>(channel));
     }
 }

+ 2 - 1
client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/TransportNoopSearchAction.java

@@ -17,6 +17,7 @@ import org.elasticsearch.action.support.HandledTransportAction;
 import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.common.util.concurrent.EsExecutors;
+import org.elasticsearch.plugin.noop.NoopPlugin;
 import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.search.SearchHits;
 import org.elasticsearch.search.aggregations.InternalAggregations;
@@ -32,7 +33,7 @@ public class TransportNoopSearchAction extends HandledTransportAction<SearchRequ
     @Inject
     public TransportNoopSearchAction(TransportService transportService, ActionFilters actionFilters) {
         super(
-            NoopSearchAction.NAME,
+            NoopPlugin.NOOP_SEARCH_ACTION.name(),
             transportService,
             actionFilters,
             (Writeable.Reader<SearchRequest>) SearchRequest::new,

+ 6 - 6
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/DeleteDataStreamLifecycleAction.java

@@ -24,14 +24,14 @@ import java.util.Objects;
 /**
  * Removes the data stream lifecycle configuration from the requested data streams.
  */
-public class DeleteDataStreamLifecycleAction extends ActionType<AcknowledgedResponse> {
+public class DeleteDataStreamLifecycleAction {
 
-    public static final DeleteDataStreamLifecycleAction INSTANCE = new DeleteDataStreamLifecycleAction();
-    public static final String NAME = "indices:admin/data_stream/lifecycle/delete";
+    public static final ActionType<AcknowledgedResponse> INSTANCE = new ActionType<>(
+        "indices:admin/data_stream/lifecycle/delete",
+        AcknowledgedResponse::readFrom
+    );
 
-    private DeleteDataStreamLifecycleAction() {
-        super(NAME, AcknowledgedResponse::readFrom);
-    }
+    private DeleteDataStreamLifecycleAction() {/* no instances */}
 
     public static final class Request extends AcknowledgedRequest<Request> implements IndicesRequest.Replaceable {
 

+ 7 - 6
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/ExplainDataStreamLifecycleAction.java

@@ -33,13 +33,14 @@ import java.util.Objects;
 /**
  * Action for explaining the data stream lifecycle status for one or more indices.
  */
-public class ExplainDataStreamLifecycleAction extends ActionType<ExplainDataStreamLifecycleAction.Response> {
-    public static final ExplainDataStreamLifecycleAction INSTANCE = new ExplainDataStreamLifecycleAction();
-    public static final String NAME = "indices:admin/data_stream/lifecycle/explain";
+public class ExplainDataStreamLifecycleAction {
 
-    public ExplainDataStreamLifecycleAction() {
-        super(NAME, Response::new);
-    }
+    public static final ActionType<ExplainDataStreamLifecycleAction.Response> INSTANCE = new ActionType<>(
+        "indices:admin/data_stream/lifecycle/explain",
+        Response::new
+    );
+
+    private ExplainDataStreamLifecycleAction() {/* no instances */}
 
     /**
      * Request explaining the data stream lifecycle for one or more indices.

+ 6 - 6
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/GetDataStreamLifecycleAction.java

@@ -34,14 +34,14 @@ import java.util.Objects;
 /**
  * This action retrieves the data stream lifecycle from every data stream that has a data stream lifecycle configured.
  */
-public class GetDataStreamLifecycleAction extends ActionType<GetDataStreamLifecycleAction.Response> {
+public class GetDataStreamLifecycleAction {
 
-    public static final GetDataStreamLifecycleAction INSTANCE = new GetDataStreamLifecycleAction();
-    public static final String NAME = "indices:admin/data_stream/lifecycle/get";
+    public static final ActionType<GetDataStreamLifecycleAction.Response> INSTANCE = new ActionType<>(
+        "indices:admin/data_stream/lifecycle/get",
+        Response::new
+    );
 
-    private GetDataStreamLifecycleAction() {
-        super(NAME, Response::new);
-    }
+    private GetDataStreamLifecycleAction() {/* no instances */}
 
     public static class Request extends MasterNodeReadRequest<Request> implements IndicesRequest.Replaceable {
 

+ 6 - 6
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/PutDataStreamLifecycleAction.java

@@ -38,14 +38,14 @@ import static org.elasticsearch.cluster.metadata.DataStreamLifecycle.ENABLED_FIE
 /**
  * Sets the data stream lifecycle that was provided in the request to the requested data streams.
  */
-public class PutDataStreamLifecycleAction extends ActionType<AcknowledgedResponse> {
+public class PutDataStreamLifecycleAction {
 
-    public static final PutDataStreamLifecycleAction INSTANCE = new PutDataStreamLifecycleAction();
-    public static final String NAME = "indices:admin/data_stream/lifecycle/put";
+    public static final ActionType<AcknowledgedResponse> INSTANCE = new ActionType<>(
+        "indices:admin/data_stream/lifecycle/put",
+        AcknowledgedResponse::readFrom
+    );
 
-    private PutDataStreamLifecycleAction() {
-        super(NAME, AcknowledgedResponse::readFrom);
-    }
+    private PutDataStreamLifecycleAction() {/* no instances */}
 
     public static final class Request extends AcknowledgedRequest<Request> implements IndicesRequest.Replaceable, ToXContentObject {
 

+ 1 - 1
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportDeleteDataStreamLifecycleAction.java

@@ -47,7 +47,7 @@ public class TransportDeleteDataStreamLifecycleAction extends AcknowledgedTransp
         SystemIndices systemIndices
     ) {
         super(
-            DeleteDataStreamLifecycleAction.NAME,
+            DeleteDataStreamLifecycleAction.INSTANCE.name(),
             transportService,
             clusterService,
             threadPool,

+ 1 - 1
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportExplainDataStreamLifecycleAction.java

@@ -53,7 +53,7 @@ public class TransportExplainDataStreamLifecycleAction extends TransportMasterNo
         DataStreamLifecycleErrorStore dataLifecycleServiceErrorStore
     ) {
         super(
-            ExplainDataStreamLifecycleAction.NAME,
+            ExplainDataStreamLifecycleAction.INSTANCE.name(),
             transportService,
             clusterService,
             threadPool,

+ 1 - 1
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportGetDataStreamLifecycleAction.java

@@ -48,7 +48,7 @@ public class TransportGetDataStreamLifecycleAction extends TransportMasterNodeRe
         IndexNameExpressionResolver indexNameExpressionResolver
     ) {
         super(
-            GetDataStreamLifecycleAction.NAME,
+            GetDataStreamLifecycleAction.INSTANCE.name(),
             transportService,
             clusterService,
             threadPool,

+ 1 - 1
modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/TransportPutDataStreamLifecycleAction.java

@@ -46,7 +46,7 @@ public class TransportPutDataStreamLifecycleAction extends AcknowledgedTransport
         SystemIndices systemIndices
     ) {
         super(
-            PutDataStreamLifecycleAction.NAME,
+            PutDataStreamLifecycleAction.INSTANCE.name(),
             transportService,
             clusterService,
             threadPool,

+ 7 - 7
modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java

@@ -40,14 +40,14 @@ import java.util.TreeMap;
 import static org.elasticsearch.grok.GrokBuiltinPatterns.ECS_COMPATIBILITY_DISABLED;
 import static org.elasticsearch.rest.RestRequest.Method.GET;
 
-public class GrokProcessorGetAction extends ActionType<GrokProcessorGetAction.Response> {
+public class GrokProcessorGetAction {
 
-    static final GrokProcessorGetAction INSTANCE = new GrokProcessorGetAction();
-    static final String NAME = "cluster:admin/ingest/processor/grok/get";
+    static final ActionType<GrokProcessorGetAction.Response> INSTANCE = new ActionType<>(
+        "cluster:admin/ingest/processor/grok/get",
+        Response::new
+    );
 
-    private GrokProcessorGetAction() {
-        super(NAME, Response::new);
-    }
+    private GrokProcessorGetAction() {/* no instances */}
 
     public static class Request extends ActionRequest {
 
@@ -140,7 +140,7 @@ public class GrokProcessorGetAction extends ActionType<GrokProcessorGetAction.Re
             PatternBank legacyGrokPatterns,
             PatternBank ecsV1GrokPatterns
         ) {
-            super(NAME, transportService, actionFilters, Request::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
+            super(INSTANCE.name(), transportService, actionFilters, Request::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
             this.legacyGrokPatterns = legacyGrokPatterns.bank();
             this.sortedLegacyGrokPatterns = new TreeMap<>(this.legacyGrokPatterns);
             this.ecsV1GrokPatterns = ecsV1GrokPatterns.bank();

+ 4 - 7
modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsAction.java

@@ -30,14 +30,11 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 
-public class GeoIpDownloaderStatsAction extends ActionType<GeoIpDownloaderStatsAction.Response> {
+public class GeoIpDownloaderStatsAction {
 
-    public static final GeoIpDownloaderStatsAction INSTANCE = new GeoIpDownloaderStatsAction();
-    public static final String NAME = "cluster:monitor/ingest/geoip/stats";
+    public static final ActionType<Response> INSTANCE = new ActionType<>("cluster:monitor/ingest/geoip/stats", Response::new);
 
-    public GeoIpDownloaderStatsAction() {
-        super(NAME, Response::new);
-    }
+    private GeoIpDownloaderStatsAction() {/* no instances */}
 
     public static class Request extends BaseNodesRequest<Request> implements ToXContentObject {
 
@@ -55,7 +52,7 @@ public class GeoIpDownloaderStatsAction extends ActionType<GeoIpDownloaderStatsA
         @Override
         public int hashCode() {
             // Nothing to hash atm, so just use the action name
-            return Objects.hashCode(NAME);
+            return Objects.hashCode(INSTANCE.name());
         }
 
         @Override

+ 1 - 1
modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsTransportAction.java

@@ -45,7 +45,7 @@ public class GeoIpDownloaderStatsTransportAction extends TransportNodesAction<Re
         GeoIpDownloaderTaskExecutor geoIpDownloaderTaskExecutor
     ) {
         super(
-            GeoIpDownloaderStatsAction.NAME,
+            GeoIpDownloaderStatsAction.INSTANCE.name(),
             clusterService,
             transportService,
             actionFilters,

+ 3 - 2
modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/MultiSearchTemplateIT.java

@@ -142,7 +142,7 @@ public class MultiSearchTemplateIT extends ESIntegTestCase {
         search5.setScriptParams(params5);
         multiRequest.add(search5);
 
-        MultiSearchTemplateResponse response = client().execute(MultiSearchTemplateAction.INSTANCE, multiRequest).get();
+        MultiSearchTemplateResponse response = client().execute(MustachePlugin.MULTI_SEARCH_TEMPLATE_ACTION, multiRequest).get();
         assertThat(response.getResponses(), arrayWithSize(5));
         assertThat(response.getTook().millis(), greaterThan(0L));
 
@@ -195,7 +195,8 @@ public class MultiSearchTemplateIT extends ESIntegTestCase {
         searchTemplateRequest.setRequest(new SearchRequest());
         MultiSearchTemplateRequest request = new MultiSearchTemplateRequest();
         request.add(searchTemplateRequest);
-        MultiSearchTemplateResponse multiSearchTemplateResponse = client().execute(MultiSearchTemplateAction.INSTANCE, request).get();
+        MultiSearchTemplateResponse multiSearchTemplateResponse = client().execute(MustachePlugin.MULTI_SEARCH_TEMPLATE_ACTION, request)
+            .get();
         Item response = multiSearchTemplateResponse.getResponses()[0];
         assertTrue(response.isFailure());
         Exception ex = response.getFailure();

+ 4 - 4
modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchTemplateIT.java

@@ -100,7 +100,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
             }""";
         SearchTemplateRequest request = SearchTemplateRequest.fromXContent(createParser(JsonXContent.jsonXContent, query));
         request.setRequest(searchRequest);
-        SearchTemplateResponse searchResponse = client().execute(SearchTemplateAction.INSTANCE, request).get();
+        SearchTemplateResponse searchResponse = client().execute(MustachePlugin.SEARCH_TEMPLATE_ACTION, request).get();
         assertThat(searchResponse.getResponse().getHits().getHits().length, equalTo(1));
     }
 
@@ -121,7 +121,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
             }""";
         SearchTemplateRequest request = SearchTemplateRequest.fromXContent(createParser(JsonXContent.jsonXContent, templateString));
         request.setRequest(searchRequest);
-        SearchTemplateResponse searchResponse = client().execute(SearchTemplateAction.INSTANCE, request).get();
+        SearchTemplateResponse searchResponse = client().execute(MustachePlugin.SEARCH_TEMPLATE_ACTION, request).get();
         assertThat(searchResponse.getResponse().getHits().getHits().length, equalTo(1));
     }
 
@@ -142,7 +142,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
             }""";
         SearchTemplateRequest request = SearchTemplateRequest.fromXContent(createParser(JsonXContent.jsonXContent, templateString));
         request.setRequest(searchRequest);
-        SearchTemplateResponse searchResponse = client().execute(SearchTemplateAction.INSTANCE, request).get();
+        SearchTemplateResponse searchResponse = client().execute(MustachePlugin.SEARCH_TEMPLATE_ACTION, request).get();
         assertThat(searchResponse.getResponse().getHits().getHits().length, equalTo(1));
     }
 
@@ -363,7 +363,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
         request.setRequest(new SearchRequest());
         ExecutionException ex = expectThrows(
             ExecutionException.class,
-            () -> client().execute(SearchTemplateAction.INSTANCE, request).get()
+            () -> client().execute(MustachePlugin.SEARCH_TEMPLATE_ACTION, request).get()
         );
 
         Throwable primary = ex.getCause();

+ 0 - 21
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateAction.java

@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.script.mustache;
-
-import org.elasticsearch.action.ActionType;
-
-public class MultiSearchTemplateAction extends ActionType<MultiSearchTemplateResponse> {
-
-    public static final MultiSearchTemplateAction INSTANCE = new MultiSearchTemplateAction();
-    public static final String NAME = "indices:data/read/msearch/template";
-
-    private MultiSearchTemplateAction() {
-        super(NAME, MultiSearchTemplateResponse::new);
-    }
-}

+ 12 - 2
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustachePlugin.java

@@ -10,6 +10,7 @@ package org.elasticsearch.script.mustache;
 
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.ActionType;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
 import org.elasticsearch.common.settings.ClusterSettings;
@@ -32,6 +33,15 @@ import java.util.function.Supplier;
 
 public class MustachePlugin extends Plugin implements ScriptPlugin, ActionPlugin, SearchPlugin {
 
+    public static final ActionType<SearchTemplateResponse> SEARCH_TEMPLATE_ACTION = new ActionType<>(
+        "indices:data/read/search/template",
+        SearchTemplateResponse::new
+    );
+    public static final ActionType<MultiSearchTemplateResponse> MULTI_SEARCH_TEMPLATE_ACTION = new ActionType<>(
+        "indices:data/read/msearch/template",
+        MultiSearchTemplateResponse::new
+    );
+
     @Override
     public ScriptEngine getScriptEngine(Settings settings, Collection<ScriptContext<?>> contexts) {
         return new MustacheScriptEngine();
@@ -40,8 +50,8 @@ public class MustachePlugin extends Plugin implements ScriptPlugin, ActionPlugin
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
         return Arrays.asList(
-            new ActionHandler<>(SearchTemplateAction.INSTANCE, TransportSearchTemplateAction.class),
-            new ActionHandler<>(MultiSearchTemplateAction.INSTANCE, TransportMultiSearchTemplateAction.class)
+            new ActionHandler<>(SEARCH_TEMPLATE_ACTION, TransportSearchTemplateAction.class),
+            new ActionHandler<>(MULTI_SEARCH_TEMPLATE_ACTION, TransportMultiSearchTemplateAction.class)
         );
     }
 

+ 1 - 1
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java

@@ -59,7 +59,7 @@ public class RestMultiSearchTemplateAction extends BaseRestHandler {
     @Override
     public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
         MultiSearchTemplateRequest multiRequest = parseRequest(request, allowExplicitIndex);
-        return channel -> client.execute(MultiSearchTemplateAction.INSTANCE, multiRequest, new RestToXContentListener<>(channel));
+        return channel -> client.execute(MustachePlugin.MULTI_SEARCH_TEMPLATE_ACTION, multiRequest, new RestToXContentListener<>(channel));
     }
 
     /**

+ 1 - 1
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestRenderSearchTemplateAction.java

@@ -56,6 +56,6 @@ public class RestRenderSearchTemplateAction extends BaseRestHandler {
             renderRequest.setScript(id);
         }
 
-        return channel -> client.execute(SearchTemplateAction.INSTANCE, renderRequest, new RestToXContentListener<>(channel));
+        return channel -> client.execute(MustachePlugin.SEARCH_TEMPLATE_ACTION, renderRequest, new RestToXContentListener<>(channel));
     }
 }

+ 1 - 1
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java

@@ -77,7 +77,7 @@ public class RestSearchTemplateAction extends BaseRestHandler {
             searchTemplateRequest.setExplain(searchRequest.source().explain());
         }
         return channel -> client.execute(
-            SearchTemplateAction.INSTANCE,
+            MustachePlugin.SEARCH_TEMPLATE_ACTION,
             searchTemplateRequest,
             new RestToXContentListener<>(channel, SearchTemplateResponse::status)
         );

+ 0 - 21
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateAction.java

@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.script.mustache;
-
-import org.elasticsearch.action.ActionType;
-
-public class SearchTemplateAction extends ActionType<SearchTemplateResponse> {
-
-    public static final SearchTemplateAction INSTANCE = new SearchTemplateAction();
-    public static final String NAME = "indices:data/read/search/template";
-
-    private SearchTemplateAction() {
-        super(NAME, SearchTemplateResponse::new);
-    }
-}

+ 3 - 2
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateRequestBuilder.java

@@ -9,6 +9,7 @@
 package org.elasticsearch.script.mustache;
 
 import org.elasticsearch.action.ActionRequestBuilder;
+import org.elasticsearch.action.ActionType;
 import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.client.internal.ElasticsearchClient;
 import org.elasticsearch.script.ScriptType;
@@ -17,12 +18,12 @@ import java.util.Map;
 
 public class SearchTemplateRequestBuilder extends ActionRequestBuilder<SearchTemplateRequest, SearchTemplateResponse> {
 
-    SearchTemplateRequestBuilder(ElasticsearchClient client, SearchTemplateAction action) {
+    SearchTemplateRequestBuilder(ElasticsearchClient client, ActionType<SearchTemplateResponse> action) {
         super(client, action, new SearchTemplateRequest());
     }
 
     public SearchTemplateRequestBuilder(ElasticsearchClient client) {
-        this(client, SearchTemplateAction.INSTANCE);
+        this(client, MustachePlugin.SEARCH_TEMPLATE_ACTION);
     }
 
     public SearchTemplateRequestBuilder setRequest(SearchRequest searchRequest) {

+ 1 - 1
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportMultiSearchTemplateAction.java

@@ -46,7 +46,7 @@ public class TransportMultiSearchTemplateAction extends HandledTransportAction<M
         UsageService usageService
     ) {
         super(
-            MultiSearchTemplateAction.NAME,
+            MustachePlugin.MULTI_SEARCH_TEMPLATE_ACTION.name(),
             transportService,
             actionFilters,
             MultiSearchTemplateRequest::new,

+ 7 - 1
modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java

@@ -55,7 +55,13 @@ public class TransportSearchTemplateAction extends HandledTransportAction<Search
         NodeClient client,
         UsageService usageService
     ) {
-        super(SearchTemplateAction.NAME, transportService, actionFilters, SearchTemplateRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
+        super(
+            MustachePlugin.SEARCH_TEMPLATE_ACTION.name(),
+            transportService,
+            actionFilters,
+            SearchTemplateRequest::new,
+            EsExecutors.DIRECT_EXECUTOR_SERVICE
+        );
         this.scriptService = scriptService;
         this.xContentRegistry = xContentRegistry;
         this.client = client;

+ 10 - 7
modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java

@@ -52,16 +52,13 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
  *     retrieves all available information about the API for this specific context</li>
  * </ul>
  */
-public class PainlessContextAction extends ActionType<PainlessContextAction.Response> {
+public class PainlessContextAction {
 
-    public static final PainlessContextAction INSTANCE = new PainlessContextAction();
-    private static final String NAME = "cluster:admin/scripts/painless/context";
+    public static final ActionType<Response> INSTANCE = new ActionType<>("cluster:admin/scripts/painless/context", Response::new);
 
     private static final String SCRIPT_CONTEXT_NAME_PARAM = "context";
 
-    private PainlessContextAction() {
-        super(NAME, PainlessContextAction.Response::new);
-    }
+    private PainlessContextAction() {/* no instances */}
 
     public static class Request extends ActionRequest {
 
@@ -143,7 +140,13 @@ public class PainlessContextAction extends ActionType<PainlessContextAction.Resp
 
         @Inject
         public TransportAction(TransportService transportService, ActionFilters actionFilters, PainlessScriptEngine painlessScriptEngine) {
-            super(NAME, transportService, actionFilters, (Writeable.Reader<Request>) Request::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
+            super(
+                INSTANCE.name(),
+                transportService,
+                actionFilters,
+                (Writeable.Reader<Request>) Request::new,
+                EsExecutors.DIRECT_EXECUTOR_SERVICE
+            );
             this.painlessScriptEngine = painlessScriptEngine;
         }
 

+ 4 - 7
modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessExecuteAction.java

@@ -113,14 +113,11 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
 import static org.elasticsearch.rest.RestRequest.Method.GET;
 import static org.elasticsearch.rest.RestRequest.Method.POST;
 
-public class PainlessExecuteAction extends ActionType<PainlessExecuteAction.Response> {
+public class PainlessExecuteAction {
 
-    public static final PainlessExecuteAction INSTANCE = new PainlessExecuteAction();
-    private static final String NAME = "cluster:admin/scripts/painless/execute";
+    public static final ActionType<Response> INSTANCE = new ActionType<>("cluster:admin/scripts/painless/execute", Response::new);
 
-    private PainlessExecuteAction() {
-        super(NAME, Response::new);
-    }
+    private PainlessExecuteAction() {/* no instances */}
 
     public static class Request extends SingleShardRequest<Request> implements ToXContentObject {
 
@@ -507,7 +504,7 @@ public class PainlessExecuteAction extends ActionType<PainlessExecuteAction.Resp
             IndicesService indicesServices
         ) {
             super(
-                NAME,
+                INSTANCE.name(),
                 threadPool,
                 clusterService,
                 transportService,

+ 22 - 22
modules/rank-eval/src/internalClusterTest/java/org/elasticsearch/index/rankeval/RankEvalRequestIT.java

@@ -88,11 +88,11 @@ public class RankEvalRequestIT extends ESIntegTestCase {
         PrecisionAtK metric = new PrecisionAtK(1, false, 10);
         RankEvalSpec task = new RankEvalSpec(specifications, metric);
 
-        RankEvalRequestBuilder builder = new RankEvalRequestBuilder(client(), RankEvalAction.INSTANCE, new RankEvalRequest());
+        RankEvalRequestBuilder builder = new RankEvalRequestBuilder(client(), RankEvalPlugin.ACTION, new RankEvalRequest());
         builder.setRankEvalSpec(task);
 
         String indexToUse = randomBoolean() ? TEST_INDEX : INDEX_ALIAS;
-        RankEvalResponse response = client().execute(RankEvalAction.INSTANCE, builder.request().indices(indexToUse)).actionGet();
+        RankEvalResponse response = client().execute(RankEvalPlugin.ACTION, builder.request().indices(indexToUse)).actionGet();
         // the expected Prec@ for the first query is 4/6 and the expected Prec@ for the
         // second is 1/6, divided by 2 to get the average
         double expectedPrecision = (1.0 / 6.0 + 4.0 / 6.0) / 2.0;
@@ -133,9 +133,9 @@ public class RankEvalRequestIT extends ESIntegTestCase {
         metric = new PrecisionAtK(1, false, 3);
         task = new RankEvalSpec(specifications, metric);
 
-        builder = new RankEvalRequestBuilder(client(), RankEvalAction.INSTANCE, new RankEvalRequest(task, new String[] { TEST_INDEX }));
+        builder = new RankEvalRequestBuilder(client(), RankEvalPlugin.ACTION, new RankEvalRequest(task, new String[] { TEST_INDEX }));
 
-        response = client().execute(RankEvalAction.INSTANCE, builder.request()).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, builder.request()).actionGet();
         // if we look only at top 3 documente, the expected P@3 for the first query is
         // 2/3 and the expected Prec@ for the second is 1/3, divided by 2 to get the average
         expectedPrecision = (1.0 / 3.0 + 2.0 / 3.0) / 2.0;
@@ -167,20 +167,20 @@ public class RankEvalRequestIT extends ESIntegTestCase {
 
         RankEvalRequestBuilder builder = new RankEvalRequestBuilder(
             client(),
-            RankEvalAction.INSTANCE,
+            RankEvalPlugin.ACTION,
             new RankEvalRequest(task, new String[] { TEST_INDEX })
         );
 
-        RankEvalResponse response = client().execute(RankEvalAction.INSTANCE, builder.request()).actionGet();
+        RankEvalResponse response = client().execute(RankEvalPlugin.ACTION, builder.request()).actionGet();
         assertEquals(DiscountedCumulativeGainTests.EXPECTED_DCG, response.getMetricScore(), 10E-14);
 
         // test that a different window size k affects the result
         metric = new DiscountedCumulativeGain(false, null, 3);
         task = new RankEvalSpec(specifications, metric);
 
-        builder = new RankEvalRequestBuilder(client(), RankEvalAction.INSTANCE, new RankEvalRequest(task, new String[] { TEST_INDEX }));
+        builder = new RankEvalRequestBuilder(client(), RankEvalPlugin.ACTION, new RankEvalRequest(task, new String[] { TEST_INDEX }));
 
-        response = client().execute(RankEvalAction.INSTANCE, builder.request()).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, builder.request()).actionGet();
         assertEquals(12.39278926071437, response.getMetricScore(), 10E-14);
     }
 
@@ -198,11 +198,11 @@ public class RankEvalRequestIT extends ESIntegTestCase {
 
         RankEvalRequestBuilder builder = new RankEvalRequestBuilder(
             client(),
-            RankEvalAction.INSTANCE,
+            RankEvalPlugin.ACTION,
             new RankEvalRequest(task, new String[] { TEST_INDEX })
         );
 
-        RankEvalResponse response = client().execute(RankEvalAction.INSTANCE, builder.request()).actionGet();
+        RankEvalResponse response = client().execute(RankEvalPlugin.ACTION, builder.request()).actionGet();
         // the expected reciprocal rank for the amsterdam_query is 1/5
         // the expected reciprocal rank for the berlin_query is 1/1
         // dividing by 2 to get the average
@@ -213,9 +213,9 @@ public class RankEvalRequestIT extends ESIntegTestCase {
         metric = new MeanReciprocalRank(1, 3);
         task = new RankEvalSpec(specifications, metric);
 
-        builder = new RankEvalRequestBuilder(client(), RankEvalAction.INSTANCE, new RankEvalRequest(task, new String[] { TEST_INDEX }));
+        builder = new RankEvalRequestBuilder(client(), RankEvalPlugin.ACTION, new RankEvalRequest(task, new String[] { TEST_INDEX }));
 
-        response = client().execute(RankEvalAction.INSTANCE, builder.request()).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, builder.request()).actionGet();
         // limiting to top 3 results, the amsterdam_query has no relevant document in it
         // the reciprocal rank for the berlin_query is 1/1
         // dividing by 2 to get the average
@@ -243,12 +243,12 @@ public class RankEvalRequestIT extends ESIntegTestCase {
 
         RankEvalRequestBuilder builder = new RankEvalRequestBuilder(
             client(),
-            RankEvalAction.INSTANCE,
+            RankEvalPlugin.ACTION,
             new RankEvalRequest(task, new String[] { TEST_INDEX })
         );
         builder.setRankEvalSpec(task);
 
-        RankEvalResponse response = client().execute(RankEvalAction.INSTANCE, builder.request()).actionGet();
+        RankEvalResponse response = client().execute(RankEvalPlugin.ACTION, builder.request()).actionGet();
         assertEquals(1, response.getFailures().size());
         ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(response.getFailures().get("broken_query"));
         assertEquals("java.lang.NumberFormatException: For input string: \"noStringOnNumericFields\"", rootCauses[0].getCause().toString());
@@ -268,7 +268,7 @@ public class RankEvalRequestIT extends ESIntegTestCase {
         RankEvalRequest request = new RankEvalRequest(task, new String[] { TEST_INDEX, "test2" });
         request.setRankEvalSpec(task);
 
-        RankEvalResponse response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        RankEvalResponse response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         Detail details = (PrecisionAtK.Detail) response.getPartialResults().get("amsterdam_query").getMetricDetails();
         assertEquals(7, details.getRetrieved());
         assertEquals(6, details.getRelevantRetrieved());
@@ -277,7 +277,7 @@ public class RankEvalRequestIT extends ESIntegTestCase {
         assertTrue(indicesAdmin().prepareClose("test2").get().isAcknowledged());
 
         request.indicesOptions(IndicesOptions.fromParameters(null, "true", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
-        response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         details = (PrecisionAtK.Detail) response.getPartialResults().get("amsterdam_query").getMetricDetails();
         assertEquals(6, details.getRetrieved());
         assertEquals(5, details.getRelevantRetrieved());
@@ -285,37 +285,37 @@ public class RankEvalRequestIT extends ESIntegTestCase {
         // test that ignore_unavailable=false or default settings throw an IndexClosedException
         assertTrue(indicesAdmin().prepareClose("test2").get().isAcknowledged());
         request.indicesOptions(IndicesOptions.fromParameters(null, "false", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
-        response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         assertEquals(1, response.getFailures().size());
         assertThat(response.getFailures().get("amsterdam_query"), instanceOf(IndexClosedException.class));
 
         // test expand_wildcards
         request = new RankEvalRequest(task, new String[] { "tes*" });
         request.indicesOptions(IndicesOptions.fromParameters("none", "true", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
-        response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         details = (PrecisionAtK.Detail) response.getPartialResults().get("amsterdam_query").getMetricDetails();
         assertEquals(0, details.getRetrieved());
 
         request.indicesOptions(IndicesOptions.fromParameters("open", null, null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
-        response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         details = (PrecisionAtK.Detail) response.getPartialResults().get("amsterdam_query").getMetricDetails();
         assertEquals(6, details.getRetrieved());
         assertEquals(5, details.getRelevantRetrieved());
 
         request.indicesOptions(IndicesOptions.fromParameters("closed", null, null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
-        response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         assertEquals(1, response.getFailures().size());
         assertThat(response.getFailures().get("amsterdam_query"), instanceOf(IndexClosedException.class));
 
         // test allow_no_indices
         request = new RankEvalRequest(task, new String[] { "bad*" });
         request.indicesOptions(IndicesOptions.fromParameters(null, null, "true", "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
-        response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         details = (PrecisionAtK.Detail) response.getPartialResults().get("amsterdam_query").getMetricDetails();
         assertEquals(0, details.getRetrieved());
 
         request.indicesOptions(IndicesOptions.fromParameters(null, null, "false", "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
-        response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
+        response = client().execute(RankEvalPlugin.ACTION, request).actionGet();
         assertEquals(1, response.getFailures().size());
         assertThat(response.getFailures().get("amsterdam_query"), instanceOf(IndexNotFoundException.class));
     }

+ 0 - 24
modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalAction.java

@@ -1,24 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.index.rankeval;
-
-import org.elasticsearch.action.ActionType;
-
-/**
- * ActionType for explaining evaluating search ranking results.
- */
-public class RankEvalAction extends ActionType<RankEvalResponse> {
-
-    public static final RankEvalAction INSTANCE = new RankEvalAction();
-    public static final String NAME = "indices:data/read/rank_eval";
-
-    private RankEvalAction() {
-        super(NAME, RankEvalResponse::new);
-    }
-}

+ 4 - 1
modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalPlugin.java

@@ -10,6 +10,7 @@ package org.elasticsearch.index.rankeval;
 
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.ActionType;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
 import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
@@ -31,9 +32,11 @@ import java.util.function.Supplier;
 
 public class RankEvalPlugin extends Plugin implements ActionPlugin {
 
+    public static final ActionType<RankEvalResponse> ACTION = new ActionType<>("indices:data/read/rank_eval", RankEvalResponse::new);
+
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
-        return Arrays.asList(new ActionHandler<>(RankEvalAction.INSTANCE, TransportRankEvalAction.class));
+        return Arrays.asList(new ActionHandler<>(ACTION, TransportRankEvalAction.class));
     }
 
     @Override

+ 1 - 1
modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RestRankEvalAction.java

@@ -99,7 +99,7 @@ public class RestRankEvalAction extends BaseRestHandler {
             parseRankEvalRequest(rankEvalRequest, request, parser);
         }
         return channel -> client.executeLocally(
-            RankEvalAction.INSTANCE,
+            RankEvalPlugin.ACTION,
             rankEvalRequest,
             new RestToXContentListener<RankEvalResponse>(channel)
         );

+ 1 - 1
modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java

@@ -70,7 +70,7 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
         ScriptService scriptService,
         NamedXContentRegistry namedXContentRegistry
     ) {
-        super(RankEvalAction.NAME, transportService, actionFilters, RankEvalRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
+        super(RankEvalPlugin.ACTION.name(), transportService, actionFilters, RankEvalRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE);
         this.scriptService = scriptService;
         this.namedXContentRegistry = namedXContentRegistry;
         this.client = client;

+ 1 - 2
modules/reindex/src/internalClusterTest/java/org/elasticsearch/client/documentation/ReindexDocumentationIT.java

@@ -29,7 +29,6 @@ import org.elasticsearch.index.shard.ShardId;
 import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.reindex.CancelTests;
 import org.elasticsearch.reindex.ReindexPlugin;
-import org.elasticsearch.reindex.RethrottleAction;
 import org.elasticsearch.reindex.RethrottleRequestBuilder;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.script.ScriptType;
@@ -222,7 +221,7 @@ public class ReindexDocumentationIT extends ESIntegTestCase {
         }
         {
             // tag::update-by-query-rethrottle
-            new RethrottleRequestBuilder(client, RethrottleAction.INSTANCE)
+            new RethrottleRequestBuilder(client, ReindexPlugin.RETHROTTLE_ACTION)
                 .setTargetTaskId(taskId)
                 .setRequestsPerSecond(2.0f)
                 .get();

+ 8 - 1
modules/reindex/src/main/java/org/elasticsearch/reindex/ReindexPlugin.java

@@ -10,6 +10,8 @@ package org.elasticsearch.reindex;
 
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.ActionType;
+import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
 import org.elasticsearch.client.internal.Client;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -52,13 +54,18 @@ import static java.util.Collections.singletonList;
 public class ReindexPlugin extends Plugin implements ActionPlugin {
     public static final String NAME = "reindex";
 
+    public static final ActionType<ListTasksResponse> RETHROTTLE_ACTION = new ActionType<>(
+        "cluster:admin/reindex/rethrottle",
+        ListTasksResponse::new
+    );
+
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
         return Arrays.asList(
             new ActionHandler<>(ReindexAction.INSTANCE, TransportReindexAction.class),
             new ActionHandler<>(UpdateByQueryAction.INSTANCE, TransportUpdateByQueryAction.class),
             new ActionHandler<>(DeleteByQueryAction.INSTANCE, TransportDeleteByQueryAction.class),
-            new ActionHandler<>(RethrottleAction.INSTANCE, TransportRethrottleAction.class)
+            new ActionHandler<>(RETHROTTLE_ACTION, TransportRethrottleAction.class)
         );
     }
 

+ 1 - 1
modules/reindex/src/main/java/org/elasticsearch/reindex/RestRethrottleAction.java

@@ -55,7 +55,7 @@ public class RestRethrottleAction extends BaseRestHandler {
         internalRequest.setRequestsPerSecond(requestsPerSecond);
         final String groupBy = request.param("group_by", "nodes");
         return channel -> client.execute(
-            RethrottleAction.INSTANCE,
+            ReindexPlugin.RETHROTTLE_ACTION,
             internalRequest,
             listTasksResponseListener(nodesInCluster, groupBy, channel)
         );

+ 0 - 21
modules/reindex/src/main/java/org/elasticsearch/reindex/RethrottleAction.java

@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.reindex;
-
-import org.elasticsearch.action.ActionType;
-import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
-
-public class RethrottleAction extends ActionType<ListTasksResponse> {
-    public static final RethrottleAction INSTANCE = new RethrottleAction();
-    public static final String NAME = "cluster:admin/reindex/rethrottle";
-
-    private RethrottleAction() {
-        super(NAME, ListTasksResponse::new);
-    }
-}

+ 2 - 2
modules/reindex/src/main/java/org/elasticsearch/reindex/TransportRethrottleAction.java

@@ -39,7 +39,7 @@ public class TransportRethrottleAction extends TransportTasksAction<BulkByScroll
         Client client
     ) {
         super(
-            RethrottleAction.NAME,
+            ReindexPlugin.RETHROTTLE_ACTION.name(),
             clusterService,
             transportService,
             actionFilters,
@@ -101,7 +101,7 @@ public class TransportRethrottleAction extends TransportTasksAction<BulkByScroll
             subRequest.setRequestsPerSecond(newRequestsPerSecond / runningSubtasks);
             subRequest.setTargetParentTaskId(new TaskId(localNodeId, task.getId()));
             logger.debug("rethrottling children of task [{}] to [{}] requests per second", task.getId(), subRequest.getRequestsPerSecond());
-            client.execute(RethrottleAction.INSTANCE, subRequest, ActionListener.wrap(r -> {
+            client.execute(ReindexPlugin.RETHROTTLE_ACTION, subRequest, ActionListener.wrap(r -> {
                 r.rethrowFailures("Rethrottle");
                 listener.onResponse(task.taskInfoGivenSubtaskInfo(localNodeId, r.getTasks()));
             }, listener::onFailure));

+ 1 - 1
modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexTestCase.java

@@ -50,7 +50,7 @@ public abstract class ReindexTestCase extends ESIntegTestCase {
     }
 
     protected RethrottleRequestBuilder rethrottle() {
-        return new RethrottleRequestBuilder(client(), RethrottleAction.INSTANCE);
+        return new RethrottleRequestBuilder(client(), ReindexPlugin.RETHROTTLE_ACTION);
     }
 
     public static BulkIndexByScrollResponseMatcher matcher() {

+ 1 - 1
modules/reindex/src/test/java/org/elasticsearch/reindex/TransportRethrottleActionTests.java

@@ -73,7 +73,7 @@ public class TransportRethrottleActionTests extends ESTestCase {
         @SuppressWarnings({ "unchecked", "rawtypes" }) // Magical generics incantation.....
         ArgumentCaptor<ActionListener<ListTasksResponse>> subListener = ArgumentCaptor.forClass((Class) ActionListener.class);
         if (runningSlices > 0) {
-            verify(client).execute(eq(RethrottleAction.INSTANCE), subRequest.capture(), subListener.capture());
+            verify(client).execute(eq(ReindexPlugin.RETHROTTLE_ACTION), subRequest.capture(), subListener.capture());
 
             assertEquals(new TaskId(localNodeId, task.getId()), subRequest.getValue().getTargetParentTaskId());
             assertEquals(newRequestsPerSecond / runningSlices, subRequest.getValue().getRequestsPerSecond(), 0.00001f);

+ 0 - 22
modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainAction.java

@@ -1,22 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.rest.root;
-
-import org.elasticsearch.action.ActionType;
-import org.elasticsearch.common.io.stream.Writeable;
-
-public class MainAction extends ActionType<MainResponse> {
-
-    public static final String NAME = "cluster:monitor/main";
-    public static final MainAction INSTANCE = new MainAction();
-
-    public MainAction() {
-        super(NAME, Writeable.Reader.localOnly());
-    }
-}

+ 5 - 1
modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainRestPlugin.java

@@ -10,6 +10,7 @@ package org.elasticsearch.rest.root;
 
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.ActionType;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
 import org.elasticsearch.common.settings.ClusterSettings;
@@ -25,6 +26,9 @@ import java.util.List;
 import java.util.function.Supplier;
 
 public class MainRestPlugin extends Plugin implements ActionPlugin {
+
+    public static final ActionType<MainResponse> MAIN_ACTION = ActionType.localOnly("cluster:monitor/main");
+
     @Override
     public List<RestHandler> getRestHandlers(
         Settings settings,
@@ -40,6 +44,6 @@ public class MainRestPlugin extends Plugin implements ActionPlugin {
 
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
-        return List.of(new ActionHandler<>(MainAction.INSTANCE, TransportMainAction.class));
+        return List.of(new ActionHandler<>(MAIN_ACTION, TransportMainAction.class));
     }
 }

+ 1 - 1
modules/rest-root/src/main/java/org/elasticsearch/rest/root/RestMainAction.java

@@ -39,7 +39,7 @@ public class RestMainAction extends BaseRestHandler {
 
     @Override
     public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
-        return channel -> client.execute(MainAction.INSTANCE, new MainRequest(), new RestBuilderListener<MainResponse>(channel) {
+        return channel -> client.execute(MainRestPlugin.MAIN_ACTION, new MainRequest(), new RestBuilderListener<MainResponse>(channel) {
             @Override
             public RestResponse buildResponse(MainResponse mainResponse, XContentBuilder builder) throws Exception {
                 return convertMainResponse(mainResponse, request, builder);

+ 1 - 1
modules/rest-root/src/main/java/org/elasticsearch/rest/root/TransportMainAction.java

@@ -33,7 +33,7 @@ public class TransportMainAction extends TransportAction<MainRequest, MainRespon
         ActionFilters actionFilters,
         ClusterService clusterService
     ) {
-        super(MainAction.NAME, actionFilters, transportService.getTaskManager());
+        super(MainRestPlugin.MAIN_ACTION.name(), actionFilters, transportService.getTaskManager());
         this.nodeName = Node.NODE_NAME_SETTING.get(settings);
         this.clusterService = clusterService;
     }

+ 1 - 1
server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java

@@ -65,7 +65,7 @@ public class TaskStorageRetryIT extends ESSingleNodeTestCase {
             TestTaskPlugin.NodesRequest req = new TestTaskPlugin.NodesRequest("foo");
             req.setShouldStoreResult(true);
             req.setShouldBlock(false);
-            task = nodeClient().executeLocally(TestTaskPlugin.TestTaskAction.INSTANCE, req, future);
+            task = nodeClient().executeLocally(TestTaskPlugin.TEST_TASK_ACTION, req, future);
 
             logger.info("verify that the task has started and is still running");
             assertBusy(() -> {

+ 30 - 34
server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java

@@ -76,6 +76,8 @@ import java.util.stream.Collectors;
 
 import static java.util.Collections.emptyList;
 import static java.util.Collections.singleton;
+import static org.elasticsearch.action.admin.cluster.node.tasks.TestTaskPlugin.TEST_TASK_ACTION;
+import static org.elasticsearch.action.admin.cluster.node.tasks.TestTaskPlugin.UNBLOCK_TASK_ACTION;
 import static org.elasticsearch.core.TimeValue.timeValueMillis;
 import static org.elasticsearch.core.TimeValue.timeValueSeconds;
 import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_HEADER_SIZE;
@@ -498,7 +500,7 @@ public class TasksIT extends ESIntegTestCase {
         // Start blocking test task
         // Get real client (the plugin is not registered on transport nodes)
         TestTaskPlugin.NodesRequest request = new TestTaskPlugin.NodesRequest("test");
-        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TestTaskPlugin.TestTaskAction.INSTANCE, request);
+        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TEST_TASK_ACTION, request);
 
         logger.info("--> started test tasks");
 
@@ -506,54 +508,51 @@ public class TasksIT extends ESIntegTestCase {
         assertBusy(
             () -> assertEquals(
                 internalCluster().size(),
-                clusterAdmin().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME + "[n]").get().getTasks().size()
+                clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name() + "[n]").get().getTasks().size()
             )
         );
 
         logger.info("--> cancelling the main test task");
-        CancelTasksResponse cancelTasksResponse = clusterAdmin().prepareCancelTasks().setActions(TestTaskPlugin.TestTaskAction.NAME).get();
+        CancelTasksResponse cancelTasksResponse = clusterAdmin().prepareCancelTasks().setActions(TEST_TASK_ACTION.name()).get();
         assertEquals(1, cancelTasksResponse.getTasks().size());
 
         expectThrows(TaskCancelledException.class, future::actionGet);
 
         logger.info("--> checking that test tasks are not running");
-        assertEquals(0, clusterAdmin().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME + "*").get().getTasks().size());
+        assertEquals(0, clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name() + "*").get().getTasks().size());
     }
 
     @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/95325")
     public void testTasksUnblocking() throws Exception {
         // Start blocking test task
         TestTaskPlugin.NodesRequest request = new TestTaskPlugin.NodesRequest("test");
-        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TestTaskPlugin.TestTaskAction.INSTANCE, request);
+        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TEST_TASK_ACTION, request);
         // Wait for the task to start on all nodes
         assertBusy(
             () -> assertEquals(
                 internalCluster().size(),
-                clusterAdmin().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME + "[n]").get().getTasks().size()
+                clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name() + "[n]").get().getTasks().size()
             )
         );
 
-        new TestTaskPlugin.UnblockTestTasksRequestBuilder(client(), TestTaskPlugin.UnblockTestTasksAction.INSTANCE).get();
+        new TestTaskPlugin.UnblockTestTasksRequestBuilder(client(), UNBLOCK_TASK_ACTION).get();
 
         future.get();
         assertBusy(
-            () -> assertEquals(
-                0,
-                clusterAdmin().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME + "[n]").get().getTasks().size()
-            )
+            () -> assertEquals(0, clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name() + "[n]").get().getTasks().size())
         );
     }
 
     public void testListTasksWaitForCompletion() throws Exception {
         waitForCompletionTestCase(
             randomBoolean(),
-            id -> clusterAdmin().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME).setWaitForCompletion(true).execute(),
+            id -> clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name()).setWaitForCompletion(true).execute(),
             response -> {
                 assertThat(response.getNodeFailures(), empty());
                 assertThat(response.getTaskFailures(), empty());
                 assertThat(response.getTasks(), hasSize(1));
                 TaskInfo task = response.getTasks().get(0);
-                assertEquals(TestTaskPlugin.TestTaskAction.NAME, task.action());
+                assertEquals(TEST_TASK_ACTION.name(), task.action());
             }
         );
     }
@@ -565,7 +564,7 @@ public class TasksIT extends ESIntegTestCase {
             assertNull(response.getTask().getResponse());
             // But the task's details should still be there because we grabbed a reference to the task before waiting for it to complete
             assertNotNull(response.getTask().getTask());
-            assertEquals(TestTaskPlugin.TestTaskAction.NAME, response.getTask().getTask().action());
+            assertEquals(TEST_TASK_ACTION.name(), response.getTask().getTask().action());
         });
     }
 
@@ -576,7 +575,7 @@ public class TasksIT extends ESIntegTestCase {
             assertEquals(0, response.getTask().getResponseAsMap().get("failure_count"));
             // The task's details should also be there
             assertNotNull(response.getTask().getTask());
-            assertEquals(TestTaskPlugin.TestTaskAction.NAME, response.getTask().getTask().action());
+            assertEquals(TEST_TASK_ACTION.name(), response.getTask().getTask().action());
         });
     }
 
@@ -591,7 +590,7 @@ public class TasksIT extends ESIntegTestCase {
         // Start blocking test task
         TestTaskPlugin.NodesRequest request = new TestTaskPlugin.NodesRequest("test");
         request.setShouldStoreResult(storeResult);
-        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TestTaskPlugin.TestTaskAction.INSTANCE, request);
+        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TEST_TASK_ACTION, request);
 
         ActionFuture<T> waitResponseFuture;
         TaskId taskId;
@@ -627,7 +626,7 @@ public class TasksIT extends ESIntegTestCase {
             waitForWaitingToStart.await();
         } finally {
             // Unblock the request so the wait for completion request can finish
-            new TestTaskPlugin.UnblockTestTasksRequestBuilder(client(), TestTaskPlugin.UnblockTestTasksAction.INSTANCE).get();
+            new TestTaskPlugin.UnblockTestTasksRequestBuilder(client(), UNBLOCK_TASK_ACTION).get();
         }
 
         // Now that the task is unblocked the list response will come back
@@ -641,7 +640,7 @@ public class TasksIT extends ESIntegTestCase {
     public void testListTasksWaitForTimeout() throws Exception {
         waitForTimeoutTestCase(id -> {
             ListTasksResponse response = clusterAdmin().prepareListTasks()
-                .setActions(TestTaskPlugin.TestTaskAction.NAME)
+                .setActions(TEST_TASK_ACTION.name())
                 .setWaitForCompletion(true)
                 .setTimeout(timeValueMillis(100))
                 .get();
@@ -667,7 +666,7 @@ public class TasksIT extends ESIntegTestCase {
     private void waitForTimeoutTestCase(Function<TaskId, ? extends Iterable<? extends Throwable>> wait) throws Exception {
         // Start blocking test task
         TestTaskPlugin.NodesRequest request = new TestTaskPlugin.NodesRequest("test");
-        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TestTaskPlugin.TestTaskAction.INSTANCE, request);
+        ActionFuture<TestTaskPlugin.NodesResponse> future = client().execute(TEST_TASK_ACTION, request);
         try {
             TaskId taskId = waitForTestTaskStartOnAllNodes();
 
@@ -685,7 +684,7 @@ public class TasksIT extends ESIntegTestCase {
             }
         } finally {
             // Now we can unblock those requests
-            new TestTaskPlugin.UnblockTestTasksRequestBuilder(client(), TestTaskPlugin.UnblockTestTasksAction.INSTANCE).get();
+            new TestTaskPlugin.UnblockTestTasksRequestBuilder(client(), UNBLOCK_TASK_ACTION).get();
         }
         future.get();
     }
@@ -695,13 +694,10 @@ public class TasksIT extends ESIntegTestCase {
      */
     private TaskId waitForTestTaskStartOnAllNodes() throws Exception {
         assertBusy(() -> {
-            List<TaskInfo> tasks = clusterAdmin().prepareListTasks()
-                .setActions(TestTaskPlugin.TestTaskAction.NAME + "[n]")
-                .get()
-                .getTasks();
+            List<TaskInfo> tasks = clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name() + "[n]").get().getTasks();
             assertEquals(internalCluster().size(), tasks.size());
         });
-        List<TaskInfo> task = clusterAdmin().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME).get().getTasks();
+        List<TaskInfo> task = clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name()).get().getTasks();
         assertThat(task, hasSize(1));
         return task.get(0).taskId();
     }
@@ -709,7 +705,7 @@ public class TasksIT extends ESIntegTestCase {
     public void testTasksListWaitForNoTask() throws Exception {
         // Spin up a request to wait for no matching tasks
         ActionFuture<ListTasksResponse> waitResponseFuture = clusterAdmin().prepareListTasks()
-            .setActions(TestTaskPlugin.TestTaskAction.NAME + "[n]")
+            .setActions(TEST_TASK_ACTION.name() + "[n]")
             .setWaitForCompletion(true)
             .setTimeout(timeValueMillis(10))
             .execute();
@@ -753,7 +749,7 @@ public class TasksIT extends ESIntegTestCase {
     }
 
     public void testTaskStoringSuccessfulResult() throws Exception {
-        registerTaskManagerListeners(TestTaskPlugin.TestTaskAction.NAME);  // we need this to get task id of the process
+        registerTaskManagerListeners(TEST_TASK_ACTION.name());  // we need this to get task id of the process
 
         // Start non-blocking test task
         TestTaskPlugin.NodesRequest request = new TestTaskPlugin.NodesRequest("test");
@@ -762,9 +758,9 @@ public class TasksIT extends ESIntegTestCase {
         TaskId parentTaskId = new TaskId("parent_node", randomLong());
         request.setParentTask(parentTaskId);
 
-        client().execute(TestTaskPlugin.TestTaskAction.INSTANCE, request).get();
+        client().execute(TEST_TASK_ACTION, request).get();
 
-        List<TaskInfo> events = findEvents(TestTaskPlugin.TestTaskAction.NAME, Tuple::v1);
+        List<TaskInfo> events = findEvents(TEST_TASK_ACTION.name(), Tuple::v1);
 
         assertEquals(1, events.size());
         TaskInfo taskInfo = events.get(0);
@@ -803,15 +799,15 @@ public class TasksIT extends ESIntegTestCase {
         assertNull(getResponse.getTask().getError());
 
         // run it again to check that the tasks index has been successfully created and can be re-used
-        client().execute(TestTaskPlugin.TestTaskAction.INSTANCE, request).get();
+        client().execute(TEST_TASK_ACTION, request).get();
 
-        events = findEvents(TestTaskPlugin.TestTaskAction.NAME, Tuple::v1);
+        events = findEvents(TEST_TASK_ACTION.name(), Tuple::v1);
 
         assertEquals(2, events.size());
     }
 
     public void testTaskStoringFailureResult() throws Exception {
-        registerTaskManagerListeners(TestTaskPlugin.TestTaskAction.NAME);  // we need this to get task id of the process
+        registerTaskManagerListeners(TEST_TASK_ACTION.name());  // we need this to get task id of the process
 
         TestTaskPlugin.NodesRequest request = new TestTaskPlugin.NodesRequest("test");
         request.setShouldFail(true);
@@ -819,9 +815,9 @@ public class TasksIT extends ESIntegTestCase {
         request.setShouldBlock(false);
 
         // Start non-blocking test task that should fail
-        assertFutureThrows(client().execute(TestTaskPlugin.TestTaskAction.INSTANCE, request), IllegalStateException.class);
+        assertFutureThrows(client().execute(TEST_TASK_ACTION, request), IllegalStateException.class);
 
-        List<TaskInfo> events = findEvents(TestTaskPlugin.TestTaskAction.NAME, Tuple::v1);
+        List<TaskInfo> events = findEvents(TEST_TASK_ACTION.name(), Tuple::v1);
         assertEquals(1, events.size());
         TaskInfo failedTaskInfo = events.get(0);
         TaskId failedTaskId = failedTaskInfo.taskId();

+ 2 - 2
server/src/main/java/org/elasticsearch/action/ActionType.java

@@ -39,7 +39,7 @@ public class ActionType<Response extends ActionResponse> {
     }
 
     /**
-     * Get a reader that can create a new instance of the class from a {@link org.elasticsearch.common.io.stream.StreamInput}
+     * Get a reader that can read a response from a {@link org.elasticsearch.common.io.stream.StreamInput}.
      */
     public Writeable.Reader<Response> getResponseReader() {
         return responseReader;
@@ -47,7 +47,7 @@ public class ActionType<Response extends ActionResponse> {
 
     @Override
     public boolean equals(Object o) {
-        return o instanceof ActionType && name.equals(((ActionType<?>) o).name());
+        return o instanceof ActionType<?> actionType && name.equals(actionType.name);
     }
 
     @Override

+ 1 - 6
server/src/test/java/org/elasticsearch/action/ActionModuleTests.java

@@ -91,12 +91,7 @@ public class ActionModuleTests extends ESTestCase {
             @Override
             protected void doExecute(Task task, FakeRequest request, ActionListener<ActionResponse> listener) {}
         }
-        class FakeAction extends ActionType<ActionResponse> {
-            protected FakeAction() {
-                super("fake", null);
-            }
-        }
-        FakeAction action = new FakeAction();
+        final var action = new ActionType<>("fake", null);
         ActionPlugin registersFakeAction = new ActionPlugin() {
             @Override
             public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {

+ 3 - 8
server/src/test/java/org/elasticsearch/action/ActionTests.java

@@ -13,14 +13,9 @@ import org.elasticsearch.test.ESTestCase;
 public class ActionTests extends ESTestCase {
 
     public void testEquals() {
-        class FakeAction extends ActionType<ActionResponse> {
-            protected FakeAction(String name) {
-                super(name, null);
-            }
-        }
-        FakeAction fakeAction1 = new FakeAction("a");
-        FakeAction fakeAction2 = new FakeAction("a");
-        FakeAction fakeAction3 = new FakeAction("b");
+        final var fakeAction1 = ActionType.localOnly("a");
+        final var fakeAction2 = ActionType.localOnly("a");
+        final var fakeAction3 = ActionType.localOnly("b");
         String s = "Some random other object";
         assertEquals(fakeAction1, fakeAction1);
         assertEquals(fakeAction2, fakeAction2);

+ 10 - 24
server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java

@@ -73,11 +73,17 @@ public class TestTaskPlugin extends Plugin implements ActionPlugin, NetworkPlugi
 
     private static final Logger logger = LogManager.getLogger(TestTaskPlugin.class);
 
+    public static final ActionType<NodesResponse> TEST_TASK_ACTION = ActionType.localOnly("cluster:admin/tasks/test");
+    public static final ActionType<UnblockTestTasksResponse> UNBLOCK_TASK_ACTION = new ActionType<>(
+        "cluster:admin/tasks/testunblock",
+        UnblockTestTasksResponse::new
+    );
+
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
         return Arrays.asList(
-            new ActionHandler<>(TestTaskAction.INSTANCE, TransportTestTaskAction.class),
-            new ActionHandler<>(UnblockTestTasksAction.INSTANCE, TransportUnblockTestTasksAction.class)
+            new ActionHandler<>(TEST_TASK_ACTION, TransportTestTaskAction.class),
+            new ActionHandler<>(UNBLOCK_TASK_ACTION, TransportUnblockTestTasksAction.class)
         );
     }
 
@@ -262,7 +268,7 @@ public class TestTaskPlugin extends Plugin implements ActionPlugin, NetworkPlugi
         @Inject
         public TransportTestTaskAction(ThreadPool threadPool, ClusterService clusterService, TransportService transportService) {
             super(
-                TestTaskAction.NAME,
+                TEST_TASK_ACTION.name(),
                 clusterService,
                 transportService,
                 new ActionFilters(new HashSet<>()),
@@ -314,16 +320,6 @@ public class TestTaskPlugin extends Plugin implements ActionPlugin, NetworkPlugi
         }
     }
 
-    public static class TestTaskAction extends ActionType<NodesResponse> {
-
-        public static final TestTaskAction INSTANCE = new TestTaskAction();
-        public static final String NAME = "cluster:admin/tasks/test";
-
-        private TestTaskAction() {
-            super(NAME, NodesResponse::new);
-        }
-    }
-
     public static class UnblockTestTaskResponse implements Writeable {
 
         UnblockTestTaskResponse() {
@@ -395,7 +391,7 @@ public class TestTaskPlugin extends Plugin implements ActionPlugin, NetworkPlugi
         @Inject
         public TransportUnblockTestTasksAction(ClusterService clusterService, TransportService transportService) {
             super(
-                UnblockTestTasksAction.NAME,
+                UNBLOCK_TASK_ACTION.name(),
                 clusterService,
                 transportService,
                 new ActionFilters(new HashSet<>()),
@@ -429,16 +425,6 @@ public class TestTaskPlugin extends Plugin implements ActionPlugin, NetworkPlugi
 
     }
 
-    public static class UnblockTestTasksAction extends ActionType<UnblockTestTasksResponse> {
-
-        public static final UnblockTestTasksAction INSTANCE = new UnblockTestTasksAction();
-        public static final String NAME = "cluster:admin/tasks/testunblock";
-
-        private UnblockTestTasksAction() {
-            super(NAME, UnblockTestTasksResponse::new);
-        }
-    }
-
     public static class UnblockTestTasksRequestBuilder extends ActionRequestBuilder<UnblockTestTasksRequest, UnblockTestTasksResponse> {
 
         protected UnblockTestTasksRequestBuilder(ElasticsearchClient client, ActionType<UnblockTestTasksResponse> action) {

+ 6 - 8
server/src/test/java/org/elasticsearch/indices/settings/InternalOrPrivateSettingsPlugin.java

@@ -59,14 +59,12 @@ public class InternalOrPrivateSettingsPlugin extends Plugin implements ActionPlu
         return Arrays.asList(INDEX_INTERNAL_SETTING, INDEX_PRIVATE_SETTING);
     }
 
-    public static class UpdateInternalOrPrivateAction extends ActionType<UpdateInternalOrPrivateAction.Response> {
+    public static class UpdateInternalOrPrivateAction {
 
-        public static final UpdateInternalOrPrivateAction INSTANCE = new UpdateInternalOrPrivateAction();
-        private static final String NAME = "indices:admin/settings/update-internal-or-private-index";
-
-        public UpdateInternalOrPrivateAction() {
-            super(NAME, UpdateInternalOrPrivateAction.Response::new);
-        }
+        public static final ActionType<Response> INSTANCE = new ActionType<>(
+            "indices:admin/settings/update-internal-or-private-index",
+            UpdateInternalOrPrivateAction.Response::new
+        );
 
         public static class Request extends MasterNodeRequest<Request> {
 
@@ -130,7 +128,7 @@ public class InternalOrPrivateSettingsPlugin extends Plugin implements ActionPlu
             final IndexNameExpressionResolver indexNameExpressionResolver
         ) {
             super(
-                UpdateInternalOrPrivateAction.NAME,
+                UpdateInternalOrPrivateAction.INSTANCE.name(),
                 transportService,
                 clusterService,
                 threadPool,

+ 9 - 16
server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java

@@ -76,9 +76,14 @@ import static org.junit.Assert.fail;
  */
 public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin, PersistentTaskPlugin {
 
+    public static final ActionType<TestTasksResponse> TEST_ACTION = new ActionType<>(
+        "cluster:admin/persistent/task_test",
+        TestTasksResponse::new
+    );
+
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
-        return Collections.singletonList(new ActionHandler<>(TestTaskAction.INSTANCE, TransportTestTaskAction.class));
+        return Collections.singletonList(new ActionHandler<>(TEST_ACTION, TransportTestTaskAction.class));
     }
 
     @Override
@@ -413,16 +418,6 @@ public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin, P
         }
     }
 
-    public static class TestTaskAction extends ActionType<TestTasksResponse> {
-
-        public static final TestTaskAction INSTANCE = new TestTaskAction();
-        public static final String NAME = "cluster:admin/persistent/task_test";
-
-        private TestTaskAction() {
-            super(NAME, TestTasksResponse::new);
-        }
-    }
-
     public static class TestTask extends AllocatedPersistentTask {
         private volatile String operation;
 
@@ -446,9 +441,7 @@ public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin, P
 
     static class TestTaskResponse implements Writeable {
 
-        TestTaskResponse() {
-
-        }
+        TestTaskResponse() {}
 
         TestTaskResponse(StreamInput in) throws IOException {
             in.readBoolean();
@@ -489,7 +482,7 @@ public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin, P
     public static class TestTasksRequestBuilder extends TasksRequestBuilder<TestTasksRequest, TestTasksResponse, TestTasksRequestBuilder> {
 
         protected TestTasksRequestBuilder(ElasticsearchClient client) {
-            super(client, TestTaskAction.INSTANCE, new TestTasksRequest());
+            super(client, TEST_ACTION, new TestTasksRequest());
         }
 
         public TestTasksRequestBuilder setOperation(String operation) {
@@ -536,7 +529,7 @@ public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin, P
         @Inject
         public TransportTestTaskAction(ClusterService clusterService, TransportService transportService, ActionFilters actionFilters) {
             super(
-                TestTaskAction.NAME,
+                TEST_ACTION.name(),
                 clusterService,
                 transportService,
                 actionFilters,

+ 1 - 1
test/external-modules/seek-tracking-directory/src/internalClusterTest/java/org/elasticsearch/test/seektracker/SeekTrackerPluginIT.java

@@ -47,7 +47,7 @@ public class SeekTrackerPluginIT extends ESIntegTestCase {
 
         client().prepareSearch("index").setQuery(QueryBuilders.termQuery("field", "term2")).get();
 
-        SeekStatsResponse response = client().execute(SeekStatsAction.INSTANCE, new SeekStatsRequest("index")).actionGet();
+        SeekStatsResponse response = client().execute(SeekTrackerPlugin.SEEK_STATS_ACTION, new SeekStatsRequest("index")).actionGet();
         List<ShardSeekStats> shardSeekStats = response.getSeekStats().get("index");
         assertThat(shardSeekStats.size(), greaterThan(0));
     }

+ 1 - 1
test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/RestSeekStatsAction.java

@@ -36,6 +36,6 @@ public class RestSeekStatsAction extends BaseRestHandler {
     protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {
         String[] indices = request.paramAsStringArray("index", Strings.EMPTY_ARRAY);
         SeekStatsRequest seekStatsRequest = new SeekStatsRequest(indices);
-        return channel -> client.execute(SeekStatsAction.INSTANCE, seekStatsRequest, new RestToXContentListener<>(channel));
+        return channel -> client.execute(SeekTrackerPlugin.SEEK_STATS_ACTION, seekStatsRequest, new RestToXContentListener<>(channel));
     }
 }

+ 0 - 22
test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekStatsAction.java

@@ -1,22 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.test.seektracker;
-
-import org.elasticsearch.action.ActionType;
-import org.elasticsearch.common.io.stream.Writeable;
-
-public class SeekStatsAction extends ActionType<SeekStatsResponse> {
-
-    public static final SeekStatsAction INSTANCE = new SeekStatsAction();
-    public static final String NAME = "cluster:monitor/seek_stats";
-
-    public SeekStatsAction() {
-        super(NAME, Writeable.Reader.localOnly());
-    }
-}

+ 4 - 1
test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekTrackerPlugin.java

@@ -10,6 +10,7 @@ package org.elasticsearch.test.seektracker;
 
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.ActionType;
 import org.elasticsearch.client.internal.Client;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -50,6 +51,8 @@ public class SeekTrackerPlugin extends Plugin implements ActionPlugin {
         Setting.Property.NodeScope
     );
 
+    public static final ActionType<SeekStatsResponse> SEEK_STATS_ACTION = ActionType.localOnly("cluster:monitor/seek_stats");
+
     private final SeekStatsService seekStatsService = new SeekStatsService();
     private final boolean enabled;
 
@@ -112,7 +115,7 @@ public class SeekTrackerPlugin extends Plugin implements ActionPlugin {
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
         if (enabled) {
-            return Collections.singletonList(new ActionHandler<>(SeekStatsAction.INSTANCE, TransportSeekStatsAction.class));
+            return Collections.singletonList(new ActionHandler<>(SEEK_STATS_ACTION, TransportSeekStatsAction.class));
         } else {
             return Collections.emptyList();
         }

+ 1 - 1
test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/TransportSeekStatsAction.java

@@ -37,7 +37,7 @@ public class TransportSeekStatsAction extends TransportNodesAction<SeekStatsRequ
         SeekStatsService seekStatsService
     ) {
         super(
-            SeekStatsAction.NAME,
+            SeekTrackerPlugin.SEEK_STATS_ACTION.name(),
             clusterService,
             transportService,
             actionFilters,

+ 2 - 2
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

@@ -65,7 +65,7 @@ import org.elasticsearch.cluster.metadata.Metadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.util.set.Sets;
 import org.elasticsearch.index.IndexVersion;
-import org.elasticsearch.rest.root.MainAction;
+import org.elasticsearch.rest.root.MainRestPlugin;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.transport.TransportRequest;
 import org.elasticsearch.xpack.core.XPackPlugin;
@@ -1489,7 +1489,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
                 )
             )
         );
-        assertThat(monitoringUserRole.cluster().check(MainAction.NAME, request, authentication), is(true));
+        assertThat(monitoringUserRole.cluster().check(MainRestPlugin.MAIN_ACTION.name(), request, authentication), is(true));
         assertThat(monitoringUserRole.cluster().check(XPackInfoAction.NAME, request, authentication), is(true));
         assertThat(monitoringUserRole.cluster().check(TransportRemoteInfoAction.TYPE.name(), request, authentication), is(true));
         assertThat(monitoringUserRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false));