diff --git a/docs/build.gradle b/docs/build.gradle index da3d83378e894..ddd2a38b5160b 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -111,6 +111,7 @@ testClusters.matching { it.name == "yamlRestTest"}.configureEach { systemProperty 'es.transport.cname_in_publish_address', 'true' requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0") + requiresFeature 'es.failure_store_feature_flag_enabled', Version.fromString("8.12.0") extraConfigFile 'op-jwks.json', project(':x-pack:test:idp-fixture').file("oidc/op-jwks.json") extraConfigFile 'idp-docs-metadata.xml', project(':x-pack:test:idp-fixture').file("idp/shibboleth-idp/metadata/idp-docs-metadata.xml") diff --git a/docs/changelog/102078.yaml b/docs/changelog/102078.yaml new file mode 100644 index 0000000000000..d031aa0dbf6f7 --- /dev/null +++ b/docs/changelog/102078.yaml @@ -0,0 +1,5 @@ +pr: 102078 +summary: Derive expected replica size from primary +area: Allocation +type: enhancement +issues: [] diff --git a/docs/changelog/103035.yaml b/docs/changelog/103035.yaml new file mode 100644 index 0000000000000..5b1c9d6629767 --- /dev/null +++ b/docs/changelog/103035.yaml @@ -0,0 +1,5 @@ +pr: 103035 +summary: "x-pack/plugin/core: add `match_mapping_type` to `ecs@mappings` dynamic templates" +area: Data streams +type: bug +issues: [] diff --git a/docs/changelog/103176.yaml b/docs/changelog/103176.yaml new file mode 100644 index 0000000000000..a0f46c1462f62 --- /dev/null +++ b/docs/changelog/103176.yaml @@ -0,0 +1,5 @@ +pr: 103176 +summary: Validate settings in `ReloadSecureSettings` API +area: Client +type: bug +issues: [] diff --git a/docs/changelog/103251.yaml b/docs/changelog/103251.yaml new file mode 100644 index 0000000000000..0c5c6d6e4d776 --- /dev/null +++ b/docs/changelog/103251.yaml @@ -0,0 +1,5 @@ +pr: 103251 +summary: Wait for reroute before acking put-shutdown +area: Infra/Node Lifecycle +type: bug +issues: [] diff --git a/docs/reference/rest-api/common-parms.asciidoc b/docs/reference/rest-api/common-parms.asciidoc index 55f277218d210..ca8a191ad4b2c 100644 --- a/docs/reference/rest-api/common-parms.asciidoc +++ b/docs/reference/rest-api/common-parms.asciidoc @@ -611,9 +611,10 @@ The `similarity` parameter is the direct vector similarity calculation. * `l2_norm`: also known as Euclidean, will include documents where the vector is within the `dims` dimensional hypersphere with radius `similarity` with origin at `query_vector`. -* `cosine` & `dot_product`: Only return vectors where the cosine similarity or dot-product are at least the provided +* `cosine`, `dot_product`, and `max_inner_product`: Only return vectors where the cosine similarity or dot-product are at least the provided `similarity`. -- +Read more here: <> end::knn-similarity[] tag::lenient[] diff --git a/docs/reference/search/search-your-data/knn-search.asciidoc b/docs/reference/search/search-your-data/knn-search.asciidoc index ff64535c705d9..496e0cf1b9d4f 100644 --- a/docs/reference/search/search-your-data/knn-search.asciidoc +++ b/docs/reference/search/search-your-data/knn-search.asciidoc @@ -547,6 +547,7 @@ score = 0.9 * match_score + 0.1 * knn_score_image-vector + 0.5 * knn_score_title ``` [discrete] +[[knn-similarity-search]] ==== Search kNN with expected similarity While kNN is a powerful tool, it always tries to return `k` nearest neighbors. Consequently, when using `knn` with @@ -563,6 +564,18 @@ minimum similarity for a vector to be considered a match. The `knn` search flow * Do not return any vectors that are further away than the configured `similarity` -- +NOTE: `similarity` is the true <> before it has been transformed into `_score` and boost applied. + +For each configured <>, here is the corresponding inverted `_score` function. This is so if you are wanting to filter from a `_score` perspective, you can do this minor transformation to correctly reject irrelevant results. +-- + - `l2_norm`: `sqrt((1 / _score) - 1)` + - `cosine`: `(2 * _score) - 1` + - `dot_product`: `(2 * _score) - 1` + - `max_inner_product`: + - `_score < 1`: `1 - (1 / _score)` + - `_score >= 1`: `_score - 1` +-- + Here is an example. In this example we search for the given `query_vector` for `k` nearest neighbors. However, with `filter` applied and requiring that the found vectors have at least the provided `similarity` between them. [source,console] diff --git a/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/DisabledSecurityDataStreamTestCase.java b/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/DisabledSecurityDataStreamTestCase.java index c5ca8445b08eb..ae33c06b497db 100644 --- a/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/DisabledSecurityDataStreamTestCase.java +++ b/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/DisabledSecurityDataStreamTestCase.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.rest.ESRestTestCase; import org.junit.ClassRule; @@ -25,6 +26,7 @@ public abstract class DisabledSecurityDataStreamTestCase extends ESRestTestCase @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) + .feature(FeatureFlag.FAILURE_STORE_ENABLED) .setting("xpack.security.enabled", "false") .setting("xpack.watcher.enabled", "false") .build(); diff --git a/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecyclePermissionsRestIT.java b/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecyclePermissionsRestIT.java index d662427c99d13..1c6329dcf922f 100644 --- a/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecyclePermissionsRestIT.java +++ b/modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecyclePermissionsRestIT.java @@ -19,6 +19,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.cluster.util.resource.Resource; import org.elasticsearch.test.rest.ESRestTestCase; @@ -38,6 +39,7 @@ public class DataStreamLifecyclePermissionsRestIT extends ESRestTestCase { @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) + .feature(FeatureFlag.FAILURE_STORE_ENABLED) .setting("xpack.watcher.enabled", "false") .setting("xpack.ml.enabled", "false") .setting("xpack.security.enabled", "true") diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java index 4d2c2af2266b1..21b1316e5685b 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java @@ -15,8 +15,8 @@ import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ResultDeduplicator; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeAction; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse; @@ -719,7 +719,7 @@ private void deleteIndexOnce(String indexName, String reason) { transportActionsDeduplicator.executeOnce( deleteIndexRequest, new ErrorRecordingActionListener( - DeleteIndexAction.NAME, + TransportDeleteIndexAction.TYPE.name(), indexName, errorStore, Strings.format("Data stream lifecycle encountered an error trying to delete index [%s]", indexName), diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/DeleteDataStreamLifecycleAction.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/DeleteDataStreamLifecycleAction.java index baa163c1ae75e..67bfae0740fb5 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/DeleteDataStreamLifecycleAction.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/DeleteDataStreamLifecycleAction.java @@ -26,9 +26,8 @@ */ public class DeleteDataStreamLifecycleAction { - public static final ActionType INSTANCE = new ActionType<>( - "indices:admin/data_stream/lifecycle/delete", - AcknowledgedResponse::readFrom + public static final ActionType INSTANCE = ActionType.acknowledgedResponse( + "indices:admin/data_stream/lifecycle/delete" ); private DeleteDataStreamLifecycleAction() {/* no instances */} diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/PutDataStreamLifecycleAction.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/PutDataStreamLifecycleAction.java index a4f4b88d17bca..f01d06fda8101 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/PutDataStreamLifecycleAction.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/PutDataStreamLifecycleAction.java @@ -40,9 +40,8 @@ */ public class PutDataStreamLifecycleAction { - public static final ActionType INSTANCE = new ActionType<>( - "indices:admin/data_stream/lifecycle/put", - AcknowledgedResponse::readFrom + public static final ActionType INSTANCE = ActionType.acknowledgedResponse( + "indices:admin/data_stream/lifecycle/put" ); private PutDataStreamLifecycleAction() {/* no instances */} diff --git a/modules/data-streams/src/yamlRestTest/java/org/elasticsearch/datastreams/DataStreamsClientYamlTestSuiteIT.java b/modules/data-streams/src/yamlRestTest/java/org/elasticsearch/datastreams/DataStreamsClientYamlTestSuiteIT.java index fa7b4ca1a80c0..37a83deeb3550 100644 --- a/modules/data-streams/src/yamlRestTest/java/org/elasticsearch/datastreams/DataStreamsClientYamlTestSuiteIT.java +++ b/modules/data-streams/src/yamlRestTest/java/org/elasticsearch/datastreams/DataStreamsClientYamlTestSuiteIT.java @@ -19,6 +19,8 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.junit.ClassRule; +import static org.elasticsearch.test.cluster.FeatureFlag.FAILURE_STORE_ENABLED; + public class DataStreamsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { public DataStreamsClientYamlTestSuiteIT(final ClientYamlTestCandidate testCandidate) { @@ -43,6 +45,7 @@ protected Settings restClientSettings() { private static ElasticsearchCluster createCluster() { LocalClusterSpecBuilder clusterBuilder = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) + .feature(FAILURE_STORE_ENABLED) .setting("xpack.security.enabled", "true") .keystore("bootstrap.password", "x-pack-test-password") .user("x_pack_rest_user", "x-pack-test-password"); diff --git a/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/10_basic.yml b/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/10_basic.yml index b1e0cf8ed7d90..6496930764ab8 100644 --- a/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/10_basic.yml +++ b/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/10_basic.yml @@ -210,10 +210,8 @@ setup: --- "Create data stream with failure store": - skip: - version: all - reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/102873" -# version: " - 8.10.99" -# reason: "data stream failure stores only creatable in 8.11+" + version: " - 8.10.99" + reason: "data stream failure stores only creatable in 8.11+" - do: allowed_warnings: diff --git a/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/30_auto_create_data_stream.yml b/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/30_auto_create_data_stream.yml index a7d8476ee2dcf..303a584555f8f 100644 --- a/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/30_auto_create_data_stream.yml +++ b/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/30_auto_create_data_stream.yml @@ -50,10 +50,8 @@ --- "Put index template with failure store": - skip: - version: all - reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/102873" -# version: " - 8.10.99" -# reason: "data stream failure stores only creatable in 8.11+" + version: " - 8.10.99" + reason: "data stream failure stores only creatable in 8.11+" features: allowed_warnings - do: diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java index 36f317474f5a9..f11144d698242 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java @@ -14,8 +14,8 @@ import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.admin.indices.flush.TransportShardFlushAction; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeAction; @@ -502,14 +502,14 @@ public void testCloseIndex() { } public void testDeleteIndex() { - interceptTransportActions(DeleteIndexAction.NAME); + interceptTransportActions(TransportDeleteIndexAction.TYPE.name()); String[] randomIndicesOrAliases = randomUniqueIndices(); DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(randomIndicesOrAliases); assertAcked(internalCluster().coordOnlyNodeClient().admin().indices().delete(deleteIndexRequest).actionGet()); clearInterceptedActions(); - assertSameIndices(deleteIndexRequest, DeleteIndexAction.NAME); + assertSameIndices(deleteIndexRequest, TransportDeleteIndexAction.TYPE.name()); } public void testGetMappings() { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java index ad17e4f0d49dd..4aa3598608fb6 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java @@ -11,10 +11,13 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.node.reload.NodesReloadSecureSettingsResponse; +import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.KeyStoreWrapper; +import org.elasticsearch.common.settings.SecureSetting; import org.elasticsearch.common.settings.SecureSettings; import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.plugins.Plugin; @@ -43,6 +46,8 @@ @ESIntegTestCase.ClusterScope(minNumDataNodes = 2) public class ReloadSecureSettingsIT extends ESIntegTestCase { + private static final String VALID_SECURE_SETTING_NAME = "some.setting.that.exists"; + @BeforeClass public static void disableInFips() { // Reload secure settings with a password protected keystore is tested in ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT @@ -350,9 +355,46 @@ public void testReloadWhileKeystoreChanged() throws Exception { } } + public void testInvalidKeyInSettings() throws Exception { + final Environment environment = internalCluster().getInstance(Environment.class); + + try (KeyStoreWrapper keyStoreWrapper = KeyStoreWrapper.create()) { + keyStoreWrapper.setString(VALID_SECURE_SETTING_NAME, new char[0]); + keyStoreWrapper.save(environment.configFile(), new char[0], false); + } + + PlainActionFuture actionFuture = new PlainActionFuture<>(); + clusterAdmin().prepareReloadSecureSettings() + .setSecureStorePassword(new SecureString(new char[0])) + .setNodesIds(Strings.EMPTY_ARRAY) + .execute(actionFuture); + + actionFuture.get().getNodes().forEach(nodeResponse -> assertThat(nodeResponse.reloadException(), nullValue())); + + try (KeyStoreWrapper keyStoreWrapper = KeyStoreWrapper.create()) { + assertThat(keyStoreWrapper, notNullValue()); + keyStoreWrapper.setString("some.setting.that.does.not.exist", new char[0]); + keyStoreWrapper.save(environment.configFile(), new char[0], false); + } + + actionFuture = new PlainActionFuture<>(); + clusterAdmin().prepareReloadSecureSettings() + .setSecureStorePassword(new SecureString(new char[0])) + .setNodesIds(Strings.EMPTY_ARRAY) + .execute(actionFuture); + + actionFuture.get() + .getNodes() + .forEach(nodeResponse -> assertThat(nodeResponse.reloadException(), instanceOf(IllegalArgumentException.class))); + } + @Override protected Collection> nodePlugins() { - final List> plugins = Arrays.asList(MockReloadablePlugin.class, MisbehavingReloadablePlugin.class); + final List> plugins = Arrays.asList( + MockWithSecureSettingPlugin.class, + MockReloadablePlugin.class, + MisbehavingReloadablePlugin.class + ); // shuffle as reload is called in order Collections.shuffle(plugins, random()); return plugins; @@ -455,4 +497,10 @@ public synchronized void setShouldThrow(boolean shouldThrow) { } } + public static class MockWithSecureSettingPlugin extends Plugin { + public List> getSettings() { + return List.of(SecureSetting.secureString(VALID_SECURE_SETTING_NAME, null)); + } + }; + } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java index c9f3b0202b111..a4cf7843beb41 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java @@ -40,7 +40,7 @@ public void testDesiredBalanceOnMultiNodeCluster() throws Exception { var clusterHealthResponse = clusterAdmin().health(new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.GREEN)).get(); assertEquals(RestStatus.OK, clusterHealthResponse.status()); - DesiredBalanceResponse desiredBalanceResponse = client().execute(GetDesiredBalanceAction.INSTANCE, new DesiredBalanceRequest()) + DesiredBalanceResponse desiredBalanceResponse = client().execute(TransportGetDesiredBalanceAction.TYPE, new DesiredBalanceRequest()) .get(); assertEquals(1, desiredBalanceResponse.getRoutingTable().size()); @@ -75,7 +75,7 @@ public void testDesiredBalanceWithUnassignedShards() throws Exception { var clusterHealthResponse = clusterAdmin().health(new ClusterHealthRequest(index).waitForStatus(ClusterHealthStatus.YELLOW)).get(); assertEquals(RestStatus.OK, clusterHealthResponse.status()); - DesiredBalanceResponse desiredBalanceResponse = client().execute(GetDesiredBalanceAction.INSTANCE, new DesiredBalanceRequest()) + DesiredBalanceResponse desiredBalanceResponse = client().execute(TransportGetDesiredBalanceAction.TYPE, new DesiredBalanceRequest()) .get(); assertEquals(1, desiredBalanceResponse.getRoutingTable().size()); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java index 76d456bae1c06..a3c1304cfbae9 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java @@ -271,7 +271,9 @@ public void testDeleteDesiredNodesTasksAreBatchedCorrectly() throws Exception { final List> deleteDesiredNodesFutures = new ArrayList<>(15); for (int i = 0; i < 15; i++) { - deleteDesiredNodesFutures.add(client().execute(DeleteDesiredNodesAction.INSTANCE, new DeleteDesiredNodesAction.Request())); + deleteDesiredNodesFutures.add( + client().execute(TransportDeleteDesiredNodesAction.TYPE, new TransportDeleteDesiredNodesAction.Request()) + ); } for (ActionFuture future : deleteDesiredNodesFutures) { @@ -347,8 +349,8 @@ private UpdateDesiredNodesRequest randomDryRunUpdateDesiredNodesRequest(Version } private void deleteDesiredNodes() { - final DeleteDesiredNodesAction.Request request = new DeleteDesiredNodesAction.Request(); - client().execute(DeleteDesiredNodesAction.INSTANCE, request).actionGet(); + final TransportDeleteDesiredNodesAction.Request request = new TransportDeleteDesiredNodesAction.Request(); + client().execute(TransportDeleteDesiredNodesAction.TYPE, request).actionGet(); } private DesiredNodes getLatestDesiredNodes() { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java index d99ebe6a3e2e7..cb508334f835e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java @@ -142,10 +142,7 @@ protected Collection> getPlugins() { return List.of(TestPlugin.class); } - private static final ActionType TEST_ACTION = new ActionType<>( - TestTransportAction.NAME, - in -> ActionResponse.Empty.INSTANCE - ); + private static final ActionType TEST_ACTION = ActionType.emptyResponse(TestTransportAction.NAME); public static class TestPlugin extends Plugin implements ActionPlugin { volatile CyclicBarrier barrier; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java index 09c14df3566af..d3cbab2760747 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java @@ -8,10 +8,10 @@ package org.elasticsearch.cluster; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest; -import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; +import org.elasticsearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException; @@ -111,7 +111,7 @@ public void testTwoNodesNoMasterBlock() throws Exception { String masterNode = internalCluster().getMasterName(); String otherNode = node1Name.equals(masterNode) ? node2Name : node1Name; logger.info("--> add voting config exclusion for non-master node, to be sure it's not elected"); - client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(otherNode)).get(); + client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(otherNode)).get(); logger.info("--> stop master node, no master block should appear"); Settings masterDataPathSettings = internalCluster().dataPathSettings(masterNode); internalCluster().stopNode(masterNode); @@ -156,12 +156,12 @@ public void testTwoNodesNoMasterBlock() throws Exception { logger.info("--> clearing voting config exclusions"); ClearVotingConfigExclusionsRequest clearRequest = new ClearVotingConfigExclusionsRequest(); clearRequest.setWaitForRemoval(false); - client().execute(ClearVotingConfigExclusionsAction.INSTANCE, clearRequest).get(); + client().execute(TransportClearVotingConfigExclusionsAction.TYPE, clearRequest).get(); masterNode = internalCluster().getMasterName(); otherNode = node1Name.equals(masterNode) ? node2Name : node1Name; logger.info("--> add voting config exclusion for master node, to be sure it's not elected"); - client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(masterNode)).get(); + client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(masterNode)).get(); logger.info("--> stop non-master node, no master block should appear"); Settings otherNodeDataPathSettings = internalCluster().dataPathSettings(otherNode); internalCluster().stopNode(otherNode); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java index 23c13a3dbf579..aa54e46389676 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java @@ -9,8 +9,8 @@ package org.elasticsearch.cluster; import org.elasticsearch.action.ActionRequestBuilder; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.get.GetResponse; @@ -320,7 +320,7 @@ public void testNoMasterActionsMetadataWriteMasterBlock() throws Exception { .toList(); client().execute( - AddVotingConfigExclusionsAction.INSTANCE, + TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(nodesWithShards.toArray(new String[0])) ).get(); ensureGreen("test1"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java index 93d714c79c391..43506647f89ba 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java @@ -9,8 +9,8 @@ package org.elasticsearch.cluster; import org.apache.lucene.search.join.ScoreMode; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.MasterNotDiscoveredException; import org.elasticsearch.index.query.QueryBuilders; @@ -113,7 +113,7 @@ public void testElectOnlyBetweenMasterNodes() throws Exception { ); logger.info("--> closing master node (1)"); - client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(masterNodeName)).get(); + client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(masterNodeName)).get(); // removing the master from the voting configuration immediately triggers the master to step down assertBusy(() -> { assertThat( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java index dee6ac3859b15..b0cc81bf34811 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java @@ -8,8 +8,8 @@ package org.elasticsearch.cluster.coordination; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Priority; @@ -43,7 +43,7 @@ public void testAbdicateAfterVotingConfigExclusionAdded() throws ExecutionExcept final String originalMaster = internalCluster().getMasterName(); logger.info("--> excluding master node {}", originalMaster); - client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(originalMaster)).get(); + client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(originalMaster)).get(); clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get(); assertNotEquals(originalMaster, internalCluster().getMasterName()); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java index f05a83e861e52..3baabe4cc888e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java @@ -8,10 +8,10 @@ package org.elasticsearch.gateway; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest; -import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; +import org.elasticsearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; import org.elasticsearch.action.admin.indices.stats.IndexStats; import org.elasticsearch.action.admin.indices.stats.ShardStats; @@ -316,7 +316,7 @@ public void testTwoNodeFirstNodeCleared() throws Exception { Map primaryTerms = assertAndCapturePrimaryTerms(null); - client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(firstNode)).get(); + client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(firstNode)).get(); internalCluster().fullRestart(new RestartCallback() { @Override @@ -342,7 +342,7 @@ public boolean clearData(String nodeName) { assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2); } - client().execute(ClearVotingConfigExclusionsAction.INSTANCE, new ClearVotingConfigExclusionsRequest()).get(); + client().execute(TransportClearVotingConfigExclusionsAction.TYPE, new ClearVotingConfigExclusionsRequest()).get(); } public void testLatestVersionLoaded() throws Exception { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index 2cbc3477cb49d..d40d2e02415b1 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -782,6 +782,7 @@ public Settings onNodeStopped(String nodeName) { * Tests shard recovery throttling on the target node. Node statistics should show throttling time on the target node, while no * throttling should be shown on the source node because the target will accept data more slowly than the source's throttling threshold. */ + @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/103204") public void testTargetThrottling() throws Exception { logger.info("--> starting node A with default settings"); final String nodeA = internalCluster().startNode(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java index 91cd5e0e6e971..9d6a53d8bc818 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java @@ -10,8 +10,8 @@ import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesAction; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest; -import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest; +import org.elasticsearch.action.admin.cluster.repositories.put.TransportPutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.reservedstate.ReservedRepositoryAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterChangedEvent; @@ -151,7 +151,7 @@ private void assertClusterStateSaveOK(CountDownLatch savedClusterState, AtomicLo + "with errors: [[repo] set as read-only by [file_settings]]", expectThrows( IllegalArgumentException.class, - () -> client().execute(PutRepositoryAction.INSTANCE, sampleRestRequest("repo")).actionGet() + () -> client().execute(TransportPutRepositoryAction.TYPE, sampleRestRequest("repo")).actionGet() ).getMessage() ); } @@ -211,7 +211,7 @@ private void assertClusterStateNotSaved(CountDownLatch savedClusterState, Atomic ); // This should succeed, nothing was reserved - client().execute(PutRepositoryAction.INSTANCE, sampleRestRequest("err-repo")).get(); + client().execute(TransportPutRepositoryAction.TYPE, sampleRestRequest("err-repo")).get(); } public void testErrorSaved() throws Exception { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java index 59fc54347d1d5..089f6c09806cd 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java @@ -965,8 +965,7 @@ public void testRetentionLeasesClearedOnRestore() throws Exception { final String leaseId = randomAlphaOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); logger.debug("--> adding retention lease with id {} to {}", leaseId, shardId); - client().execute(RetentionLeaseActions.Add.INSTANCE, new RetentionLeaseActions.AddRequest(shardId, leaseId, RETAIN_ALL, "test")) - .actionGet(); + client().execute(RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(shardId, leaseId, RETAIN_ALL, "test")).actionGet(); final ShardStats shardStats = Arrays.stream(indicesAdmin().prepareStats(indexName).get().getShards()) .filter(s -> s.getShardRouting().shardId().equals(shardId)) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java index 2005d63ab6413..a6c8e0b08c9ed 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java @@ -11,7 +11,7 @@ import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse; import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse; -import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotAction; +import org.elasticsearch.action.admin.cluster.snapshots.delete.TransportDeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -277,7 +277,7 @@ public void testRepositoryConflict() throws Exception { assertTrue( clusterAdmin().prepareListTasks() - .setActions(DeleteSnapshotAction.NAME) + .setActions(TransportDeleteSnapshotAction.TYPE.name()) .setDetailed(true) .get() .getTasks() diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index 01e51d47722f6..2039acda89b8a 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -10,20 +10,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainAction; -import org.elasticsearch.action.admin.cluster.allocation.DeleteDesiredBalanceAction; -import org.elasticsearch.action.admin.cluster.allocation.GetDesiredBalanceAction; import org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction; import org.elasticsearch.action.admin.cluster.allocation.TransportDeleteDesiredBalanceAction; import org.elasticsearch.action.admin.cluster.allocation.TransportGetDesiredBalanceAction; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; -import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.coordination.ClusterFormationInfoAction; import org.elasticsearch.action.admin.cluster.coordination.CoordinationDiagnosticsAction; import org.elasticsearch.action.admin.cluster.coordination.MasterHistoryAction; -import org.elasticsearch.action.admin.cluster.desirednodes.DeleteDesiredNodesAction; import org.elasticsearch.action.admin.cluster.desirednodes.GetDesiredNodesAction; import org.elasticsearch.action.admin.cluster.desirednodes.TransportDeleteDesiredNodesAction; import org.elasticsearch.action.admin.cluster.desirednodes.TransportGetDesiredNodesAction; @@ -52,11 +46,9 @@ import org.elasticsearch.action.admin.cluster.remote.TransportRemoteInfoAction; import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.cleanup.TransportCleanupRepositoryAction; -import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.delete.TransportDeleteRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesAction; import org.elasticsearch.action.admin.cluster.repositories.get.TransportGetRepositoriesAction; -import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.put.TransportPutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.verify.TransportVerifyRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryAction; @@ -68,11 +60,9 @@ import org.elasticsearch.action.admin.cluster.settings.TransportClusterUpdateSettingsAction; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsAction; import org.elasticsearch.action.admin.cluster.shards.TransportClusterSearchShardsAction; -import org.elasticsearch.action.admin.cluster.snapshots.clone.CloneSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.clone.TransportCloneSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.create.TransportCreateSnapshotAction; -import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.delete.TransportDeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateAction; import org.elasticsearch.action.admin.cluster.snapshots.features.SnapshottableFeaturesAction; @@ -91,11 +81,9 @@ import org.elasticsearch.action.admin.cluster.state.TransportClusterStateAction; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction; import org.elasticsearch.action.admin.cluster.stats.TransportClusterStatsAction; -import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.GetScriptContextAction; import org.elasticsearch.action.admin.cluster.storedscripts.GetScriptLanguageAction; import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptAction; -import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.TransportDeleteStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.TransportGetScriptContextAction; import org.elasticsearch.action.admin.cluster.storedscripts.TransportGetScriptLanguageAction; @@ -116,15 +104,12 @@ import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; -import org.elasticsearch.action.admin.indices.dangling.delete.DeleteDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.delete.TransportDeleteDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.find.FindDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.find.TransportFindDanglingIndexAction; -import org.elasticsearch.action.admin.indices.dangling.import_index.ImportDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.import_index.TransportImportDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.list.ListDanglingIndicesAction; import org.elasticsearch.action.admin.indices.dangling.list.TransportListDanglingIndicesAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.diskusage.AnalyzeIndexDiskUsageAction; import org.elasticsearch.action.admin.indices.diskusage.TransportAnalyzeIndexDiskUsageAction; @@ -664,11 +649,11 @@ public void reg actions.register(PrevalidateNodeRemovalAction.INSTANCE, TransportPrevalidateNodeRemovalAction.class); actions.register(HealthApiStatsAction.INSTANCE, HealthApiStatsTransportAction.class); - actions.register(AddVotingConfigExclusionsAction.INSTANCE, TransportAddVotingConfigExclusionsAction.class); - actions.register(ClearVotingConfigExclusionsAction.INSTANCE, TransportClearVotingConfigExclusionsAction.class); - actions.register(ClusterAllocationExplainAction.INSTANCE, TransportClusterAllocationExplainAction.class); - actions.register(GetDesiredBalanceAction.INSTANCE, TransportGetDesiredBalanceAction.class); - actions.register(DeleteDesiredBalanceAction.INSTANCE, TransportDeleteDesiredBalanceAction.class); + actions.register(TransportAddVotingConfigExclusionsAction.TYPE, TransportAddVotingConfigExclusionsAction.class); + actions.register(TransportClearVotingConfigExclusionsAction.TYPE, TransportClearVotingConfigExclusionsAction.class); + actions.register(TransportClusterAllocationExplainAction.TYPE, TransportClusterAllocationExplainAction.class); + actions.register(TransportGetDesiredBalanceAction.TYPE, TransportGetDesiredBalanceAction.class); + actions.register(TransportDeleteDesiredBalanceAction.TYPE, TransportDeleteDesiredBalanceAction.class); actions.register(ClusterStatsAction.INSTANCE, TransportClusterStatsAction.class); actions.register(ClusterStateAction.INSTANCE, TransportClusterStateAction.class); actions.register(TransportClusterHealthAction.TYPE, TransportClusterHealthAction.class); @@ -678,15 +663,15 @@ public void reg actions.register(ClusterSearchShardsAction.INSTANCE, TransportClusterSearchShardsAction.class); actions.register(ClusterFormationInfoAction.INSTANCE, ClusterFormationInfoAction.TransportAction.class); actions.register(TransportPendingClusterTasksAction.TYPE, TransportPendingClusterTasksAction.class); - actions.register(PutRepositoryAction.INSTANCE, TransportPutRepositoryAction.class); + actions.register(TransportPutRepositoryAction.TYPE, TransportPutRepositoryAction.class); actions.register(GetRepositoriesAction.INSTANCE, TransportGetRepositoriesAction.class); - actions.register(DeleteRepositoryAction.INSTANCE, TransportDeleteRepositoryAction.class); + actions.register(TransportDeleteRepositoryAction.TYPE, TransportDeleteRepositoryAction.class); actions.register(VerifyRepositoryAction.INSTANCE, TransportVerifyRepositoryAction.class); actions.register(CleanupRepositoryAction.INSTANCE, TransportCleanupRepositoryAction.class); actions.register(GetSnapshotsAction.INSTANCE, TransportGetSnapshotsAction.class); - actions.register(DeleteSnapshotAction.INSTANCE, TransportDeleteSnapshotAction.class); + actions.register(TransportDeleteSnapshotAction.TYPE, TransportDeleteSnapshotAction.class); actions.register(CreateSnapshotAction.INSTANCE, TransportCreateSnapshotAction.class); - actions.register(CloneSnapshotAction.INSTANCE, TransportCloneSnapshotAction.class); + actions.register(TransportCloneSnapshotAction.TYPE, TransportCloneSnapshotAction.class); actions.register(RestoreSnapshotAction.INSTANCE, TransportRestoreSnapshotAction.class); actions.register(SnapshotsStatusAction.INSTANCE, TransportSnapshotsStatusAction.class); actions.register(SnapshottableFeaturesAction.INSTANCE, TransportSnapshottableFeaturesAction.class); @@ -701,7 +686,7 @@ public void reg actions.register(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class); actions.register(ResizeAction.INSTANCE, TransportResizeAction.class); actions.register(RolloverAction.INSTANCE, TransportRolloverAction.class); - actions.register(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class); + actions.register(TransportDeleteIndexAction.TYPE, TransportDeleteIndexAction.class); actions.register(GetIndexAction.INSTANCE, TransportGetIndexAction.class); actions.register(OpenIndexAction.INSTANCE, TransportOpenIndexAction.class); actions.register(TransportCloseIndexAction.TYPE, TransportCloseIndexAction.class); @@ -764,9 +749,9 @@ public void reg actions.register(CoordinationDiagnosticsAction.INSTANCE, CoordinationDiagnosticsAction.TransportAction.class); // Indexed scripts - actions.register(PutStoredScriptAction.INSTANCE, TransportPutStoredScriptAction.class); + actions.register(TransportPutStoredScriptAction.TYPE, TransportPutStoredScriptAction.class); actions.register(GetStoredScriptAction.INSTANCE, TransportGetStoredScriptAction.class); - actions.register(DeleteStoredScriptAction.INSTANCE, TransportDeleteStoredScriptAction.class); + actions.register(TransportDeleteStoredScriptAction.TYPE, TransportDeleteStoredScriptAction.class); actions.register(GetScriptContextAction.INSTANCE, TransportGetScriptContextAction.class); actions.register(GetScriptLanguageAction.INSTANCE, TransportGetScriptLanguageAction.class); @@ -786,14 +771,14 @@ public void reg actions.register(RemovePersistentTaskAction.INSTANCE, RemovePersistentTaskAction.TransportAction.class); // retention leases - actions.register(RetentionLeaseActions.Add.INSTANCE, RetentionLeaseActions.Add.TransportAction.class); - actions.register(RetentionLeaseActions.Renew.INSTANCE, RetentionLeaseActions.Renew.TransportAction.class); - actions.register(RetentionLeaseActions.Remove.INSTANCE, RetentionLeaseActions.Remove.TransportAction.class); + actions.register(RetentionLeaseActions.ADD, RetentionLeaseActions.TransportAddAction.class); + actions.register(RetentionLeaseActions.RENEW, RetentionLeaseActions.TransportRenewAction.class); + actions.register(RetentionLeaseActions.REMOVE, RetentionLeaseActions.TransportRemoveAction.class); // Dangling indices actions.register(ListDanglingIndicesAction.INSTANCE, TransportListDanglingIndicesAction.class); - actions.register(ImportDanglingIndexAction.INSTANCE, TransportImportDanglingIndexAction.class); - actions.register(DeleteDanglingIndexAction.INSTANCE, TransportDeleteDanglingIndexAction.class); + actions.register(TransportImportDanglingIndexAction.TYPE, TransportImportDanglingIndexAction.class); + actions.register(TransportDeleteDanglingIndexAction.TYPE, TransportDeleteDanglingIndexAction.class); actions.register(FindDanglingIndexAction.INSTANCE, TransportFindDanglingIndexAction.class); // internal actions @@ -810,7 +795,7 @@ public void reg // desired nodes actions.register(GetDesiredNodesAction.INSTANCE, TransportGetDesiredNodesAction.class); actions.register(UpdateDesiredNodesAction.INSTANCE, TransportUpdateDesiredNodesAction.class); - actions.register(DeleteDesiredNodesAction.INSTANCE, TransportDeleteDesiredNodesAction.class); + actions.register(TransportDeleteDesiredNodesAction.TYPE, TransportDeleteDesiredNodesAction.class); actions.register(UpdateHealthInfoCacheAction.INSTANCE, UpdateHealthInfoCacheAction.TransportAction.class); actions.register(FetchHealthInfoCacheAction.INSTANCE, FetchHealthInfoCacheAction.TransportAction.class); diff --git a/server/src/main/java/org/elasticsearch/action/ActionType.java b/server/src/main/java/org/elasticsearch/action/ActionType.java index 478fab0f2cf36..b8e4c8b88aa5e 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionType.java +++ b/server/src/main/java/org/elasticsearch/action/ActionType.java @@ -8,6 +8,7 @@ package org.elasticsearch.action; +import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.common.io.stream.Writeable; /** @@ -22,6 +23,14 @@ public static ActionType localOnly(String name) { return new ActionType<>(name, Writeable.Reader.localOnly()); } + public static ActionType emptyResponse(String name) { + return new ActionType<>(name, in -> ActionResponse.Empty.INSTANCE); + } + + public static ActionType acknowledgedResponse(String name) { + return new ActionType<>(name, AcknowledgedResponse::readFrom); + } + /** * @param name The name of the action, must be unique across actions. * @param responseReader A reader for the response type diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainAction.java deleted file mode 100644 index 34d5874cea3cb..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainAction.java +++ /dev/null @@ -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.action.admin.cluster.allocation; - -import org.elasticsearch.action.ActionType; - -/** - * ActionType for explaining shard allocation for a shard in the cluster - */ -public class ClusterAllocationExplainAction extends ActionType { - - public static final ClusterAllocationExplainAction INSTANCE = new ClusterAllocationExplainAction(); - public static final String NAME = "cluster:monitor/allocation/explain"; - - private ClusterAllocationExplainAction() { - super(NAME, ClusterAllocationExplainResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestBuilder.java index 6ceea15d8fd11..3053ebe1f3db9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestBuilder.java @@ -19,8 +19,8 @@ public class ClusterAllocationExplainRequestBuilder extends MasterNodeOperationR ClusterAllocationExplainResponse, ClusterAllocationExplainRequestBuilder> { - public ClusterAllocationExplainRequestBuilder(ElasticsearchClient client, ClusterAllocationExplainAction action) { - super(client, action, new ClusterAllocationExplainRequest()); + public ClusterAllocationExplainRequestBuilder(ElasticsearchClient client) { + super(client, TransportClusterAllocationExplainAction.TYPE, new ClusterAllocationExplainRequest()); } /** The index name to use when finding the shard to explain */ diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DeleteDesiredBalanceAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DeleteDesiredBalanceAction.java deleted file mode 100644 index 23a2e75d5d401..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DeleteDesiredBalanceAction.java +++ /dev/null @@ -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.action.admin.cluster.allocation; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; - -public class DeleteDesiredBalanceAction extends ActionType { - - public static final DeleteDesiredBalanceAction INSTANCE = new DeleteDesiredBalanceAction(); - public static final String NAME = "cluster:admin/desired_balance/reset"; - - DeleteDesiredBalanceAction() { - super(NAME, in -> ActionResponse.Empty.INSTANCE); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/GetDesiredBalanceAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/GetDesiredBalanceAction.java deleted file mode 100644 index f9f90791c223f..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/GetDesiredBalanceAction.java +++ /dev/null @@ -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.action.admin.cluster.allocation; - -import org.elasticsearch.action.ActionType; - -public class GetDesiredBalanceAction extends ActionType { - public static final GetDesiredBalanceAction INSTANCE = new GetDesiredBalanceAction(); - public static final String NAME = "cluster:admin/desired_balance/get"; - - GetDesiredBalanceAction() { - super(NAME, DesiredBalanceResponse::from); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java index 68302df47d6f2..7599eb2faef96 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterInfo; @@ -43,6 +44,10 @@ public class TransportClusterAllocationExplainAction extends TransportMasterNode ClusterAllocationExplainRequest, ClusterAllocationExplainResponse> { + public static final ActionType TYPE = new ActionType<>( + "cluster:monitor/allocation/explain", + ClusterAllocationExplainResponse::new + ); private static final Logger logger = LogManager.getLogger(TransportClusterAllocationExplainAction.class); private final ClusterInfoService clusterInfoService; @@ -63,7 +68,7 @@ public TransportClusterAllocationExplainAction( AllocationService allocationService ) { super( - ClusterAllocationExplainAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportDeleteDesiredBalanceAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportDeleteDesiredBalanceAction.java index 4360d7c1925f6..76b563c3f540a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportDeleteDesiredBalanceAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportDeleteDesiredBalanceAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterState; @@ -34,6 +35,7 @@ public class TransportDeleteDesiredBalanceAction extends TransportMasterNodeAction { + public static final ActionType TYPE = ActionType.emptyResponse("cluster:admin/desired_balance/reset"); @Nullable private final MasterServiceTaskQueue resetDesiredBalanceTaskQueue; @@ -48,7 +50,7 @@ public TransportDeleteDesiredBalanceAction( ShardsAllocator shardsAllocator ) { super( - DeleteDesiredBalanceAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceAction.java index fc11790079521..49611ffae8718 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceAction.java @@ -9,6 +9,7 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; import org.elasticsearch.cluster.ClusterInfoService; @@ -42,6 +43,10 @@ public class TransportGetDesiredBalanceAction extends TransportMasterNodeReadAction { + public static final ActionType TYPE = new ActionType<>( + "cluster:admin/desired_balance/get", + DesiredBalanceResponse::from + ); @Nullable private final DesiredBalanceShardsAllocator desiredBalanceShardsAllocator; private final ClusterInfoService clusterInfoService; @@ -59,7 +64,7 @@ public TransportGetDesiredBalanceAction( WriteLoadForecaster writeLoadForecaster ) { super( - GetDesiredBalanceAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsAction.java deleted file mode 100644 index 7445096722c28..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsAction.java +++ /dev/null @@ -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.action.admin.cluster.configuration; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; - -public class AddVotingConfigExclusionsAction extends ActionType { - public static final AddVotingConfigExclusionsAction INSTANCE = new AddVotingConfigExclusionsAction(); - public static final String NAME = "cluster:admin/voting_config/add_exclusions"; - - private AddVotingConfigExclusionsAction() { - super(NAME, in -> ActionResponse.Empty.INSTANCE); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsAction.java deleted file mode 100644 index 98f4dd62763e5..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsAction.java +++ /dev/null @@ -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.action.admin.cluster.configuration; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; - -public class ClearVotingConfigExclusionsAction extends ActionType { - public static final ClearVotingConfigExclusionsAction INSTANCE = new ClearVotingConfigExclusionsAction(); - public static final String NAME = "cluster:admin/voting_config/clear_exclusions"; - - private ClearVotingConfigExclusionsAction() { - super(NAME, in -> ActionResponse.Empty.INSTANCE); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java index 57332429135b6..b9bcf0944cd83 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java @@ -13,6 +13,7 @@ import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterState; @@ -48,6 +49,7 @@ public class TransportAddVotingConfigExclusionsAction extends TransportMasterNod AddVotingConfigExclusionsRequest, ActionResponse.Empty> { + public static final ActionType TYPE = ActionType.emptyResponse("cluster:admin/voting_config/add_exclusions"); private static final Logger logger = LogManager.getLogger(TransportAddVotingConfigExclusionsAction.class); public static final Setting MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING = Setting.intSetting( @@ -73,7 +75,7 @@ public TransportAddVotingConfigExclusionsAction( Reconfigurator reconfigurator ) { super( - AddVotingConfigExclusionsAction.NAME, + TYPE.name(), false, transportService, clusterService, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java index 46069f01ecda3..113d085f51fdb 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java @@ -13,6 +13,7 @@ import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterState; @@ -42,6 +43,7 @@ public class TransportClearVotingConfigExclusionsAction extends TransportMasterN ClearVotingConfigExclusionsRequest, ActionResponse.Empty> { + public static final ActionType TYPE = ActionType.emptyResponse("cluster:admin/voting_config/clear_exclusions"); private static final Logger logger = LogManager.getLogger(TransportClearVotingConfigExclusionsAction.class); private final Reconfigurator reconfigurator; @@ -55,7 +57,7 @@ public TransportClearVotingConfigExclusionsAction( Reconfigurator reconfigurator ) { super( - ClearVotingConfigExclusionsAction.NAME, + TYPE.name(), false, transportService, clusterService, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/DeleteDesiredNodesAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/DeleteDesiredNodesAction.java deleted file mode 100644 index 720f38e16a86a..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/DeleteDesiredNodesAction.java +++ /dev/null @@ -1,39 +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.action.admin.cluster.desirednodes; - -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedRequest; -import org.elasticsearch.common.io.stream.StreamInput; - -import java.io.IOException; - -public class DeleteDesiredNodesAction extends ActionType { - public static final DeleteDesiredNodesAction INSTANCE = new DeleteDesiredNodesAction(); - public static final String NAME = "cluster:admin/desired_nodes/delete"; - - DeleteDesiredNodesAction() { - super(NAME, in -> ActionResponse.Empty.INSTANCE); - } - - public static class Request extends AcknowledgedRequest { - public Request() {} - - public Request(StreamInput in) throws IOException { - super(in); - } - - @Override - public ActionRequestValidationException validate() { - return null; - } - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java index 48ea8beef2fd4..689e0579d1cbd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java @@ -9,8 +9,11 @@ package org.elasticsearch.action.admin.cluster.desirednodes; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; +import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateTaskListener; @@ -23,14 +26,20 @@ import org.elasticsearch.cluster.service.MasterServiceTaskQueue; import org.elasticsearch.common.Priority; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.core.Tuple; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -public class TransportDeleteDesiredNodesAction extends TransportMasterNodeAction { +import java.io.IOException; +public class TransportDeleteDesiredNodesAction extends TransportMasterNodeAction< + TransportDeleteDesiredNodesAction.Request, + ActionResponse.Empty> { + + public static final ActionType TYPE = ActionType.emptyResponse("cluster:admin/desired_nodes/delete"); private final MasterServiceTaskQueue taskQueue; @Inject @@ -42,12 +51,12 @@ public TransportDeleteDesiredNodesAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - DeleteDesiredNodesAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, actionFilters, - DeleteDesiredNodesAction.Request::new, + Request::new, indexNameExpressionResolver, in -> ActionResponse.Empty.INSTANCE, EsExecutors.DIRECT_EXECUTOR_SERVICE @@ -56,17 +65,13 @@ public TransportDeleteDesiredNodesAction( } @Override - protected void masterOperation( - Task task, - DeleteDesiredNodesAction.Request request, - ClusterState state, - ActionListener listener - ) throws Exception { + protected void masterOperation(Task task, Request request, ClusterState state, ActionListener listener) + throws Exception { taskQueue.submitTask("delete-desired-nodes", new DeleteDesiredNodesTask(listener), request.masterNodeTimeout()); } @Override - protected ClusterBlockException checkBlock(DeleteDesiredNodesAction.Request request, ClusterState state) { + protected ClusterBlockException checkBlock(Request request, ClusterState state) { return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); } @@ -93,4 +98,17 @@ public ClusterState afterBatchExecution(ClusterState clusterState, boolean clust return clusterState.copyAndUpdateMetadata(metadata -> metadata.removeCustom(DesiredNodesMetadata.TYPE)); } } + + public static class Request extends AcknowledgedRequest { + public Request() {} + + public Request(StreamInput in) throws IOException { + super(in); + } + + @Override + public ActionRequestValidationException validate() { + return null; + } + } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java index 7fa97f1ee14b7..ed63e6d1b4474 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java @@ -122,6 +122,8 @@ protected NodesReloadSecureSettingsResponse.NodeResponse nodeOperation( keystore.decrypt(request.hasPassword() ? request.getSecureSettingsPassword().getChars() : new char[0]); // add the keystore to the original node settings object final Settings settingsWithKeystore = Settings.builder().put(environment.settings(), false).setSecureSettings(keystore).build(); + clusterService.getClusterSettings().validate(settingsWithKeystore, true); + final List exceptions = new ArrayList<>(); // broadcast the new settings object (with the open embedded keystore) to all reloadable plugins pluginsService.filterPlugins(ReloadablePlugin.class).forEach(p -> { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryAction.java deleted file mode 100644 index 590460e9025b6..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryAction.java +++ /dev/null @@ -1,26 +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.action.admin.cluster.repositories.delete; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -/** - * Unregister repository action - */ -public class DeleteRepositoryAction extends ActionType { - - public static final DeleteRepositoryAction INSTANCE = new DeleteRepositoryAction(); - public static final String NAME = "cluster:admin/repository/delete"; - - private DeleteRepositoryAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryRequestBuilder.java index e2f614246b81c..6accb02418df8 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryRequestBuilder.java @@ -24,7 +24,7 @@ public class DeleteRepositoryRequestBuilder extends AcknowledgedRequestBuilder< * Constructs unregister repository request builder with specified repository name */ public DeleteRepositoryRequestBuilder(ElasticsearchClient client, String name) { - super(client, DeleteRepositoryAction.INSTANCE, new DeleteRepositoryRequest(name)); + super(client, TransportDeleteRepositoryAction.TYPE, new DeleteRepositoryRequest(name)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java index b1f78408c7829..69568462731e8 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.admin.cluster.repositories.delete; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.admin.cluster.repositories.reservedstate.ReservedRepositoryAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -33,6 +34,7 @@ */ public class TransportDeleteRepositoryAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/repository/delete"); private final RepositoriesService repositoriesService; @Inject @@ -45,7 +47,7 @@ public TransportDeleteRepositoryAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - DeleteRepositoryAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryAction.java deleted file mode 100644 index 3ac2134afef83..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryAction.java +++ /dev/null @@ -1,26 +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.action.admin.cluster.repositories.put; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -/** - * Register repository action - */ -public class PutRepositoryAction extends ActionType { - - public static final PutRepositoryAction INSTANCE = new PutRepositoryAction(); - public static final String NAME = "cluster:admin/repository/put"; - - private PutRepositoryAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryRequestBuilder.java index 79195725ad962..86ed38c2ddad9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryRequestBuilder.java @@ -28,7 +28,7 @@ public class PutRepositoryRequestBuilder extends AcknowledgedRequestBuilder< * Constructs register repository request for the repository with a given name */ public PutRepositoryRequestBuilder(ElasticsearchClient client, String name) { - super(client, PutRepositoryAction.INSTANCE, new PutRepositoryRequest(name)); + super(client, TransportPutRepositoryAction.TYPE, new PutRepositoryRequest(name)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java index bb17b0d8ab8fe..c6b471ff25bdf 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.admin.cluster.repositories.put; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.admin.cluster.repositories.reservedstate.ReservedRepositoryAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -33,6 +34,7 @@ */ public class TransportPutRepositoryAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/repository/put"); private final RepositoriesService repositoriesService; @Inject @@ -45,7 +47,7 @@ public TransportPutRepositoryAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - PutRepositoryAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/CloneSnapshotAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/CloneSnapshotAction.java deleted file mode 100644 index b73e8e3668cd2..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/CloneSnapshotAction.java +++ /dev/null @@ -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.action.admin.cluster.snapshots.clone; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -public final class CloneSnapshotAction extends ActionType { - - public static final CloneSnapshotAction INSTANCE = new CloneSnapshotAction(); - public static final String NAME = "cluster:admin/snapshot/clone"; - - private CloneSnapshotAction() { - super(NAME, AcknowledgedResponse::readFrom); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequestBuilder.java index efa4c4895a12e..818f0fadf92ef 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequestBuilder.java @@ -20,7 +20,7 @@ public class CloneSnapshotRequestBuilder extends MasterNodeOperationRequestBuild CloneSnapshotRequestBuilder> { public CloneSnapshotRequestBuilder(ElasticsearchClient client, String repository, String source, String target) { - super(client, CloneSnapshotAction.INSTANCE, new CloneSnapshotRequest(repository, source, target, Strings.EMPTY_ARRAY)); + super(client, TransportCloneSnapshotAction.TYPE, new CloneSnapshotRequest(repository, source, target, Strings.EMPTY_ARRAY)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java index 1a37cd0204c30..7ab8b704a3ee8 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.admin.cluster.snapshots.clone; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; @@ -29,6 +30,7 @@ */ public final class TransportCloneSnapshotAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/snapshot/clone"); private final SnapshotsService snapshotsService; @Inject @@ -41,7 +43,7 @@ public TransportCloneSnapshotAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - CloneSnapshotAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotAction.java deleted file mode 100644 index 9d5e30b604702..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotAction.java +++ /dev/null @@ -1,26 +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.action.admin.cluster.snapshots.delete; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -/** - * Delete snapshot action - */ -public class DeleteSnapshotAction extends ActionType { - - public static final DeleteSnapshotAction INSTANCE = new DeleteSnapshotAction(); - public static final String NAME = "cluster:admin/snapshot/delete"; - - private DeleteSnapshotAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotRequestBuilder.java index 8d2c8997b42e6..f18ed209ba11e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotRequestBuilder.java @@ -24,7 +24,7 @@ public class DeleteSnapshotRequestBuilder extends MasterNodeOperationRequestBuil * Constructs delete snapshot request builder with specified repository and snapshot names */ public DeleteSnapshotRequestBuilder(ElasticsearchClient client, String repository, String... snapshots) { - super(client, DeleteSnapshotAction.INSTANCE, new DeleteSnapshotRequest(repository, snapshots)); + super(client, TransportDeleteSnapshotAction.TYPE, new DeleteSnapshotRequest(repository, snapshots)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java index df7a5e5595055..39b03b479ffdf 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.admin.cluster.snapshots.delete; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; @@ -28,6 +29,7 @@ * Transport action for delete snapshot operation */ public class TransportDeleteSnapshotAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/snapshot/delete"); private final SnapshotsService snapshotsService; @Inject @@ -40,7 +42,7 @@ public TransportDeleteSnapshotAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - DeleteSnapshotAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptAction.java deleted file mode 100644 index 1ac899666a1eb..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptAction.java +++ /dev/null @@ -1,23 +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.action.admin.cluster.storedscripts; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -public class DeleteStoredScriptAction extends ActionType { - - public static final DeleteStoredScriptAction INSTANCE = new DeleteStoredScriptAction(); - public static final String NAME = "cluster:admin/script/delete"; - - private DeleteStoredScriptAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequestBuilder.java index d8f22216073a5..ce074e17ebb75 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequestBuilder.java @@ -18,7 +18,7 @@ public class DeleteStoredScriptRequestBuilder extends AcknowledgedRequestBuilder DeleteStoredScriptRequestBuilder> { public DeleteStoredScriptRequestBuilder(ElasticsearchClient client) { - super(client, DeleteStoredScriptAction.INSTANCE, new DeleteStoredScriptRequest()); + super(client, TransportDeleteStoredScriptAction.TYPE, new DeleteStoredScriptRequest()); } public DeleteStoredScriptRequestBuilder setId(String id) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptAction.java deleted file mode 100644 index f7506f379de8a..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptAction.java +++ /dev/null @@ -1,23 +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.action.admin.cluster.storedscripts; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -public class PutStoredScriptAction extends ActionType { - - public static final PutStoredScriptAction INSTANCE = new PutStoredScriptAction(); - public static final String NAME = "cluster:admin/script/put"; - - private PutStoredScriptAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java index 24f5900629cfb..9e353382f84a9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java @@ -20,7 +20,7 @@ public class PutStoredScriptRequestBuilder extends AcknowledgedRequestBuilder< PutStoredScriptRequestBuilder> { public PutStoredScriptRequestBuilder(ElasticsearchClient client) { - super(client, PutStoredScriptAction.INSTANCE, new PutStoredScriptRequest()); + super(client, TransportPutStoredScriptAction.TYPE, new PutStoredScriptRequest()); } public PutStoredScriptRequestBuilder setId(String id) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java index dfb3745d4101a..829b00b7cc1c9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.admin.cluster.storedscripts; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; @@ -26,6 +27,8 @@ public class TransportDeleteStoredScriptAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/script/delete"); + @Inject public TransportDeleteStoredScriptAction( TransportService transportService, @@ -35,7 +38,7 @@ public TransportDeleteStoredScriptAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - DeleteStoredScriptAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java index 8025d983d2668..4fb0f68bce625 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.admin.cluster.storedscripts; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; @@ -26,6 +27,7 @@ public class TransportPutStoredScriptAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/script/put"); private final ScriptService scriptService; @Inject @@ -38,7 +40,7 @@ public TransportPutStoredScriptAction( ScriptService scriptService ) { super( - PutStoredScriptAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java index 66a489933c3ee..0001fec4e71e5 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java @@ -59,7 +59,7 @@ public class TransportIndicesAliasesAction extends AcknowledgedTransportMasterNodeAction { public static final String NAME = "indices:admin/aliases"; - public static final ActionType TYPE = new ActionType<>(NAME, AcknowledgedResponse::readFrom); + public static final ActionType TYPE = ActionType.acknowledgedResponse(NAME); private static final Logger logger = LogManager.getLogger(TransportIndicesAliasesAction.class); private final MetadataIndexAliasesService indexAliasesService; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/delete/DeleteDanglingIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/delete/DeleteDanglingIndexAction.java deleted file mode 100644 index 0435f603be8ac..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/delete/DeleteDanglingIndexAction.java +++ /dev/null @@ -1,25 +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.action.admin.indices.dangling.delete; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -/** - * This action causes a dangling index to be considered as deleted by the cluster. - */ -public class DeleteDanglingIndexAction extends ActionType { - - public static final DeleteDanglingIndexAction INSTANCE = new DeleteDanglingIndexAction(); - public static final String NAME = "cluster:admin/indices/dangling/delete"; - - private DeleteDanglingIndexAction() { - super(NAME, AcknowledgedResponse::readFrom); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java index 1207c2c1e60ff..93fae72810ad0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java @@ -12,6 +12,7 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.admin.indices.dangling.DanglingIndexInfo; import org.elasticsearch.action.admin.indices.dangling.list.ListDanglingIndicesAction; @@ -43,11 +44,12 @@ import java.util.stream.Collectors; /** - * Implements the deletion of a dangling index. When handling a {@link DeleteDanglingIndexAction}, + * Implements the deletion of a dangling index. When handling a {@link DeleteDanglingIndexRequest}, * this class first checks that such a dangling index exists. It then submits a cluster state update * to add the index to the index graveyard. */ public class TransportDeleteDanglingIndexAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/indices/dangling/delete"); private static final Logger logger = LogManager.getLogger(TransportDeleteDanglingIndexAction.class); private final Settings settings; @@ -64,7 +66,7 @@ public TransportDeleteDanglingIndexAction( NodeClient nodeClient ) { super( - DeleteDanglingIndexAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/import_index/ImportDanglingIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/import_index/ImportDanglingIndexAction.java deleted file mode 100644 index c64a8b81fc2de..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/import_index/ImportDanglingIndexAction.java +++ /dev/null @@ -1,25 +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.action.admin.indices.dangling.import_index; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -/** - * Represents a request to import a particular dangling index. - */ -public class ImportDanglingIndexAction extends ActionType { - - public static final ImportDanglingIndexAction INSTANCE = new ImportDanglingIndexAction(); - public static final String NAME = "cluster:admin/indices/dangling/import"; - - private ImportDanglingIndexAction() { - super(NAME, AcknowledgedResponse::readFrom); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java index 0362128c6403a..0348b46bedcae 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java @@ -12,6 +12,7 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.admin.indices.dangling.find.FindDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.find.FindDanglingIndexRequest; @@ -33,11 +34,12 @@ import java.util.stream.Collectors; /** - * Implements the import of a dangling index. When handling a {@link ImportDanglingIndexAction}, + * Implements the import of a dangling index. When handling a {@link ImportDanglingIndexRequest}, * this class first checks that such a dangling index exists. It then calls {@link LocalAllocateDangledIndices} * to perform the actual allocation. */ public class TransportImportDanglingIndexAction extends HandledTransportAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("cluster:admin/indices/dangling/import"); private static final Logger logger = LogManager.getLogger(TransportImportDanglingIndexAction.class); private final LocalAllocateDangledIndices danglingIndexAllocator; @@ -50,13 +52,7 @@ public TransportImportDanglingIndexAction( LocalAllocateDangledIndices danglingIndexAllocator, NodeClient nodeClient ) { - super( - ImportDanglingIndexAction.NAME, - transportService, - actionFilters, - ImportDanglingIndexRequest::new, - EsExecutors.DIRECT_EXECUTOR_SERVICE - ); + super(TYPE.name(), transportService, actionFilters, ImportDanglingIndexRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); this.danglingIndexAllocator = danglingIndexAllocator; this.nodeClient = nodeClient; } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexAction.java deleted file mode 100644 index c652375be2de0..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexAction.java +++ /dev/null @@ -1,23 +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.action.admin.indices.delete; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -public class DeleteIndexAction extends ActionType { - - public static final DeleteIndexAction INSTANCE = new DeleteIndexAction(); - public static final String NAME = "indices:admin/delete"; - - private DeleteIndexAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequestBuilder.java index a6ae02dddde20..5c0aec258176a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequestBuilder.java @@ -19,7 +19,7 @@ public class DeleteIndexRequestBuilder extends AcknowledgedRequestBuilder< DeleteIndexRequestBuilder> { public DeleteIndexRequestBuilder(ElasticsearchClient client, String... indices) { - super(client, DeleteIndexAction.INSTANCE, new DeleteIndexRequest(indices)); + super(client, TransportDeleteIndexAction.TYPE, new DeleteIndexRequest(indices)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java index 8fe6e0b67e827..eff4fe24c10ac 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -36,6 +37,7 @@ */ public class TransportDeleteIndexAction extends AcknowledgedTransportMasterNodeAction { + public static final ActionType TYPE = ActionType.acknowledgedResponse("indices:admin/delete"); private static final Logger logger = LogManager.getLogger(TransportDeleteIndexAction.class); private final MetadataDeleteIndexService deleteIndexService; @@ -52,7 +54,7 @@ public TransportDeleteIndexAction( DestructiveOperations destructiveOperations ) { super( - DeleteIndexAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java index 0a4951c8c4125..e37f248246920 100644 --- a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java @@ -15,7 +15,6 @@ import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.CancellableFanOut; -import org.elasticsearch.action.support.ChannelActionListener; import org.elasticsearch.action.support.ThreadedActionListener; import org.elasticsearch.action.support.TransportAction; import org.elasticsearch.cluster.ClusterState; @@ -27,7 +26,6 @@ import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.core.CheckedConsumer; import org.elasticsearch.tasks.Task; -import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportChannel; import org.elasticsearch.transport.TransportRequest; import org.elasticsearch.transport.TransportRequestHandler; @@ -83,32 +81,6 @@ protected TransportNodesAction( transportService.registerRequestHandler(transportNodeAction, finalExecutor, nodeRequest, new NodeTransportHandler()); } - /** - * @deprecated Use the local-only constructor instead. - */ - @Deprecated(forRemoval = true) - @SuppressWarnings("this-escape") - protected TransportNodesAction( - String actionName, - ThreadPool threadPool, - ClusterService clusterService, - TransportService transportService, - ActionFilters actionFilters, - Writeable.Reader requestReader, - Writeable.Reader nodeRequest, - Executor executor - ) { - this(actionName, clusterService, transportService, actionFilters, nodeRequest, executor); - transportService.registerRequestHandler( - actionName, - executor, - false, - true, - requestReader, - (request, channel, task) -> execute(task, request, new ChannelActionListener<>(channel)) - ); - } - @Override protected void doExecute(Task task, NodesRequest request, ActionListener listener) { // coordination can run on SAME because it's only O(#nodes) work diff --git a/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java b/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java index 182e9ee497c07..21c01abd52437 100644 --- a/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java @@ -16,10 +16,10 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainAction; import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest; import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequestBuilder; import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse; +import org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; @@ -56,16 +56,16 @@ import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequestBuilder; import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryResponse; -import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequestBuilder; +import org.elasticsearch.action.admin.cluster.repositories.delete.TransportDeleteRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesAction; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequestBuilder; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse; -import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequestBuilder; +import org.elasticsearch.action.admin.cluster.repositories.put.TransportPutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequestBuilder; @@ -82,16 +82,16 @@ import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsRequest; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsRequestBuilder; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse; -import org.elasticsearch.action.admin.cluster.snapshots.clone.CloneSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.clone.CloneSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.clone.CloneSnapshotRequestBuilder; +import org.elasticsearch.action.admin.cluster.snapshots.clone.TransportCloneSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequestBuilder; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; -import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequestBuilder; +import org.elasticsearch.action.admin.cluster.snapshots.delete.TransportDeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsAction; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequestBuilder; @@ -112,16 +112,16 @@ import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; -import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest; import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequestBuilder; import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest; import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequestBuilder; import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptResponse; -import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest; import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequestBuilder; +import org.elasticsearch.action.admin.cluster.storedscripts.TransportDeleteStoredScriptAction; +import org.elasticsearch.action.admin.cluster.storedscripts.TransportPutStoredScriptAction; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequestBuilder; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse; @@ -147,16 +147,16 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.action.admin.indices.dangling.delete.DeleteDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.delete.DeleteDanglingIndexRequest; -import org.elasticsearch.action.admin.indices.dangling.import_index.ImportDanglingIndexAction; +import org.elasticsearch.action.admin.indices.dangling.delete.TransportDeleteDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.import_index.ImportDanglingIndexRequest; +import org.elasticsearch.action.admin.indices.dangling.import_index.TransportImportDanglingIndexAction; import org.elasticsearch.action.admin.indices.dangling.list.ListDanglingIndicesAction; import org.elasticsearch.action.admin.indices.dangling.list.ListDanglingIndicesRequest; import org.elasticsearch.action.admin.indices.dangling.list.ListDanglingIndicesResponse; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.flush.FlushAction; import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder; @@ -877,7 +877,7 @@ public void pendingClusterTasks(PendingClusterTasksRequest request, ActionListen @Override public void putRepository(PutRepositoryRequest request, ActionListener listener) { - execute(PutRepositoryAction.INSTANCE, request, listener); + execute(TransportPutRepositoryAction.TYPE, request, listener); } @Override @@ -907,7 +907,7 @@ public CloneSnapshotRequestBuilder prepareCloneSnapshot(String repository, Strin @Override public void cloneSnapshot(CloneSnapshotRequest request, ActionListener listener) { - execute(CloneSnapshotAction.INSTANCE, request, listener); + execute(TransportCloneSnapshotAction.TYPE, request, listener); } @Override @@ -922,7 +922,7 @@ public GetSnapshotsRequestBuilder prepareGetSnapshots(String... repositories) { @Override public void deleteSnapshot(DeleteSnapshotRequest request, ActionListener listener) { - execute(DeleteSnapshotAction.INSTANCE, request, listener); + execute(TransportDeleteSnapshotAction.TYPE, request, listener); } @Override @@ -932,7 +932,7 @@ public DeleteSnapshotRequestBuilder prepareDeleteSnapshot(String repository, Str @Override public void deleteRepository(DeleteRepositoryRequest request, ActionListener listener) { - execute(DeleteRepositoryAction.INSTANCE, request, listener); + execute(TransportDeleteRepositoryAction.TYPE, request, listener); } @Override @@ -1057,17 +1057,17 @@ public SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference sou @Override public void allocationExplain(ClusterAllocationExplainRequest request, ActionListener listener) { - execute(ClusterAllocationExplainAction.INSTANCE, request, listener); + execute(TransportClusterAllocationExplainAction.TYPE, request, listener); } @Override public ActionFuture allocationExplain(ClusterAllocationExplainRequest request) { - return execute(ClusterAllocationExplainAction.INSTANCE, request); + return execute(TransportClusterAllocationExplainAction.TYPE, request); } @Override public ClusterAllocationExplainRequestBuilder prepareAllocationExplain() { - return new ClusterAllocationExplainRequestBuilder(this, ClusterAllocationExplainAction.INSTANCE); + return new ClusterAllocationExplainRequestBuilder(this); } @Override @@ -1087,22 +1087,22 @@ public void listDanglingIndices(ListDanglingIndicesRequest request, ActionListen @Override public ActionFuture importDanglingIndex(ImportDanglingIndexRequest request) { - return execute(ImportDanglingIndexAction.INSTANCE, request); + return execute(TransportImportDanglingIndexAction.TYPE, request); } @Override public void importDanglingIndex(ImportDanglingIndexRequest request, ActionListener listener) { - execute(ImportDanglingIndexAction.INSTANCE, request, listener); + execute(TransportImportDanglingIndexAction.TYPE, request, listener); } @Override public ActionFuture deleteDanglingIndex(DeleteDanglingIndexRequest request) { - return execute(DeleteDanglingIndexAction.INSTANCE, request); + return execute(TransportDeleteDanglingIndexAction.TYPE, request); } @Override public void deleteDanglingIndex(DeleteDanglingIndexRequest request, ActionListener listener) { - execute(DeleteDanglingIndexAction.INSTANCE, request, listener); + execute(TransportDeleteDanglingIndexAction.TYPE, request, listener); } @Override @@ -1117,13 +1117,13 @@ public PutStoredScriptRequestBuilder preparePutStoredScript() { @Override public void putStoredScript(final PutStoredScriptRequest request, ActionListener listener) { - execute(PutStoredScriptAction.INSTANCE, request, listener); + execute(TransportPutStoredScriptAction.TYPE, request, listener); } @Override public void deleteStoredScript(DeleteStoredScriptRequest request, ActionListener listener) { - execute(DeleteStoredScriptAction.INSTANCE, request, listener); + execute(TransportDeleteStoredScriptAction.TYPE, request, listener); } @Override @@ -1239,12 +1239,12 @@ public CreateIndexRequestBuilder prepareCreate(String index) { @Override public ActionFuture delete(final DeleteIndexRequest request) { - return execute(DeleteIndexAction.INSTANCE, request); + return execute(TransportDeleteIndexAction.TYPE, request); } @Override public void delete(final DeleteIndexRequest request, final ActionListener listener) { - execute(DeleteIndexAction.INSTANCE, request, listener); + execute(TransportDeleteIndexAction.TYPE, request, listener); } @Override diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java b/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java index 05c0876669732..85e201d52f03b 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java @@ -47,11 +47,18 @@ public static long getExpectedShardSize( if (indexMetadata.getResizeSourceIndex() != null && shard.active() == false && shard.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) { + assert shard.primary() : "All replica shards are recovering from " + RecoverySource.Type.PEER; return getExpectedSizeOfResizedShard(shard, defaultValue, indexMetadata, clusterInfo, metadata, routingTable); - } else if (shard.unassigned() && shard.recoverySource().getType() == RecoverySource.Type.SNAPSHOT) { + } else if (shard.active() == false && shard.recoverySource().getType() == RecoverySource.Type.SNAPSHOT) { + assert shard.primary() : "All replica shards are recovering from " + RecoverySource.Type.PEER; return snapshotShardSizeInfo.getShardSize(shard, defaultValue); } else { - return clusterInfo.getShardSize(shard, defaultValue); + var shardSize = clusterInfo.getShardSize(shard.shardId(), shard.primary()); + if (shardSize == null && shard.primary() == false) { + // derive replica size from corresponding primary + shardSize = clusterInfo.getShardSize(shard.shardId(), true); + } + return shardSize == null ? defaultValue : shardSize; } } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index 0e0d15a02d042..e92a6106a6e33 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.core.UpdateForV9; +import org.elasticsearch.snapshots.SnapshotShardSizeInfo; import java.util.Map; @@ -146,7 +147,7 @@ public static long sizeOfUnaccountedShards( routing, Math.max(routing.getExpectedShardSize(), 0L), clusterInfo, - null, + SnapshotShardSizeInfo.EMPTY, metadata, routingTable ); @@ -158,7 +159,7 @@ public static long sizeOfUnaccountedShards( if (subtractShardsMovingAway) { for (ShardRouting routing : node.relocating()) { if (dataPath.equals(clusterInfo.getDataPath(routing))) { - totalSize -= getExpectedShardSize(routing, 0L, clusterInfo, null, metadata, routingTable); + totalSize -= getExpectedShardSize(routing, 0L, clusterInfo, SnapshotShardSizeInfo.EMPTY, metadata, routingTable); } } } diff --git a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java index 9cc9e79ebb11a..162d7311a0594 100644 --- a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java +++ b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java @@ -45,6 +45,9 @@ public class RetentionLeaseActions { public static final long RETAIN_ALL = -1; + public static final ActionType ADD = ActionType.emptyResponse("indices:admin/seq_no/add_retention_lease"); + public static final ActionType RENEW = ActionType.emptyResponse("indices:admin/seq_no/renew_retention_lease"); + public static final ActionType REMOVE = ActionType.emptyResponse("indices:admin/seq_no/remove_retention_lease"); abstract static class TransportRetentionLeaseAction> extends TransportSingleShardAction { @@ -109,139 +112,109 @@ protected boolean resolveIndex(final T request) { } - public static class Add extends ActionType { + public static class TransportAddAction extends TransportRetentionLeaseAction { - public static final Add INSTANCE = new Add(); - public static final String ACTION_NAME = "indices:admin/seq_no/add_retention_lease"; - - private Add() { - super(ACTION_NAME, in -> ActionResponse.Empty.INSTANCE); + @Inject + public TransportAddAction( + final ThreadPool threadPool, + final ClusterService clusterService, + final TransportService transportService, + final ActionFilters actionFilters, + final IndexNameExpressionResolver indexNameExpressionResolver, + final IndicesService indicesService + ) { + super( + ADD.name(), + threadPool, + clusterService, + transportService, + actionFilters, + indexNameExpressionResolver, + indicesService, + AddRequest::new + ); } - public static class TransportAction extends TransportRetentionLeaseAction { - - @Inject - public TransportAction( - final ThreadPool threadPool, - final ClusterService clusterService, - final TransportService transportService, - final ActionFilters actionFilters, - final IndexNameExpressionResolver indexNameExpressionResolver, - final IndicesService indicesService - ) { - super( - ACTION_NAME, - threadPool, - clusterService, - transportService, - actionFilters, - indexNameExpressionResolver, - indicesService, - AddRequest::new - ); - } - - @Override - void doRetentionLeaseAction( - final IndexShard indexShard, - final AddRequest request, - final ActionListener listener - ) { - indexShard.addRetentionLease( - request.getId(), - request.getRetainingSequenceNumber(), - request.getSource(), - listener.map(r -> ActionResponse.Empty.INSTANCE) - ); - } + @Override + void doRetentionLeaseAction( + final IndexShard indexShard, + final AddRequest request, + final ActionListener listener + ) { + indexShard.addRetentionLease( + request.getId(), + request.getRetainingSequenceNumber(), + request.getSource(), + listener.map(r -> ActionResponse.Empty.INSTANCE) + ); } } - public static class Renew extends ActionType { - - public static final Renew INSTANCE = new Renew(); - public static final String ACTION_NAME = "indices:admin/seq_no/renew_retention_lease"; + public static class TransportRenewAction extends TransportRetentionLeaseAction { - private Renew() { - super(ACTION_NAME, in -> ActionResponse.Empty.INSTANCE); + @Inject + public TransportRenewAction( + final ThreadPool threadPool, + final ClusterService clusterService, + final TransportService transportService, + final ActionFilters actionFilters, + final IndexNameExpressionResolver indexNameExpressionResolver, + final IndicesService indicesService + ) { + super( + RENEW.name(), + threadPool, + clusterService, + transportService, + actionFilters, + indexNameExpressionResolver, + indicesService, + RenewRequest::new + ); } - public static class TransportAction extends TransportRetentionLeaseAction { - - @Inject - public TransportAction( - final ThreadPool threadPool, - final ClusterService clusterService, - final TransportService transportService, - final ActionFilters actionFilters, - final IndexNameExpressionResolver indexNameExpressionResolver, - final IndicesService indicesService - ) { - super( - ACTION_NAME, - threadPool, - clusterService, - transportService, - actionFilters, - indexNameExpressionResolver, - indicesService, - RenewRequest::new - ); - } - - @Override - void doRetentionLeaseAction( - final IndexShard indexShard, - final RenewRequest request, - final ActionListener listener - ) { - indexShard.renewRetentionLease(request.getId(), request.getRetainingSequenceNumber(), request.getSource()); - listener.onResponse(ActionResponse.Empty.INSTANCE); - } - + @Override + void doRetentionLeaseAction( + final IndexShard indexShard, + final RenewRequest request, + final ActionListener listener + ) { + indexShard.renewRetentionLease(request.getId(), request.getRetainingSequenceNumber(), request.getSource()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } - } - public static class Remove extends ActionType { + } - public static final Remove INSTANCE = new Remove(); - public static final String ACTION_NAME = "indices:admin/seq_no/remove_retention_lease"; + public static class TransportRemoveAction extends TransportRetentionLeaseAction { - private Remove() { - super(ACTION_NAME, in -> ActionResponse.Empty.INSTANCE); + @Inject + public TransportRemoveAction( + final ThreadPool threadPool, + final ClusterService clusterService, + final TransportService transportService, + final ActionFilters actionFilters, + final IndexNameExpressionResolver indexNameExpressionResolver, + final IndicesService indicesService + ) { + super( + REMOVE.name(), + threadPool, + clusterService, + transportService, + actionFilters, + indexNameExpressionResolver, + indicesService, + RemoveRequest::new + ); } - public static class TransportAction extends TransportRetentionLeaseAction { - - @Inject - public TransportAction( - final ThreadPool threadPool, - final ClusterService clusterService, - final TransportService transportService, - final ActionFilters actionFilters, - final IndexNameExpressionResolver indexNameExpressionResolver, - final IndicesService indicesService - ) { - super( - ACTION_NAME, - threadPool, - clusterService, - transportService, - actionFilters, - indexNameExpressionResolver, - indicesService, - RemoveRequest::new - ); - } - - @Override - void doRetentionLeaseAction( - final IndexShard indexShard, - final RemoveRequest request, - final ActionListener listener - ) { - indexShard.removeRetentionLease(request.getId(), listener.map(r -> ActionResponse.Empty.INSTANCE)); - } + @Override + void doRetentionLeaseAction( + final IndexShard indexShard, + final RemoveRequest request, + final ActionListener listener + ) { + indexShard.removeRetentionLease(request.getId(), listener.map(r -> ActionResponse.Empty.INSTANCE)); } } diff --git a/server/src/main/java/org/elasticsearch/indices/SystemIndices.java b/server/src/main/java/org/elasticsearch/indices/SystemIndices.java index 3ff760b753886..f23f28e4c1047 100644 --- a/server/src/main/java/org/elasticsearch/indices/SystemIndices.java +++ b/server/src/main/java/org/elasticsearch/indices/SystemIndices.java @@ -17,8 +17,8 @@ import org.apache.lucene.util.automaton.Operations; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse.ResetFeatureStateStatus; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.support.RefCountingListener; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.internal.Client; @@ -896,7 +896,7 @@ private static void cleanUpFeatureForIndices( ) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(); deleteIndexRequest.indices(indexNames); - client.execute(DeleteIndexAction.INSTANCE, deleteIndexRequest, new ActionListener<>() { + client.execute(TransportDeleteIndexAction.TYPE, deleteIndexRequest, new ActionListener<>() { @Override public void onResponse(AcknowledgedResponse acknowledgedResponse) { listener.onResponse(ResetFeatureStateStatus.success(name)); diff --git a/server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java b/server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java index e6ec6f25a71a9..61545ada107b6 100644 --- a/server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java +++ b/server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java @@ -320,7 +320,7 @@ private void doRecovery(final long recoveryId, final StartRecoveryRequest preExi assert indexShard.indexSettings().getIndexMetadata().isSearchableSnapshot() == false; try (onCompletion) { client.execute( - StatelessPrimaryRelocationAction.INSTANCE, + StatelessPrimaryRelocationAction.TYPE, new StatelessPrimaryRelocationAction.Request( recoveryId, indexShard.shardId(), diff --git a/server/src/main/java/org/elasticsearch/indices/recovery/StatelessPrimaryRelocationAction.java b/server/src/main/java/org/elasticsearch/indices/recovery/StatelessPrimaryRelocationAction.java index eed6a1d02ae16..490f19fc9111c 100644 --- a/server/src/main/java/org/elasticsearch/indices/recovery/StatelessPrimaryRelocationAction.java +++ b/server/src/main/java/org/elasticsearch/indices/recovery/StatelessPrimaryRelocationAction.java @@ -23,9 +23,8 @@ public class StatelessPrimaryRelocationAction { - public static final ActionType INSTANCE = new ActionType<>( - "internal:index/shard/recovery/stateless_primary_relocation", - in -> ActionResponse.Empty.INSTANCE + public static final ActionType TYPE = ActionType.emptyResponse( + "internal:index/shard/recovery/stateless_primary_relocation" ); public static class Request extends ActionRequest { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java index 2cfc152fdcebd..8c8624f1766b1 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestAddVotingConfigExclusionAction.java @@ -8,8 +8,8 @@ package org.elasticsearch.rest.action.admin.cluster; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.core.RestApiVersion; @@ -54,7 +54,7 @@ public boolean canTripCircuitBreaker() { protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { AddVotingConfigExclusionsRequest votingConfigExclusionsRequest = resolveVotingConfigExclusionsRequest(request); return channel -> client.execute( - AddVotingConfigExclusionsAction.INSTANCE, + TransportAddVotingConfigExclusionsAction.TYPE, votingConfigExclusionsRequest, new RestToXContentListener<>(channel) ); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java index d0797b4b1b8d4..69b51afb8d257 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClearVotingConfigExclusionsAction.java @@ -8,8 +8,8 @@ package org.elasticsearch.rest.action.admin.cluster; -import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -40,7 +40,7 @@ public String getName() { @Override protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { final var req = resolveVotingConfigExclusionsRequest(request); - return channel -> client.execute(ClearVotingConfigExclusionsAction.INSTANCE, req, new RestToXContentListener<>(channel)); + return channel -> client.execute(TransportClearVotingConfigExclusionsAction.TYPE, req, new RestToXContentListener<>(channel)); } static ClearVotingConfigExclusionsRequest resolveVotingConfigExclusionsRequest(final RestRequest request) { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredBalanceAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredBalanceAction.java index d471d6bdaa3e3..66382c20cae82 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredBalanceAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredBalanceAction.java @@ -8,8 +8,8 @@ package org.elasticsearch.rest.action.admin.cluster; -import org.elasticsearch.action.admin.cluster.allocation.DeleteDesiredBalanceAction; import org.elasticsearch.action.admin.cluster.allocation.DesiredBalanceRequest; +import org.elasticsearch.action.admin.cluster.allocation.TransportDeleteDesiredBalanceAction; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -33,7 +33,7 @@ public List routes() { @Override protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { return channel -> client.execute( - DeleteDesiredBalanceAction.INSTANCE, + TransportDeleteDesiredBalanceAction.TYPE, new DesiredBalanceRequest(), new RestToXContentListener<>(channel) ); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredNodesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredNodesAction.java index fbd9dc2f30294..27bcd82075f04 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredNodesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteDesiredNodesAction.java @@ -8,7 +8,7 @@ package org.elasticsearch.rest.action.admin.cluster; -import org.elasticsearch.action.admin.cluster.desirednodes.DeleteDesiredNodesAction; +import org.elasticsearch.action.admin.cluster.desirednodes.TransportDeleteDesiredNodesAction; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -30,10 +30,10 @@ public List routes() { @Override protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { - final DeleteDesiredNodesAction.Request deleteDesiredNodesRequest = new DeleteDesiredNodesAction.Request(); + final TransportDeleteDesiredNodesAction.Request deleteDesiredNodesRequest = new TransportDeleteDesiredNodesAction.Request(); deleteDesiredNodesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteDesiredNodesRequest.masterNodeTimeout())); return restChannel -> client.execute( - DeleteDesiredNodesAction.INSTANCE, + TransportDeleteDesiredNodesAction.TYPE, deleteDesiredNodesRequest, new RestToXContentListener<>(restChannel) ); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetDesiredBalanceAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetDesiredBalanceAction.java index 11732747b2b3a..312ce353b6d42 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetDesiredBalanceAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetDesiredBalanceAction.java @@ -9,7 +9,7 @@ package org.elasticsearch.rest.action.admin.cluster; import org.elasticsearch.action.admin.cluster.allocation.DesiredBalanceRequest; -import org.elasticsearch.action.admin.cluster.allocation.GetDesiredBalanceAction; +import org.elasticsearch.action.admin.cluster.allocation.TransportGetDesiredBalanceAction; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -33,7 +33,7 @@ public List routes() { @Override protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { return restChannel -> client.execute( - GetDesiredBalanceAction.INSTANCE, + TransportGetDesiredBalanceAction.TYPE, new DesiredBalanceRequest(), new RestChunkedToXContentListener<>(restChannel) ); diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardSizeInfo.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardSizeInfo.java index 864303fe6b496..29ae2d1c5da4b 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardSizeInfo.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardSizeInfo.java @@ -9,6 +9,7 @@ package org.elasticsearch.snapshots; import org.elasticsearch.cluster.routing.RecoverySource; +import org.elasticsearch.cluster.routing.RecoverySource.SnapshotRecoverySource; import org.elasticsearch.cluster.routing.ShardRouting; import java.util.Map; @@ -24,11 +25,8 @@ public SnapshotShardSizeInfo(Map listeners = new ConcurrentLinkedQueue<>(); + private final SubscribableListener listeners = new SubscribableListener<>(); public CancellableTask(long id, String type, String action, String description, TaskId parentTaskId, Map headers) { super(id, type, action, description, parentTaskId, headers); @@ -39,7 +39,7 @@ final void cancel(String reason) { this.isCancelled = true; this.reason = reason; } - listeners.forEach(CancellationListener::onCancelled); + listeners.onResponse(null); onCancelled(); } @@ -74,14 +74,7 @@ public final String getReasonCancelled() { * This method adds a listener that needs to be notified if this task is cancelled. */ public final void addListener(CancellationListener listener) { - synchronized (this) { - if (this.isCancelled == false) { - listeners.add(listener); - } - } - if (isCancelled) { - listener.onCancelled(); - } + listeners.addListener(new CancellationListenerAdapter(listener)); } /** @@ -127,4 +120,16 @@ private TaskCancelledException getTaskCancelledException() { public interface CancellationListener { void onCancelled(); } + + private record CancellationListenerAdapter(CancellationListener cancellationListener) implements ActionListener { + @Override + public void onResponse(Void unused) { + cancellationListener.onCancelled(); + } + + @Override + public void onFailure(Exception e) { + assert false : e; + } + } } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionTests.java index a98d7662b8983..a598e58ada75f 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionTests.java @@ -90,7 +90,7 @@ public void initialize() { private static DesiredBalanceResponse execute(TransportGetDesiredBalanceAction action, ClusterState clusterState) throws Exception { return PlainActionFuture.get( future -> action.masterOperation( - new Task(1, "test", GetDesiredBalanceAction.NAME, "", TaskId.EMPTY_TASK_ID, Map.of()), + new Task(1, "test", TransportGetDesiredBalanceAction.TYPE.name(), "", TaskId.EMPTY_TASK_ID, Map.of()), new DesiredBalanceRequest(), clusterState, future diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java index 9f26e0a19c990..5f6540d46c719 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java @@ -179,7 +179,7 @@ public void testWithdrawsVoteFromANode() { clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions()); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest("other1"), expectSuccess(r -> { assertNotNull(r); @@ -197,7 +197,7 @@ public void testWithdrawsVotesFromMultipleNodes() { clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions()); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest("other1", "other2"), expectSuccess(r -> { assertNotNull(r); @@ -230,7 +230,7 @@ public void testReturnsImmediatelyIfVoteAlreadyWithdrawn() { // no observer to reconfigure transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest("other1"), expectSuccess(r -> { assertNotNull(r); @@ -247,7 +247,7 @@ public void testExcludeAbsentNodesByNodeIds() { final var countDownLatch = new CountDownLatch(1); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest(new String[] { "absent_id" }, Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)), expectSuccess(r -> { final var state = clusterService.getClusterApplierService().state(); @@ -267,7 +267,7 @@ public void testExcludeExistingNodesByNodeIds() { clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions()); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest(new String[] { "other1", "other2" }, Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)), expectSuccess(r -> { assertNotNull(r); @@ -284,7 +284,7 @@ public void testExcludeAbsentNodesByNodeNames() { final var countDownLatch = new CountDownLatch(1); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest("absent_node"), expectSuccess(r -> { final var state = clusterService.getClusterApplierService().state(); @@ -304,7 +304,7 @@ public void testExcludeExistingNodesByNodeNames() { clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions()); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest("other1", "other2"), expectSuccess(r -> { assertNotNull(r); @@ -332,7 +332,7 @@ public void testTriggersReconfigurationEvenIfAllExclusionsAlreadyAddedButStillIn clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions()); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), randomFrom( new AddVotingConfigExclusionsRequest("other1"), new AddVotingConfigExclusionsRequest(new String[] { "other1" }, Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)) @@ -367,7 +367,7 @@ public void testExcludeByNodeIdSucceedsEvenIfAllExclusionsAlreadyAdded() { clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions()); transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest(new String[] { "other1" }, Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)), expectSuccess(r -> { assertNotNull(r); @@ -399,7 +399,7 @@ public void testExcludeByNodeNameSucceedsEvenIfAllExclusionsAlreadyAdded() { transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest("other1"), expectSuccess(r -> { assertNotNull(r); @@ -456,7 +456,7 @@ public void testReturnsErrorIfMaximumExclusionCountExceeded() { transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest("other1", "other2"), expectError(e -> { final Throwable rootCause = e.getRootCause(); @@ -484,7 +484,7 @@ public void testTimesOut() { transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest(Strings.EMPTY_ARRAY, new String[] { "other1" }, TimeValue.timeValueMillis(100)), expectError(e -> { final Throwable rootCause = e.getRootCause(); @@ -503,7 +503,7 @@ public void testCannotAddVotingConfigExclusionsWhenItIsDisabled() { transportService.sendRequest( localNode, - AddVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), new AddVotingConfigExclusionsRequest(Strings.EMPTY_ARRAY, new String[] { "other1" }, TimeValue.timeValueMillis(100)), expectError(e -> { final Throwable rootCause = e.getRootCause(); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java index 2193e07f84f38..17a22ff8e82fd 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java @@ -122,7 +122,7 @@ public void testClearsVotingConfigExclusions() { clearVotingConfigExclusionsRequest.setWaitForRemoval(false); transportService.sendRequest( localNode, - ClearVotingConfigExclusionsAction.NAME, + TransportClearVotingConfigExclusionsAction.TYPE.name(), clearVotingConfigExclusionsRequest, expectSuccess(r -> { assertNotNull(r); @@ -140,7 +140,7 @@ public void testTimesOutIfWaitingForNodesThatAreNotRemoved() { clearVotingConfigExclusionsRequest.setTimeout(TimeValue.timeValueMillis(100)); transportService.sendRequest( localNode, - ClearVotingConfigExclusionsAction.NAME, + TransportClearVotingConfigExclusionsAction.TYPE.name(), clearVotingConfigExclusionsRequest, expectError(e -> { assertThat( @@ -164,7 +164,7 @@ public void testSucceedsIfNodesAreRemovedWhileWaiting() { transportService.sendRequest( localNode, - ClearVotingConfigExclusionsAction.NAME, + TransportClearVotingConfigExclusionsAction.TYPE.name(), new ClearVotingConfigExclusionsRequest(), expectSuccess(r -> { assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(), empty()); @@ -186,7 +186,7 @@ public void testCannotClearVotingConfigurationWhenItIsDisabled() { transportService.sendRequest( localNode, - ClearVotingConfigExclusionsAction.NAME, + TransportClearVotingConfigExclusionsAction.TYPE.name(), new ClearVotingConfigExclusionsRequest(), expectError(e -> { final Throwable rootCause = e.getRootCause(); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java index 0cc1588b814c5..345f85470a056 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java @@ -31,6 +31,7 @@ import org.elasticsearch.tasks.TaskId; import org.elasticsearch.tasks.TaskInfo; import org.elasticsearch.tasks.TaskManager; +import org.elasticsearch.test.ReachabilityChecker; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.FakeTcpChannel; import org.elasticsearch.transport.TestTransportChannels; @@ -649,4 +650,16 @@ public void onFailure(Exception e) { concurrentNotify.join(); } + public void testReleaseListenersOnCancellation() { + final CancellableTask task = new CancellableTask(randomLong(), "transport", "action", "", TaskId.EMPTY_TASK_ID, emptyMap()); + final AtomicBoolean cancelNotified = new AtomicBoolean(); + final ReachabilityChecker reachabilityChecker = new ReachabilityChecker(); + task.addListener(reachabilityChecker.register(() -> assertTrue(cancelNotified.compareAndSet(false, true)))); + + reachabilityChecker.checkReachable(); + TaskCancelHelper.cancel(task, "simulated"); + reachabilityChecker.ensureUnreachable(); + assertTrue(cancelNotified.get()); + } + } diff --git a/server/src/test/java/org/elasticsearch/client/internal/AbstractClientHeadersTestCase.java b/server/src/test/java/org/elasticsearch/client/internal/AbstractClientHeadersTestCase.java index 01acbfe06b9fd..5175fee7edceb 100644 --- a/server/src/test/java/org/elasticsearch/client/internal/AbstractClientHeadersTestCase.java +++ b/server/src/test/java/org/elasticsearch/client/internal/AbstractClientHeadersTestCase.java @@ -14,7 +14,7 @@ import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteAction; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotAction; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction; -import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptAction; +import org.elasticsearch.action.admin.cluster.storedscripts.TransportDeleteStoredScriptAction; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.flush.FlushAction; @@ -50,7 +50,7 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase { TransportGetAction.TYPE, TransportSearchAction.TYPE, TransportDeleteAction.TYPE, - DeleteStoredScriptAction.INSTANCE, + TransportDeleteStoredScriptAction.TYPE, TransportIndexAction.TYPE, // cluster admin actions @@ -102,7 +102,7 @@ public void testActions() { client.admin() .cluster() .prepareDeleteStoredScript("id") - .execute(new AssertingActionListener<>(DeleteStoredScriptAction.NAME, client.threadPool())); + .execute(new AssertingActionListener<>(TransportDeleteStoredScriptAction.TYPE.name(), client.threadPool())); client.prepareIndex("idx") .setId("id") .setSource("source", XContentType.JSON) diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java index c894585edd776..62fd21defa676 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java @@ -59,6 +59,19 @@ public void testShouldReadExpectedSizeFromClusterInfo() { assertThat(getExpectedShardSize(shard, defaultValue, allocation), equalTo(shardSize)); } + public void testShouldReadExpectedSizeFromPrimaryWhenAddingNewReplica() { + + var shardSize = randomLongBetween(100, 1000); + var state = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata(index("my-index"))).build(); + var primary = newShardRouting("my-index", 0, randomIdentifier(), true, ShardRoutingState.STARTED); + var replica = newShardRouting("my-index", 0, randomIdentifier(), false, ShardRoutingState.INITIALIZING); + + var clusterInfo = createClusterInfo(primary, shardSize); + var allocation = createRoutingAllocation(state, clusterInfo, SnapshotShardSizeInfo.EMPTY); + + assertThat(getExpectedShardSize(replica, defaultValue, allocation), equalTo(shardSize)); + } + public void testShouldReadExpectedSizeWhenInitializingFromSnapshot() { var snapshotShardSize = randomLongBetween(100, 1000); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java index 4471ed678b013..6283b721cf9bd 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java @@ -20,10 +20,10 @@ import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; -import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexVersion; +import org.elasticsearch.index.shard.ShardId; import static org.elasticsearch.cluster.routing.RoutingNodesHelper.shardsWithState; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; @@ -50,9 +50,9 @@ public void testRebalanceOnlyAfterAllShardsAreActive() { .build(), () -> new ClusterInfo() { @Override - public Long getShardSize(ShardRouting shardRouting) { - if (shardRouting.getIndexName().equals("test")) { - return sizes[shardRouting.getId()]; + public Long getShardSize(ShardId shardId, boolean primary) { + if (shardId.getIndexName().equals("test")) { + return sizes[shardId.getId()]; } return null; } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java index 88c7dc24b4089..b54480cdc0856 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java @@ -507,13 +507,8 @@ public void testShardSizeAndRelocatingSize() { test_2, other_0.getTargetRelocatingShard() ); - if (other_0.primary()) { - assertEquals(10100L, sizeOfUnaccountedShards(allocation, node, false, "/dev/null")); - assertEquals(10090L, sizeOfUnaccountedShards(allocation, node, true, "/dev/null")); - } else { - assertEquals(100L, sizeOfUnaccountedShards(allocation, node, false, "/dev/null")); - assertEquals(90L, sizeOfUnaccountedShards(allocation, node, true, "/dev/null")); - } + assertEquals(10100L, sizeOfUnaccountedShards(allocation, node, false, "/dev/null")); + assertEquals(10090L, sizeOfUnaccountedShards(allocation, node, true, "/dev/null")); } public void testTakesIntoAccountExpectedSizeForInitializingSearchableSnapshots() { diff --git a/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java b/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java index 7448814c5c1ad..3949770ae09ba 100644 --- a/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java +++ b/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java @@ -45,7 +45,7 @@ public void testAddAction() { final long retainingSequenceNumber = randomBoolean() ? RETAIN_ALL : randomNonNegativeLong(); final String source = randomAlphaOfLength(8); client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(indexService.getShard(0).shardId(), id, retainingSequenceNumber, source) ).actionGet(); @@ -76,7 +76,7 @@ public void testAddAlreadyExists() { final long retainingSequenceNumber = randomBoolean() ? RETAIN_ALL : randomNonNegativeLong(); final String source = randomAlphaOfLength(8); client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(indexService.getShard(0).shardId(), id, retainingSequenceNumber, source) ).actionGet(); @@ -87,7 +87,7 @@ public void testAddAlreadyExists() { final RetentionLeaseAlreadyExistsException e = expectThrows( RetentionLeaseAlreadyExistsException.class, () -> client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(indexService.getShard(0).shardId(), id, nextRetainingSequenceNumber, source) ).actionGet() ); @@ -112,7 +112,7 @@ public void testRenewAction() throws InterruptedException { final TimeValue estimatedTimeInterval = ThreadPool.ESTIMATED_TIME_INTERVAL_SETTING.get(node().settings()); client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(indexService.getShard(0).shardId(), id, retainingSequenceNumber, source) ).actionGet(); @@ -155,7 +155,7 @@ public void testRenewAction() throws InterruptedException { } while (threadPool.absoluteTimeInMillis() <= timestampUpperBound); client().execute( - RetentionLeaseActions.Renew.INSTANCE, + RetentionLeaseActions.RENEW, new RetentionLeaseActions.RenewRequest(indexService.getShard(0).shardId(), id, nextRetainingSequenceNumber, source) ).actionGet(); @@ -193,7 +193,7 @@ public void testRenewNotFound() { final RetentionLeaseNotFoundException e = expectThrows( RetentionLeaseNotFoundException.class, () -> client().execute( - RetentionLeaseActions.Renew.INSTANCE, + RetentionLeaseActions.RENEW, new RetentionLeaseActions.RenewRequest(indexService.getShard(0).shardId(), id, retainingSequenceNumber, source) ).actionGet() ); @@ -209,14 +209,12 @@ public void testRemoveAction() { final long retainingSequenceNumber = randomBoolean() ? RETAIN_ALL : randomNonNegativeLong(); final String source = randomAlphaOfLength(8); client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(indexService.getShard(0).shardId(), id, retainingSequenceNumber, source) ).actionGet(); - client().execute( - RetentionLeaseActions.Remove.INSTANCE, - new RetentionLeaseActions.RemoveRequest(indexService.getShard(0).shardId(), id) - ).actionGet(); + client().execute(RetentionLeaseActions.REMOVE, new RetentionLeaseActions.RemoveRequest(indexService.getShard(0).shardId(), id)) + .actionGet(); final IndicesStatsResponse stats = client().execute(IndicesStatsAction.INSTANCE, new IndicesStatsRequest().indices("index")) .actionGet(); @@ -241,7 +239,7 @@ public void testRemoveNotFound() { final RetentionLeaseNotFoundException e = expectThrows( RetentionLeaseNotFoundException.class, () -> client().execute( - RetentionLeaseActions.Remove.INSTANCE, + RetentionLeaseActions.REMOVE, new RetentionLeaseActions.RemoveRequest(indexService.getShard(0).shardId(), id) ).actionGet() ); @@ -258,7 +256,7 @@ public void testAddUnderBlock() throws InterruptedException { runActionUnderBlockTest( indexService, (shardId, actionLatch) -> client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(shardId, id, retainingSequenceNumber, source), new ActionListener<>() { @@ -310,7 +308,7 @@ public void testRenewUnderBlock() throws InterruptedException { final TimeValue estimatedTimeInterval = ThreadPool.ESTIMATED_TIME_INTERVAL_SETTING.get(node().settings()); client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(indexService.getShard(0).shardId(), id, retainingSequenceNumber, source) ).actionGet(); @@ -355,7 +353,7 @@ public void testRenewUnderBlock() throws InterruptedException { runActionUnderBlockTest( indexService, (shardId, actionLatch) -> client().execute( - RetentionLeaseActions.Renew.INSTANCE, + RetentionLeaseActions.RENEW, new RetentionLeaseActions.RenewRequest(shardId, id, nextRetainingSequenceNumber, source), new ActionListener<>() { @@ -404,14 +402,14 @@ public void testRemoveUnderBlock() throws InterruptedException { final String source = randomAlphaOfLength(8); client().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(indexService.getShard(0).shardId(), id, retainingSequenceNumber, source) ).actionGet(); runActionUnderBlockTest( indexService, (shardId, actionLatch) -> client().execute( - RetentionLeaseActions.Remove.INSTANCE, + RetentionLeaseActions.REMOVE, new RetentionLeaseActions.RemoveRequest(shardId, id), new ActionListener<>() { diff --git a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java index c5d5ecc1f90e8..ad09c58b65cba 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java @@ -19,7 +19,6 @@ import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryResponse; import org.elasticsearch.action.admin.cluster.repositories.cleanup.TransportCleanupRepositoryAction; -import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.put.TransportPutRepositoryAction; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteAction; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequest; @@ -27,7 +26,6 @@ import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.elasticsearch.action.admin.cluster.snapshots.create.TransportCreateSnapshotAction; -import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.delete.TransportDeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotAction; @@ -42,7 +40,6 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.mapping.put.AutoPutMappingAction; @@ -2036,7 +2033,7 @@ protected void assertSnapshotOrGenericThread() { ) ); actions.put( - DeleteIndexAction.INSTANCE, + TransportDeleteIndexAction.TYPE, new TransportDeleteIndexAction( transportService, clusterService, @@ -2048,7 +2045,7 @@ protected void assertSnapshotOrGenericThread() { ) ); actions.put( - PutRepositoryAction.INSTANCE, + TransportPutRepositoryAction.TYPE, new TransportPutRepositoryAction( transportService, clusterService, @@ -2126,7 +2123,7 @@ protected void assertSnapshotOrGenericThread() { ) ); actions.put( - DeleteSnapshotAction.INSTANCE, + TransportDeleteSnapshotAction.TYPE, new TransportDeleteSnapshotAction( transportService, clusterService, diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 0ce970943cc0b..38c38e719138e 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -17,10 +17,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.store.AlreadyClosedException; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest; -import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; +import org.elasticsearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; @@ -1906,7 +1906,7 @@ private Set excludeMasters(Collection nodeAndClients) { logger.info("adding voting config exclusions {} prior to restart/shutdown", excludedNodeNames); try { client().execute( - AddVotingConfigExclusionsAction.INSTANCE, + TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(excludedNodeNames.toArray(Strings.EMPTY_ARRAY)) ).get(); } catch (InterruptedException | ExecutionException e) { @@ -1923,7 +1923,7 @@ private void removeExclusions(Set excludedNodeIds) { logger.info("removing voting config exclusions for {} after restart/shutdown", excludedNodeIds); try { Client client = getRandomNodeAndClient(node -> excludedNodeIds.contains(node.name) == false).client(); - client.execute(ClearVotingConfigExclusionsAction.INSTANCE, new ClearVotingConfigExclusionsRequest()).get(); + client.execute(TransportClearVotingConfigExclusionsAction.TYPE, new ClearVotingConfigExclusionsRequest()).get(); } catch (InterruptedException | ExecutionException e) { ESTestCase.fail(e); } diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java index ef1aa8c5f95ab..86cabb37f00e6 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java @@ -811,12 +811,7 @@ public String getDataPath(ShardRouting shardRouting) { } @Override - public long getShardSize(ShardRouting shardRouting, long defaultValue) { - return 1L; - } - - @Override - public Long getShardSize(ShardRouting shardRouting) { + public Long getShardSize(ShardId shardId, boolean primary) { return 1L; } }; diff --git a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java index 811f35d2ddec1..339662c996492 100644 --- a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java +++ b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java @@ -438,8 +438,8 @@ public void testUnfollowRemovesRetentionLeases() throws Exception { senderNode.getName() ); senderTransportService.addSendBehavior((connection, requestId, action, request, options) -> { - if (RetentionLeaseActions.Remove.ACTION_NAME.equals(action) - || TransportActionProxy.getProxyAction(RetentionLeaseActions.Remove.ACTION_NAME).equals(action)) { + if (RetentionLeaseActions.REMOVE.name().equals(action) + || TransportActionProxy.getProxyAction(RetentionLeaseActions.REMOVE.name()).equals(action)) { final RetentionLeaseActions.RemoveRequest removeRequest = (RetentionLeaseActions.RemoveRequest) request; if (shardIds.contains(removeRequest.getShardId().id())) { final String primaryShardNodeId = getLeaderCluster().clusterService() @@ -526,8 +526,8 @@ public void testUnfollowFailsToRemoveRetentionLeases() throws Exception { senderNode.getName() ); senderTransportService.addSendBehavior((connection, requestId, action, request, options) -> { - if (RetentionLeaseActions.Remove.ACTION_NAME.equals(action) - || TransportActionProxy.getProxyAction(RetentionLeaseActions.Remove.ACTION_NAME).equals(action)) { + if (RetentionLeaseActions.REMOVE.name().equals(action) + || TransportActionProxy.getProxyAction(RetentionLeaseActions.REMOVE.name()).equals(action)) { final RetentionLeaseActions.RemoveRequest removeRequest = (RetentionLeaseActions.RemoveRequest) request; if (shardIds.contains(removeRequest.getShardId().id())) { throw randomBoolean() @@ -847,8 +847,8 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep senderNode.getName() ); senderTransportService.addSendBehavior((connection, requestId, action, request, options) -> { - if (RetentionLeaseActions.Renew.ACTION_NAME.equals(action) - || TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) { + if (RetentionLeaseActions.RENEW.name().equals(action) + || TransportActionProxy.getProxyAction(RetentionLeaseActions.RENEW.name()).equals(action)) { final RetentionLeaseActions.RenewRequest renewRequest = (RetentionLeaseActions.RenewRequest) request; final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex); if (retentionLeaseId.equals(renewRequest.getId())) { @@ -957,8 +957,8 @@ public void testPeriodicRenewalDoesNotAddRetentionLeaseAfterUnfollow() throws Ex senderNode.getName() ); senderTransportService.addSendBehavior((connection, requestId, action, request, options) -> { - if (RetentionLeaseActions.Renew.ACTION_NAME.equals(action) - || TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) { + if (RetentionLeaseActions.RENEW.name().equals(action) + || TransportActionProxy.getProxyAction(RetentionLeaseActions.RENEW.name()).equals(action)) { final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex); logger.info("--> blocking renewal request for retention lease [{}] until unfollowed", retentionLeaseId); try { diff --git a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java index 2adf046e6ba58..070338c07003c 100644 --- a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java @@ -1348,10 +1348,8 @@ public void testIndexFallBehind() throws Exception { final IndexRoutingTable indexRoutingTable = leaderRoutingTable.index("index1"); for (int i = 0; i < indexRoutingTable.size(); i++) { final ShardId shardId = indexRoutingTable.shard(i).shardId(); - leaderClient().execute( - RetentionLeaseActions.Remove.INSTANCE, - new RetentionLeaseActions.RemoveRequest(shardId, retentionLeaseId) - ).get(); + leaderClient().execute(RetentionLeaseActions.REMOVE, new RetentionLeaseActions.RemoveRequest(shardId, retentionLeaseId)) + .get(); } }, exceptions -> assertThat(exceptions.size(), greaterThan(0))); } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java index 651cf22797192..a73a3dc5d715f 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java @@ -112,7 +112,7 @@ public static void asyncAddRetentionLease( retainingSequenceNumber, "ccr" ); - remoteClient.execute(RetentionLeaseActions.Add.INSTANCE, request, listener); + remoteClient.execute(RetentionLeaseActions.ADD, request, listener); } /** @@ -167,7 +167,7 @@ public static void asyncRenewRetentionLease( retainingSequenceNumber, "ccr" ); - remoteClient.execute(RetentionLeaseActions.Renew.INSTANCE, request, listener); + remoteClient.execute(RetentionLeaseActions.RENEW, request, listener); } /** @@ -187,7 +187,7 @@ public static void asyncRemoveRetentionLease( final ActionListener listener ) { final RetentionLeaseActions.RemoveRequest request = new RetentionLeaseActions.RemoveRequest(leaderShardId, retentionLeaseId); - remoteClient.execute(RetentionLeaseActions.Remove.INSTANCE, request, listener); + remoteClient.execute(RetentionLeaseActions.REMOVE, request, listener); } } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java index 2f0643ef16c1b..78d997ef9d777 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesTests.java @@ -134,7 +134,7 @@ public void testMissingOperations() throws Exception { client().admin().indices().forceMerge(forceMergeRequest).actionGet(); indicesAdmin().execute( - RetentionLeaseActions.Add.INSTANCE, + RetentionLeaseActions.ADD, new RetentionLeaseActions.AddRequest(new ShardId(resolveIndex("index"), 0), "test", RetentionLeaseActions.RETAIN_ALL, "ccr") ).get(); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java index a1c52728e9a7a..099f15eb59e46 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java @@ -77,7 +77,7 @@ public void testWhenRetentionLeaseAlreadyExistsWeTryToRenewIt() { final ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; listener.onFailure(new RetentionLeaseAlreadyExistsException(retentionLeaseId)); return null; - }).when(remoteClient).execute(same(RetentionLeaseActions.Add.INSTANCE), addRequestCaptor.capture(), any()); + }).when(remoteClient).execute(same(RetentionLeaseActions.ADD), addRequestCaptor.capture(), any()); final ArgumentCaptor renewRequestCaptor = ArgumentCaptor.forClass( RetentionLeaseActions.RenewRequest.class ); @@ -86,17 +86,17 @@ public void testWhenRetentionLeaseAlreadyExistsWeTryToRenewIt() { final ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; listener.onResponse(ActionResponse.Empty.INSTANCE); return null; - }).when(remoteClient).execute(same(RetentionLeaseActions.Renew.INSTANCE), renewRequestCaptor.capture(), any()); + }).when(remoteClient).execute(same(RetentionLeaseActions.RENEW), renewRequestCaptor.capture(), any()); repository.acquireRetentionLeaseOnLeader(followerShardId, retentionLeaseId, leaderShardId, remoteClient); - verify(remoteClient).execute(same(RetentionLeaseActions.Add.INSTANCE), any(RetentionLeaseActions.AddRequest.class), any()); + verify(remoteClient).execute(same(RetentionLeaseActions.ADD), any(RetentionLeaseActions.AddRequest.class), any()); assertThat(addRequestCaptor.getValue().getShardId(), equalTo(leaderShardId)); assertThat(addRequestCaptor.getValue().getId(), equalTo(retentionLeaseId)); assertThat(addRequestCaptor.getValue().getRetainingSequenceNumber(), equalTo(RETAIN_ALL)); assertThat(addRequestCaptor.getValue().getSource(), equalTo("ccr")); - verify(remoteClient).execute(same(RetentionLeaseActions.Renew.INSTANCE), any(RetentionLeaseActions.RenewRequest.class), any()); + verify(remoteClient).execute(same(RetentionLeaseActions.RENEW), any(RetentionLeaseActions.RenewRequest.class), any()); assertThat(renewRequestCaptor.getValue().getShardId(), equalTo(leaderShardId)); assertThat(renewRequestCaptor.getValue().getId(), equalTo(retentionLeaseId)); assertThat(renewRequestCaptor.getValue().getRetainingSequenceNumber(), equalTo(RETAIN_ALL)); @@ -162,7 +162,7 @@ public Void answer(final InvocationOnMock invocationOnMock) { return null; } - }).when(remoteClient).execute(same(RetentionLeaseActions.Add.INSTANCE), addRequestCaptor.capture(), any()); + }).when(remoteClient).execute(same(RetentionLeaseActions.ADD), addRequestCaptor.capture(), any()); final ArgumentCaptor renewRequestCaptor = ArgumentCaptor.forClass( RetentionLeaseActions.RenewRequest.class ); @@ -171,21 +171,17 @@ public Void answer(final InvocationOnMock invocationOnMock) { final ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; listener.onFailure(new RetentionLeaseNotFoundException(retentionLeaseId)); return null; - }).when(remoteClient).execute(same(RetentionLeaseActions.Renew.INSTANCE), renewRequestCaptor.capture(), any()); + }).when(remoteClient).execute(same(RetentionLeaseActions.RENEW), renewRequestCaptor.capture(), any()); repository.acquireRetentionLeaseOnLeader(followerShardId, retentionLeaseId, leaderShardId, remoteClient); - verify(remoteClient, times(2)).execute( - same(RetentionLeaseActions.Add.INSTANCE), - any(RetentionLeaseActions.AddRequest.class), - any() - ); + verify(remoteClient, times(2)).execute(same(RetentionLeaseActions.ADD), any(RetentionLeaseActions.AddRequest.class), any()); assertThat(addRequestCaptor.getValue().getShardId(), equalTo(leaderShardId)); assertThat(addRequestCaptor.getValue().getId(), equalTo(retentionLeaseId)); assertThat(addRequestCaptor.getValue().getRetainingSequenceNumber(), equalTo(RETAIN_ALL)); assertThat(addRequestCaptor.getValue().getSource(), equalTo("ccr")); - verify(remoteClient).execute(same(RetentionLeaseActions.Renew.INSTANCE), any(RetentionLeaseActions.RenewRequest.class), any()); + verify(remoteClient).execute(same(RetentionLeaseActions.RENEW), any(RetentionLeaseActions.RenewRequest.class), any()); assertThat(renewRequestCaptor.getValue().getShardId(), equalTo(leaderShardId)); assertThat(renewRequestCaptor.getValue().getId(), equalTo(retentionLeaseId)); assertThat(renewRequestCaptor.getValue().getRetainingSequenceNumber(), equalTo(RETAIN_ALL)); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutAction.java deleted file mode 100644 index 8e51b2d18375c..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutAction.java +++ /dev/null @@ -1,23 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -package org.elasticsearch.xpack.core.security.action.saml; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; - -/** - * ActionType for completing SAML LogoutResponse - */ -public final class SamlCompleteLogoutAction extends ActionType { - - public static final String NAME = "cluster:admin/xpack/security/saml/complete_logout"; - public static final SamlCompleteLogoutAction INSTANCE = new SamlCompleteLogoutAction(); - - private SamlCompleteLogoutAction() { - super(NAME, in -> ActionResponse.Empty.INSTANCE); - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordAction.java deleted file mode 100644 index 906ec22a7cea4..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordAction.java +++ /dev/null @@ -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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -package org.elasticsearch.xpack.core.security.action.user; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; - -public class ChangePasswordAction extends ActionType { - - public static final ChangePasswordAction INSTANCE = new ChangePasswordAction(); - public static final String NAME = "cluster:admin/xpack/security/user/change_password"; - - protected ChangePasswordAction() { - super(NAME, in -> ActionResponse.Empty.INSTANCE); - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledAction.java deleted file mode 100644 index c257764f6f6e8..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledAction.java +++ /dev/null @@ -1,23 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -package org.elasticsearch.xpack.core.security.action.user; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; - -/** - * This action is for setting the enabled flag on a native or reserved user - */ -public class SetEnabledAction extends ActionType { - - public static final SetEnabledAction INSTANCE = new SetEnabledAction(); - public static final String NAME = "cluster:admin/xpack/security/user/set_enabled"; - - private SetEnabledAction() { - super(NAME, in -> ActionResponse.Empty.INSTANCE); - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java index ca8932ced81b4..4968352439fb0 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java @@ -14,7 +14,7 @@ import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexAction; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsAction; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; @@ -112,7 +112,7 @@ public final class IndexPrivilege extends Privilege { AutoCreateAction.NAME, CreateDataStreamAction.NAME ); - private static final Automaton DELETE_INDEX_AUTOMATON = patterns(DeleteIndexAction.NAME, DeleteDataStreamAction.NAME); + private static final Automaton DELETE_INDEX_AUTOMATON = patterns(TransportDeleteIndexAction.TYPE.name(), DeleteDataStreamAction.NAME); private static final Automaton VIEW_METADATA_AUTOMATON = patterns( GetAliasesAction.NAME, GetIndexAction.NAME, @@ -152,9 +152,9 @@ public final class IndexPrivilege extends Privilege { private static final Automaton CROSS_CLUSTER_REPLICATION_AUTOMATON = patterns( "indices:data/read/xpack/ccr/shard_changes*", IndicesStatsAction.NAME + "*", - RetentionLeaseActions.Add.ACTION_NAME + "*", - RetentionLeaseActions.Remove.ACTION_NAME + "*", - RetentionLeaseActions.Renew.ACTION_NAME + "*" + RetentionLeaseActions.ADD.name() + "*", + RetentionLeaseActions.REMOVE.name() + "*", + RetentionLeaseActions.RENEW.name() + "*" ); private static final Automaton CROSS_CLUSTER_REPLICATION_INTERNAL_AUTOMATON = patterns( "indices:internal/admin/ccr/restore/session/clear*", diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java index bc42632507256..2616b63df7c01 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java @@ -34,9 +34,9 @@ public final class SystemPrivilege extends Privilege { "indices:admin/seq_no/global_checkpoint_sync*", // needed for global checkpoint syncs RetentionLeaseSyncAction.ACTION_NAME + "*", // needed for retention lease syncs RetentionLeaseBackgroundSyncAction.ACTION_NAME + "*", // needed for background retention lease syncs - RetentionLeaseActions.Add.ACTION_NAME + "*", // needed for CCR to add retention leases - RetentionLeaseActions.Remove.ACTION_NAME + "*", // needed for CCR to remove retention leases - RetentionLeaseActions.Renew.ACTION_NAME + "*", // needed for CCR to renew retention leases + RetentionLeaseActions.ADD.name() + "*", // needed for CCR to add retention leases + RetentionLeaseActions.REMOVE.name() + "*", // needed for CCR to remove retention leases + RetentionLeaseActions.RENEW.name() + "*", // needed for CCR to renew retention leases "indices:admin/settings/update", // needed for DiskThresholdMonitor.markIndicesReadOnly CompletionPersistentTaskAction.NAME, // needed for ShardFollowTaskCleaner "indices:data/write/*", // needed for SystemIndexMigrator diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java index fc0df87425239..474ba25e3e117 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java @@ -8,7 +8,7 @@ package org.elasticsearch.xpack.core.security.authz.store; import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.rollover.RolloverAction; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction; @@ -285,7 +285,7 @@ static RoleDescriptor kibanaSystem(String name) { "synthetics-browser.network-*", "synthetics-browser.screenshot-*" ) - .privileges(DeleteIndexAction.NAME) + .privileges(TransportDeleteIndexAction.TYPE.name()) .build(), // For src/dest indices of the Endpoint package that ships a transform RoleDescriptor.IndicesPrivileges.builder() @@ -326,7 +326,7 @@ static RoleDescriptor kibanaSystem(String name) { .indices("logs-ti_*.*-*") .privileges( // Require "delete_index" to perform ILM policy actions - DeleteIndexAction.NAME, + TransportDeleteIndexAction.TYPE.name(), // Require "read" and "view_index_metadata" for transform "read", "view_index_metadata" diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStepTests.java index 90482be334363..be6338a566669 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStepTests.java @@ -10,8 +10,8 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; @@ -143,7 +143,7 @@ protected void Request request, ActionListener listener ) { - assertThat(action.name(), is(DeleteIndexAction.NAME)); + assertThat(action.name(), is(TransportDeleteIndexAction.TYPE.name())); assertTrue(request instanceof DeleteIndexRequest); assertThat(((DeleteIndexRequest) request).indices(), arrayContaining(shrinkIndexName)); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupSnapshotStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupSnapshotStepTests.java index 5fddcd51a6614..c7e9cc707aa02 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupSnapshotStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupSnapshotStepTests.java @@ -10,8 +10,8 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotAction; import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest; +import org.elasticsearch.action.admin.cluster.snapshots.delete.TransportDeleteSnapshotAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -124,7 +124,7 @@ protected void Request request, ActionListener listener ) { - assertThat(action.name(), is(DeleteSnapshotAction.NAME)); + assertThat(action.name(), is(TransportDeleteSnapshotAction.TYPE.name())); assertTrue(request instanceof DeleteSnapshotRequest); assertThat(((DeleteSnapshotRequest) request).snapshots(), arrayContaining(expectedSnapshotName)); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupTargetIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupTargetIndexStepTests.java index dea53b2c736ac..679fd8835a648 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupTargetIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CleanupTargetIndexStepTests.java @@ -10,8 +10,8 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; @@ -173,7 +173,7 @@ protected void Request request, ActionListener listener ) { - assertThat(action.name(), is(DeleteIndexAction.NAME)); + assertThat(action.name(), is(TransportDeleteIndexAction.TYPE.name())); assertTrue(request instanceof DeleteIndexRequest); assertThat(((DeleteIndexRequest) request).indices(), arrayContaining(shrinkIndexName)); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/permission/LimitedRoleTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/permission/LimitedRoleTests.java index 7ab450fc2e191..46c393d9f0de2 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/permission/LimitedRoleTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/permission/LimitedRoleTests.java @@ -9,7 +9,7 @@ import org.apache.lucene.util.automaton.Automaton; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.cluster.metadata.AliasMetadata; @@ -339,7 +339,7 @@ public void testAuthorize() { assertThat(iac.getIndexPermissions("_index1"), is(nullValue())); assertThat(iac.hasIndexPermissions("_index1"), is(false)); iac = limitedByRole.authorize( - DeleteIndexAction.NAME, + TransportDeleteIndexAction.TYPE.name(), Sets.newHashSet("_index", "_alias1"), md.getIndicesLookup(), fieldPermissionsCache @@ -379,7 +379,7 @@ public void testAuthorize() { assertThat(iac.getIndexPermissions("_index1"), is(nullValue())); assertThat(iac.hasIndexPermissions("_index1"), is(false)); iac = role.authorize( - DeleteIndexAction.NAME, + TransportDeleteIndexAction.TYPE.name(), Sets.newHashSet("_index", "_alias1"), md.getIndicesLookup(), fieldPermissionsCache diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java index ed77e9a1d4d9a..831dc58e14003 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.remote.TransportRemoteInfoAction; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesAction; -import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryAction; +import org.elasticsearch.action.admin.cluster.repositories.put.TransportPutRepositoryAction; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsAction; @@ -23,7 +23,7 @@ import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexAction; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsAction; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; @@ -308,7 +308,7 @@ public void testSnapshotUserRole() { assertThat(snapshotUserRole.cluster().check(SnapshotsStatusAction.NAME, request, authentication), is(true)); assertThat(snapshotUserRole.cluster().check(GetSnapshotsAction.NAME, request, authentication), is(true)); - assertThat(snapshotUserRole.cluster().check(PutRepositoryAction.NAME, request, authentication), is(false)); + assertThat(snapshotUserRole.cluster().check(TransportPutRepositoryAction.TYPE.name(), request, authentication), is(false)); assertThat(snapshotUserRole.cluster().check(GetIndexTemplatesAction.NAME, request, authentication), is(false)); assertThat(snapshotUserRole.cluster().check(DeleteIndexTemplateAction.NAME, request, authentication), is(false)); assertThat(snapshotUserRole.cluster().check(PutPipelineAction.NAME, request, authentication), is(false)); @@ -619,7 +619,10 @@ public void testKibanaSystemRole() { logger.info("index name [{}]", index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); @@ -647,7 +650,10 @@ public void testKibanaSystemRole() { logger.trace("index name [{}]", index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); @@ -675,7 +681,10 @@ public void testKibanaSystemRole() { logger.trace("index name [{}]", index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); @@ -699,7 +708,10 @@ public void testKibanaSystemRole() { Arrays.asList("apm-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((index) -> { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); @@ -775,7 +787,10 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(mockIndexAbstraction(index)), is(true)); // Privileges needed for installing current ILM policy with delete action - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); }); // read-only indices for Endpoint events (to build timelines) @@ -783,7 +798,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -802,7 +820,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -872,7 +893,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -890,7 +914,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); @@ -909,7 +936,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); @@ -928,7 +958,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -950,7 +983,10 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); @@ -997,7 +1033,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -1016,7 +1055,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -1034,7 +1076,10 @@ public void testKibanaSystemRole() { final String index = ".management-beats"; assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); @@ -1152,7 +1197,10 @@ public void testKibanaSystemRole() { || indexName.startsWith("synthetics-browser.network-*") || indexName.startsWith("synthetics-browser.screenshot-*") || indexName.startsWith("profiling-*"); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(isAlsoIlmDeleteIndex)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(isAlsoIlmDeleteIndex) + ); }); // 4. Transform for endpoint package @@ -1192,7 +1240,7 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateDataStreamAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteDataStreamAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true)); @@ -1228,7 +1276,7 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true)); // Allow create and delete index, modifying aliases, and updating index settings assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); @@ -1262,7 +1310,7 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); @@ -1305,7 +1353,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(cspIndex); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -1323,7 +1374,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(cspIndex); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -1380,7 +1434,10 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); @@ -1414,7 +1471,7 @@ public void testKibanaSystemRole() { logger.info("index name [{}]", indexName); final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); }); @@ -1430,7 +1487,7 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true)); // Allow create and delete index, modifying aliases, and updating index settings assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); @@ -1665,7 +1722,10 @@ public void testMonitoringUserRole() { final String index = ".monitoring-" + randomAlphaOfLength(randomIntBetween(0, 13)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(monitoringUserRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + monitoringUserRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( monitoringUserRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), @@ -1812,7 +1872,9 @@ public void testRemoteMonitoringAgentRole() { is(true) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(monitoringIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()) + .test(mockIndexAbstraction(monitoringIndex)), is(true) ); assertThat( @@ -1864,7 +1926,9 @@ public void testRemoteMonitoringAgentRole() { is(false) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(metricbeatIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()) + .test(mockIndexAbstraction(metricbeatIndex)), is(false) ); assertThat( @@ -2011,7 +2075,9 @@ public void testRemoteMonitoringCollectorRole() { is(false) ); assertThat( - remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), + remoteMonitoringCollectorRole.indices() + .allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()) + .test(mockIndexAbstraction(index)), is(false) ); assertThat( @@ -2262,7 +2328,10 @@ public void testReportingUserRole() { final String index = ".reporting-" + randomAlphaOfLength(randomIntBetween(0, 13)); assertThat(reportingUserRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(false)); assertThat(reportingUserRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); - assertThat(reportingUserRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + reportingUserRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(reportingUserRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( reportingUserRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), @@ -2355,7 +2424,8 @@ public void testSuperuserRole() { .authorize(TransportSearchAction.TYPE.name(), Sets.newHashSet("a1", "ba"), lookup, fieldPermissionsCache); assertThat(iac.hasIndexPermissions("a1"), is(true)); assertThat(iac.hasIndexPermissions("b"), is(true)); - iac = superuserRole.indices().authorize(DeleteIndexAction.NAME, Sets.newHashSet("a1", "ba"), lookup, fieldPermissionsCache); + iac = superuserRole.indices() + .authorize(TransportDeleteIndexAction.TYPE.name(), Sets.newHashSet("a1", "ba"), lookup, fieldPermissionsCache); assertThat(iac.hasIndexPermissions("a1"), is(true)); assertThat(iac.hasIndexPermissions("b"), is(true)); iac = superuserRole.indices().authorize(TransportIndexAction.NAME, Sets.newHashSet("a2", "ba"), lookup, fieldPermissionsCache); @@ -2379,7 +2449,7 @@ public void testSuperuserRole() { // Write security indices => denied iac = superuserRole.indices() .authorize( - randomFrom(TransportIndexAction.NAME, DeleteIndexAction.NAME), + randomFrom(TransportIndexAction.NAME, TransportDeleteIndexAction.TYPE.name()), Sets.newHashSet(TestRestrictedIndices.SECURITY_MAIN_ALIAS), lookup, fieldPermissionsCache @@ -2409,13 +2479,13 @@ public void testSuperuserRole() { // Write security indices => denied assertThat( superuserRole.indices() - .allowedIndicesMatcher(randomFrom(TransportIndexAction.NAME, DeleteIndexAction.NAME)) + .allowedIndicesMatcher(randomFrom(TransportIndexAction.NAME, TransportDeleteIndexAction.TYPE.name())) .test(mockIndexAbstraction(TestRestrictedIndices.SECURITY_MAIN_ALIAS)), is(false) ); assertThat( superuserRole.indices() - .allowedIndicesMatcher(randomFrom(TransportIndexAction.NAME, DeleteIndexAction.NAME)) + .allowedIndicesMatcher(randomFrom(TransportIndexAction.NAME, TransportDeleteIndexAction.TYPE.name())) .test(mockIndexAbstraction(internalSecurityIndex)), is(false) ); @@ -2500,7 +2570,10 @@ public void testBeatsAdminRole() { logger.info("index name [{}]", index); assertThat(beatsAdminRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(true)); assertThat(beatsAdminRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(true)); - assertThat(beatsAdminRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + beatsAdminRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(beatsAdminRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(beatsAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(beatsAdminRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); @@ -3425,7 +3498,10 @@ private void assertAllIndicesAccessAllowed(Role role, String index) { logger.info("index name [{}]", index); assertThat(role.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(role.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); @@ -3442,7 +3518,10 @@ private void assertAllIndicesAccessAllowed(Role role, String index) { } private void assertReadWriteDocsAndMaintenanceButNotDeleteIndexAllowed(Role role, String index) { - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); @@ -3456,7 +3535,10 @@ private void assertReadWriteDocsAndMaintenanceButNotDeleteIndexAllowed(Role role } private void assertReadWriteDocsButNotDeleteIndexAllowed(Role role, String index) { - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); @@ -3466,7 +3548,10 @@ private void assertReadWriteDocsButNotDeleteIndexAllowed(Role role, String index } private void assertOnlyReadAllowed(Role role, String index) { - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); @@ -3505,7 +3590,10 @@ private void assertNoAccessAllowed(Role role, Collection indices) { } private void assertNoAccessAllowed(Role role, String index) { - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(false)); @@ -3564,7 +3652,10 @@ public void testLogstashAdminRole() { logstashAdminRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true) ); - assertThat(logstashAdminRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + logstashAdminRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(logstashAdminRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat( logstashAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java index f9a12b1fecf0b..8d1bcfb500e30 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java @@ -13,9 +13,9 @@ import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksAction; import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryAction; import org.elasticsearch.action.admin.cluster.state.ClusterStateAction; -import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptAction; +import org.elasticsearch.action.admin.cluster.storedscripts.TransportDeleteStoredScriptAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.readonly.AddIndexBlockAction; @@ -80,7 +80,7 @@ public void testXPackUser() { final List sampleClusterActions = List.of( ClusterStateAction.NAME, PutComponentTemplateAction.NAME, - DeleteStoredScriptAction.NAME, + TransportDeleteStoredScriptAction.TYPE.name(), UpdateJobAction.NAME, CleanupRepositoryAction.NAME ); @@ -92,7 +92,7 @@ public void testXPackUser() { RefreshAction.NAME, CreateIndexAction.NAME, PutMappingAction.NAME, - DeleteIndexAction.NAME + TransportDeleteIndexAction.TYPE.name() ); checkIndexAccess(role, randomFrom(sampleIndexActions), randomAlphaOfLengthBetween(3, 12), true); checkIndexAccess( @@ -115,7 +115,7 @@ public void testXPackSecurityUser() { final List sampleClusterActions = List.of( ClusterStateAction.NAME, PutComponentTemplateAction.NAME, - DeleteStoredScriptAction.NAME, + TransportDeleteStoredScriptAction.TYPE.name(), UpdateJobAction.NAME, CleanupRepositoryAction.NAME ); @@ -127,7 +127,7 @@ public void testXPackSecurityUser() { RefreshAction.NAME, CreateIndexAction.NAME, PutMappingAction.NAME, - DeleteIndexAction.NAME + TransportDeleteIndexAction.TYPE.name() ); checkIndexAccess( role, @@ -154,7 +154,7 @@ public void testSecurityProfileUser() { RefreshAction.NAME, CreateIndexAction.NAME, PutMappingAction.NAME, - DeleteIndexAction.NAME + TransportDeleteIndexAction.TYPE.name() ); checkIndexAccess(role, randomFrom(sampleAllowedActions), ".security-profile", true); checkIndexAccess(role, randomFrom(sampleAllowedActions), ".security-profile-" + randomIntBetween(1, 9), true); @@ -185,7 +185,7 @@ public void testAsyncSearchUser() { RefreshAction.NAME, CreateIndexAction.NAME, PutMappingAction.NAME, - DeleteIndexAction.NAME + TransportDeleteIndexAction.TYPE.name() ); checkIndexAccess(role, randomFrom(sampleAllowedActions), XPackPlugin.ASYNC_RESULTS_INDEX, true); checkIndexAccess( @@ -216,7 +216,7 @@ public void testStorageUser() { TransportGetAction.TYPE.name(), BulkAction.NAME, PutMappingAction.NAME, - DeleteIndexAction.NAME + TransportDeleteIndexAction.TYPE.name() ); checkIndexAccess(role, randomFrom(sampleDeniedActions), randomAlphaOfLengthBetween(4, 8), false); checkIndexAccess(role, randomFrom(sampleDeniedActions), ".ds-" + randomAlphaOfLengthBetween(4, 8), false); @@ -246,7 +246,7 @@ public void testDataStreamLifecycleUser() { final List sampleIndexActions = List.of( RolloverAction.NAME, - DeleteIndexAction.NAME, + TransportDeleteIndexAction.TYPE.name(), ForceMergeAction.NAME, IndicesStatsAction.NAME, UpdateSettingsAction.NAME, @@ -256,7 +256,7 @@ public void testDataStreamLifecycleUser() { final List sampleSystemDataStreamActions = List.of( RolloverAction.NAME, - DeleteIndexAction.NAME, + TransportDeleteIndexAction.TYPE.name(), ForceMergeAction.NAME, IndicesStatsAction.NAME, UpdateSettingsAction.NAME, diff --git a/x-pack/plugin/core/template-resources/src/main/resources/ecs@mappings.json b/x-pack/plugin/core/template-resources/src/main/resources/ecs@mappings.json index f1d03531e4b6b..a91cf5d1606c6 100644 --- a/x-pack/plugin/core/template-resources/src/main/resources/ecs@mappings.json +++ b/x-pack/plugin/core/template-resources/src/main/resources/ecs@mappings.json @@ -143,12 +143,33 @@ } }, { - "ecs_usage_scaled_float": { + "ecs_usage_double_scaled_float": { "mapping": { "type": "scaled_float", "scaling_factor": 1000 }, - "path_match": "*.usage" + "path_match": "*.usage", + "match_mapping_type": "double" + } + }, + { + "ecs_usage_long_scaled_float": { + "mapping": { + "type": "scaled_float", + "scaling_factor": 1000 + }, + "path_match": "*.usage", + "match_mapping_type": "long" + } + }, + { + "ecs_usage_long_scaled_float": { + "mapping": { + "type": "scaled_float", + "scaling_factor": 1000 + }, + "path_match": "*.usage", + "match_mapping_type": "string" } }, { diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index bc7a733a3daed..6d46d8bf8db94 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -17,8 +17,8 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeAction; import org.elasticsearch.action.admin.indices.get.GetIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexRequest; @@ -2391,7 +2391,7 @@ protected void ) { if (action.equals(EnrichReindexAction.INSTANCE)) { super.doExecute( - DeleteIndexAction.INSTANCE, + TransportDeleteIndexAction.TYPE, new DeleteIndexRequest(createdEnrichIndex), listener.delegateFailureAndWrap((delegate, response) -> { if (response.isAcknowledged() == false) { diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/CategorizationPartOfSpeechDictionary.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/CategorizationPartOfSpeechDictionary.java index 09a6846ead344..243286115eb8a 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/CategorizationPartOfSpeechDictionary.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/CategorizationPartOfSpeechDictionary.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.ml.aggs.categorization; import java.io.BufferedReader; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; @@ -73,49 +72,56 @@ static PartOfSpeech fromCode(char partOfSpeechCode) { } } - /** - * Lazy loaded singleton instance to avoid loading the dictionary repeatedly. - */ - private static CategorizationPartOfSpeechDictionary instance; - private static final Object INIT_LOCK = new Object(); + private static final class Holder { + /** + * Lazy loaded singleton instance to avoid loading the dictionary repeatedly. + */ + private static final CategorizationPartOfSpeechDictionary instance = new CategorizationPartOfSpeechDictionary(); + } /** * Keys are lower case. */ - private final Map partOfSpeechDictionary = new HashMap<>(); - private final int maxDictionaryWordLength; + private final Map partOfSpeechDictionary; - CategorizationPartOfSpeechDictionary(InputStream is) throws IOException { + private final int maxDictionaryWordLength; - int maxLength = 0; - BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); - String line; - while ((line = reader.readLine()) != null) { - line = line.trim(); - if (line.isEmpty()) { - continue; - } - String[] split = line.split(PART_OF_SPEECH_SEPARATOR); - if (split.length != 2) { - throw new IllegalArgumentException( - "Unexpected format in line [" + line + "]: expected one [" + PART_OF_SPEECH_SEPARATOR + "] separator" - ); - } - if (split[0].isEmpty()) { - throw new IllegalArgumentException( - "Unexpected format in line [" + line + "]: nothing preceding [" + PART_OF_SPEECH_SEPARATOR + "] separator" - ); - } - if (split[1].isEmpty()) { - throw new IllegalArgumentException( - "Unexpected format in line [" + line + "]: nothing following [" + PART_OF_SPEECH_SEPARATOR + "] separator" - ); + CategorizationPartOfSpeechDictionary() { + try (InputStream is = CategorizationPartOfSpeechDictionary.class.getResourceAsStream(DICTIONARY_FILE_PATH)) { + int maxLength = 0; + BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); + String line; + final Map partOfSpeechMap = new HashMap<>(); + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.isEmpty()) { + continue; + } + String[] split = line.split(PART_OF_SPEECH_SEPARATOR); + if (split.length != 2) { + throw new IllegalArgumentException( + "Unexpected format in line [" + line + "]: expected one [" + PART_OF_SPEECH_SEPARATOR + "] separator" + ); + } + if (split[0].isEmpty()) { + throw new IllegalArgumentException( + "Unexpected format in line [" + line + "]: nothing preceding [" + PART_OF_SPEECH_SEPARATOR + "] separator" + ); + } + if (split[1].isEmpty()) { + throw new IllegalArgumentException( + "Unexpected format in line [" + line + "]: nothing following [" + PART_OF_SPEECH_SEPARATOR + "] separator" + ); + } + String lowerCaseWord = split[0].toLowerCase(Locale.ROOT); + partOfSpeechMap.put(lowerCaseWord, PartOfSpeech.fromCode(split[1].charAt(0))); + maxLength = Math.max(maxLength, lowerCaseWord.length()); } - String lowerCaseWord = split[0].toLowerCase(Locale.ROOT); - partOfSpeechDictionary.put(lowerCaseWord, PartOfSpeech.fromCode(split[1].charAt(0))); - maxLength = Math.max(maxLength, lowerCaseWord.length()); + partOfSpeechDictionary = Map.copyOf(partOfSpeechMap); + maxDictionaryWordLength = maxLength; + } catch (Exception e) { + throw new AssertionError(e); } - maxDictionaryWordLength = maxLength; } // TODO: now we have this in Java, perform this operation in Java for anomaly detection categorization instead of in C++. @@ -142,17 +148,7 @@ public boolean isInDictionary(String word) { return getPartOfSpeech(word) != PartOfSpeech.NOT_IN_DICTIONARY; } - public static CategorizationPartOfSpeechDictionary getInstance() throws IOException { - if (instance != null) { - return instance; - } - synchronized (INIT_LOCK) { - if (instance == null) { - try (InputStream is = CategorizationPartOfSpeechDictionary.class.getResourceAsStream(DICTIONARY_FILE_PATH)) { - instance = new CategorizationPartOfSpeechDictionary(is); - } - } - return instance; - } + public static CategorizationPartOfSpeechDictionary getInstance() { + return Holder.instance; } } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java index 8ad7cd92a8e73..829101b3bd551 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java @@ -9,8 +9,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.ParentTaskAssigningClient; import org.elasticsearch.client.internal.node.NodeClient; @@ -241,7 +241,7 @@ private void executeJobInMiddleOfReindexing(DataFrameAnalyticsTask task, DataFra ClientHelper.executeAsyncWithOrigin( new ParentTaskAssigningClient(client, task.getParentTaskId()), ML_ORIGIN, - DeleteIndexAction.INSTANCE, + TransportDeleteIndexAction.TYPE, new DeleteIndexRequest(config.getDest().getIndex()), ActionListener.wrap( r -> executeStep(task, config, new ReindexingStep(clusterService, client, task, auditor, config, destIndexAllowedSettings)), diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/EmptyStateIndexRemoverTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/EmptyStateIndexRemoverTests.java index 20fadab86008a..b560a758b8e83 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/EmptyStateIndexRemoverTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/EmptyStateIndexRemoverTests.java @@ -7,8 +7,8 @@ package org.elasticsearch.xpack.ml.job.retention; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexResponse; import org.elasticsearch.action.admin.indices.stats.CommonStats; @@ -133,14 +133,14 @@ private void assertDeleteActionExecuted(boolean acknowledged) { doAnswer(withResponse(getIndexResponse)).when(client).execute(eq(GetIndexAction.INSTANCE), any(), any()); AcknowledgedResponse deleteIndexResponse = AcknowledgedResponse.of(acknowledged); - doAnswer(withResponse(deleteIndexResponse)).when(client).execute(eq(DeleteIndexAction.INSTANCE), any(), any()); + doAnswer(withResponse(deleteIndexResponse)).when(client).execute(eq(TransportDeleteIndexAction.TYPE), any(), any()); remover.remove(1.0f, listener, () -> false); InOrder inOrder = inOrder(client, listener); inOrder.verify(client).execute(eq(IndicesStatsAction.INSTANCE), any(), any()); inOrder.verify(client).execute(eq(GetIndexAction.INSTANCE), any(), any()); - inOrder.verify(client).execute(eq(DeleteIndexAction.INSTANCE), deleteIndexRequestCaptor.capture(), any()); + inOrder.verify(client).execute(eq(TransportDeleteIndexAction.TYPE), deleteIndexRequestCaptor.capture(), any()); inOrder.verify(listener).onResponse(acknowledged); DeleteIndexRequest deleteIndexRequest = deleteIndexRequestCaptor.getValue(); diff --git a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/ProfilingIndexManagerTests.java b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/ProfilingIndexManagerTests.java index 923269646d4d1..6919932a7823c 100644 --- a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/ProfilingIndexManagerTests.java +++ b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/ProfilingIndexManagerTests.java @@ -14,8 +14,8 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction; @@ -422,9 +422,8 @@ private ActionResponse verifyIndexUpgraded( assertThat(request, instanceOf(CreateIndexRequest.class)); assertNotNull(listener); return new CreateIndexResponse(true, true, ((CreateIndexRequest) request).index()); - } else if (action instanceof DeleteIndexAction) { + } else if (action == TransportDeleteIndexAction.TYPE) { indicesDeleted.incrementAndGet(); - assertThat(action, instanceOf(DeleteIndexAction.class)); assertThat(request, instanceOf(DeleteIndexRequest.class)); assertNotNull(listener); return AcknowledgedResponse.TRUE; diff --git a/x-pack/plugin/security/qa/jwt-realm/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRestIT.java b/x-pack/plugin/security/qa/jwt-realm/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRestIT.java index f12ae0bc86571..9c2fd118d59d9 100644 --- a/x-pack/plugin/security/qa/jwt-realm/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRestIT.java +++ b/x-pack/plugin/security/qa/jwt-realm/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRestIT.java @@ -508,6 +508,7 @@ public void testAuthenticationFailureIfDelegatedAuthorizationFails() throws Exce } } + @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/103308") public void testReloadClientSecret() throws Exception { final String principal = SERVICE_SUBJECT.get(); final String username = getUsernameFromPrincipal(principal); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java index d6aea4c64b246..9d56528a060c3 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java @@ -43,13 +43,11 @@ import org.elasticsearch.xpack.core.security.action.user.AuthenticateAction; import org.elasticsearch.xpack.core.security.action.user.AuthenticateRequest; import org.elasticsearch.xpack.core.security.action.user.AuthenticateResponse; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequestBuilder; import org.elasticsearch.xpack.core.security.action.user.DeleteUserRequestBuilder; import org.elasticsearch.xpack.core.security.action.user.DeleteUserResponse; import org.elasticsearch.xpack.core.security.action.user.GetUsersRequestBuilder; import org.elasticsearch.xpack.core.security.action.user.GetUsersResponse; import org.elasticsearch.xpack.core.security.action.user.PutUserRequestBuilder; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequestBuilder; import org.elasticsearch.xpack.core.security.authc.Authentication; import org.elasticsearch.xpack.core.security.authc.AuthenticationTestHelper; import org.elasticsearch.xpack.core.security.authc.support.Hasher; @@ -65,6 +63,8 @@ import org.elasticsearch.xpack.core.security.user.KibanaUser; import org.elasticsearch.xpack.core.security.user.User; import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.action.user.ChangePasswordRequestBuilder; +import org.elasticsearch.xpack.security.action.user.SetEnabledRequestBuilder; import org.elasticsearch.xpack.security.authz.store.NativeRolesStore; import org.junit.Before; import org.junit.BeforeClass; diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/operator/OperatorPrivilegesSingleNodeTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/operator/OperatorPrivilegesSingleNodeTests.java index 5e22641dd8baa..9593bfa5ab723 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/operator/OperatorPrivilegesSingleNodeTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/operator/OperatorPrivilegesSingleNodeTests.java @@ -8,8 +8,8 @@ package org.elasticsearch.xpack.security.operator; import org.elasticsearch.ElasticsearchSecurityException; -import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsRequest; +import org.elasticsearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.elasticsearch.client.internal.Client; @@ -69,7 +69,7 @@ public void testNormalSuperuserWillFailToCallOperatorOnlyAction() { final ClearVotingConfigExclusionsRequest clearVotingConfigExclusionsRequest = new ClearVotingConfigExclusionsRequest(); final ElasticsearchSecurityException e = expectThrows( ElasticsearchSecurityException.class, - () -> client().execute(ClearVotingConfigExclusionsAction.INSTANCE, clearVotingConfigExclusionsRequest).actionGet() + () -> client().execute(TransportClearVotingConfigExclusionsAction.TYPE, clearVotingConfigExclusionsRequest).actionGet() ); assertThat(e.getCause().getMessage(), containsString("Operator privileges are required for action")); } @@ -92,7 +92,7 @@ public void testNormalSuperuserWillFailToSetOperatorOnlySettings() { public void testOperatorUserWillSucceedToCallOperatorOnlyAction() { final Client client = createOperatorClient(); final ClearVotingConfigExclusionsRequest clearVotingConfigExclusionsRequest = new ClearVotingConfigExclusionsRequest(); - client.execute(ClearVotingConfigExclusionsAction.INSTANCE, clearVotingConfigExclusionsRequest).actionGet(); + client.execute(TransportClearVotingConfigExclusionsAction.TYPE, clearVotingConfigExclusionsRequest).actionGet(); } public void testOperatorUserWillSucceedToSetOperatorOnlySettings() { diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java index f2268a76221e3..963c42c55aa60 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java @@ -42,7 +42,6 @@ import org.elasticsearch.xpack.core.security.action.profile.UpdateProfileDataRequest; import org.elasticsearch.xpack.core.security.action.role.PutRoleAction; import org.elasticsearch.xpack.core.security.action.role.PutRoleRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequestBuilder; import org.elasticsearch.xpack.core.security.action.user.GetUsersAction; import org.elasticsearch.xpack.core.security.action.user.GetUsersRequest; import org.elasticsearch.xpack.core.security.action.user.GetUsersResponse; @@ -65,6 +64,7 @@ import org.elasticsearch.xpack.core.security.user.AnonymousUser; import org.elasticsearch.xpack.core.security.user.ElasticUser; import org.elasticsearch.xpack.core.security.user.User; +import org.elasticsearch.xpack.security.action.user.ChangePasswordRequestBuilder; import java.io.IOException; import java.util.ArrayList; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java index 6d7f6fcd3822b..51a902d7e12c0 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java @@ -145,7 +145,6 @@ import org.elasticsearch.xpack.core.security.action.rolemapping.GetRoleMappingsAction; import org.elasticsearch.xpack.core.security.action.rolemapping.PutRoleMappingAction; import org.elasticsearch.xpack.core.security.action.saml.SamlAuthenticateAction; -import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutAction; import org.elasticsearch.xpack.core.security.action.saml.SamlInvalidateSessionAction; import org.elasticsearch.xpack.core.security.action.saml.SamlLogoutAction; import org.elasticsearch.xpack.core.security.action.saml.SamlPrepareAuthenticationAction; @@ -161,14 +160,12 @@ import org.elasticsearch.xpack.core.security.action.token.InvalidateTokenAction; import org.elasticsearch.xpack.core.security.action.token.RefreshTokenAction; import org.elasticsearch.xpack.core.security.action.user.AuthenticateAction; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.DeleteUserAction; import org.elasticsearch.xpack.core.security.action.user.GetUserPrivilegesAction; import org.elasticsearch.xpack.core.security.action.user.GetUsersAction; import org.elasticsearch.xpack.core.security.action.user.HasPrivilegesAction; import org.elasticsearch.xpack.core.security.action.user.ProfileHasPrivilegesAction; import org.elasticsearch.xpack.core.security.action.user.PutUserAction; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledAction; import org.elasticsearch.xpack.core.security.authc.AuthenticationFailureHandler; import org.elasticsearch.xpack.core.security.authc.AuthenticationServiceField; import org.elasticsearch.xpack.core.security.authc.DefaultAuthenticationFailureHandler; @@ -1301,9 +1298,9 @@ public void onIndexModule(IndexModule module) { new ActionHandler<>(GetRolesAction.INSTANCE, TransportGetRolesAction.class), new ActionHandler<>(PutRoleAction.INSTANCE, TransportPutRoleAction.class), new ActionHandler<>(DeleteRoleAction.INSTANCE, TransportDeleteRoleAction.class), - new ActionHandler<>(ChangePasswordAction.INSTANCE, TransportChangePasswordAction.class), + new ActionHandler<>(TransportChangePasswordAction.TYPE, TransportChangePasswordAction.class), new ActionHandler<>(AuthenticateAction.INSTANCE, TransportAuthenticateAction.class), - new ActionHandler<>(SetEnabledAction.INSTANCE, TransportSetEnabledAction.class), + new ActionHandler<>(TransportSetEnabledAction.TYPE, TransportSetEnabledAction.class), new ActionHandler<>(HasPrivilegesAction.INSTANCE, TransportHasPrivilegesAction.class), new ActionHandler<>(GetUserPrivilegesAction.INSTANCE, TransportGetUserPrivilegesAction.class), new ActionHandler<>(GetRoleMappingsAction.INSTANCE, TransportGetRoleMappingsAction.class), @@ -1317,7 +1314,7 @@ public void onIndexModule(IndexModule module) { new ActionHandler<>(SamlAuthenticateAction.INSTANCE, TransportSamlAuthenticateAction.class), new ActionHandler<>(SamlLogoutAction.INSTANCE, TransportSamlLogoutAction.class), new ActionHandler<>(SamlInvalidateSessionAction.INSTANCE, TransportSamlInvalidateSessionAction.class), - new ActionHandler<>(SamlCompleteLogoutAction.INSTANCE, TransportSamlCompleteLogoutAction.class), + new ActionHandler<>(TransportSamlCompleteLogoutAction.TYPE, TransportSamlCompleteLogoutAction.class), new ActionHandler<>(SamlSpMetadataAction.INSTANCE, TransportSamlSpMetadataAction.class), new ActionHandler<>(OpenIdConnectPrepareAuthenticationAction.INSTANCE, TransportOpenIdConnectPrepareAuthenticationAction.class), new ActionHandler<>(OpenIdConnectAuthenticateAction.INSTANCE, TransportOpenIdConnectAuthenticateAction.class), diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java index 997f58a01c0e1..08544d316e87a 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java @@ -14,7 +14,7 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.support.ActionFilter; import org.elasticsearch.action.support.ActionFilterChain; @@ -131,7 +131,9 @@ private void ap Request request, ActionListener listener ) { - if (TransportCloseIndexAction.NAME.equals(action) || OpenIndexAction.NAME.equals(action) || DeleteIndexAction.NAME.equals(action)) { + if (TransportCloseIndexAction.NAME.equals(action) + || OpenIndexAction.NAME.equals(action) + || TransportDeleteIndexAction.TYPE.name().equals(action)) { IndicesRequest indicesRequest = (IndicesRequest) request; try { destructiveOperations.failDestructive(indicesRequest.indices()); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java index 0b76af3cf542e..7b45313b0e24f 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java @@ -8,13 +8,13 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutAction; import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutRequest; import org.elasticsearch.xpack.security.authc.Realms; import org.elasticsearch.xpack.security.authc.saml.SamlLogoutResponseHandler; @@ -30,17 +30,14 @@ */ public final class TransportSamlCompleteLogoutAction extends HandledTransportAction { + public static final ActionType TYPE = ActionType.emptyResponse( + "cluster:admin/xpack/security/saml/complete_logout" + ); private final Realms realms; @Inject public TransportSamlCompleteLogoutAction(TransportService transportService, ActionFilters actionFilters, Realms realms) { - super( - SamlCompleteLogoutAction.NAME, - transportService, - actionFilters, - SamlCompleteLogoutRequest::new, - EsExecutors.DIRECT_EXECUTOR_SERVICE - ); + super(TYPE.name(), transportService, actionFilters, SamlCompleteLogoutRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); this.realms = realms; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/ChangePasswordRequestBuilder.java similarity index 96% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java rename to x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/ChangePasswordRequestBuilder.java index 927f839f267b4..c5fbd7ca3c397 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/ChangePasswordRequestBuilder.java @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -package org.elasticsearch.xpack.core.security.action.user; +package org.elasticsearch.xpack.security.action.user; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.ActionRequestBuilder; @@ -18,6 +18,7 @@ import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.XContentParser; import org.elasticsearch.xcontent.XContentType; +import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.support.Validation; import org.elasticsearch.xpack.core.security.user.User; @@ -36,7 +37,7 @@ public class ChangePasswordRequestBuilder extends ActionRequestBuilder { public ChangePasswordRequestBuilder(ElasticsearchClient client) { - super(client, ChangePasswordAction.INSTANCE, new ChangePasswordRequest()); + super(client, TransportChangePasswordAction.TYPE, new ChangePasswordRequest()); } public ChangePasswordRequestBuilder username(String username) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledRequestBuilder.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/SetEnabledRequestBuilder.java similarity index 85% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledRequestBuilder.java rename to x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/SetEnabledRequestBuilder.java index 1a6d522f46e21..69ebf247ad8fa 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledRequestBuilder.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/SetEnabledRequestBuilder.java @@ -4,12 +4,13 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -package org.elasticsearch.xpack.core.security.action.user; +package org.elasticsearch.xpack.security.action.user; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.WriteRequestBuilder; import org.elasticsearch.client.internal.ElasticsearchClient; +import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequest; /** * Request builder for setting a user as enabled or disabled @@ -19,7 +20,7 @@ public class SetEnabledRequestBuilder extends ActionRequestBuilder { public SetEnabledRequestBuilder(ElasticsearchClient client) { - super(client, SetEnabledAction.INSTANCE, new SetEnabledRequest()); + super(client, TransportSetEnabledAction.TYPE, new SetEnabledRequest()); } /** diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java index 77c6fd6882bc2..fc8f931612907 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java @@ -8,6 +8,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.common.inject.Inject; @@ -16,7 +17,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackSettings; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.user.AnonymousUser; @@ -26,6 +26,9 @@ public class TransportChangePasswordAction extends HandledTransportAction { + public static final ActionType TYPE = ActionType.emptyResponse( + "cluster:admin/xpack/security/user/change_password" + ); private final Settings settings; private final NativeUsersStore nativeUsersStore; @@ -36,7 +39,7 @@ public TransportChangePasswordAction( ActionFilters actionFilters, NativeUsersStore nativeUsersStore ) { - super(ChangePasswordAction.NAME, transportService, actionFilters, ChangePasswordRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); + super(TYPE.name(), transportService, actionFilters, ChangePasswordRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); this.settings = settings; this.nativeUsersStore = nativeUsersStore; } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java index 10f58499dd92f..4647ac0cf5f66 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java @@ -8,6 +8,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.common.inject.Inject; @@ -16,7 +17,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.security.SecurityContext; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledAction; import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequest; import org.elasticsearch.xpack.core.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.core.security.user.AnonymousUser; @@ -28,6 +28,7 @@ */ public class TransportSetEnabledAction extends HandledTransportAction { + public static final ActionType TYPE = ActionType.emptyResponse("cluster:admin/xpack/security/user/set_enabled"); private final Settings settings; private final SecurityContext securityContext; private final NativeUsersStore usersStore; @@ -40,7 +41,7 @@ public TransportSetEnabledAction( SecurityContext securityContext, NativeUsersStore usersStore ) { - super(SetEnabledAction.NAME, transportService, actionFilters, SetEnabledRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); + super(TYPE.name(), transportService, actionFilters, SetEnabledRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); this.settings = settings; this.securityContext = securityContext; this.usersStore = usersStore; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java index b28680f35e083..e2b9c36c1d0ee 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java @@ -83,13 +83,11 @@ import org.elasticsearch.xpack.core.security.action.service.CreateServiceAccountTokenRequest; import org.elasticsearch.xpack.core.security.action.service.DeleteServiceAccountTokenAction; import org.elasticsearch.xpack.core.security.action.service.DeleteServiceAccountTokenRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; import org.elasticsearch.xpack.core.security.action.user.DeleteUserAction; import org.elasticsearch.xpack.core.security.action.user.DeleteUserRequest; import org.elasticsearch.xpack.core.security.action.user.PutUserAction; import org.elasticsearch.xpack.core.security.action.user.PutUserRequest; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledAction; import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequest; import org.elasticsearch.xpack.core.security.authc.Authentication; import org.elasticsearch.xpack.core.security.authc.AuthenticationField; @@ -102,6 +100,8 @@ import org.elasticsearch.xpack.core.security.user.InternalUser; import org.elasticsearch.xpack.core.security.user.User; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.action.user.TransportChangePasswordAction; +import org.elasticsearch.xpack.security.action.user.TransportSetEnabledAction; import org.elasticsearch.xpack.security.audit.AuditLevel; import org.elasticsearch.xpack.security.audit.AuditTrail; import org.elasticsearch.xpack.security.audit.AuditUtil; @@ -290,8 +290,8 @@ public class LoggingAuditTrail implements AuditTrail, ClusterStateListener { PutUserAction.NAME, PutRoleAction.NAME, PutRoleMappingAction.NAME, - SetEnabledAction.NAME, - ChangePasswordAction.NAME, + TransportSetEnabledAction.TYPE.name(), + TransportChangePasswordAction.TYPE.name(), CreateApiKeyAction.NAME, GrantApiKeyAction.NAME, PutPrivilegesAction.NAME, @@ -734,10 +734,10 @@ public void accessGranted( assert PutRoleMappingAction.NAME.equals(action); securityChangeLogEntryBuilder(requestId).withRequestBody((PutRoleMappingRequest) msg).build(); } else if (msg instanceof SetEnabledRequest) { - assert SetEnabledAction.NAME.equals(action); + assert TransportSetEnabledAction.TYPE.name().equals(action); securityChangeLogEntryBuilder(requestId).withRequestBody((SetEnabledRequest) msg).build(); } else if (msg instanceof ChangePasswordRequest) { - assert ChangePasswordAction.NAME.equals(action); + assert TransportChangePasswordAction.TYPE.name().equals(action); securityChangeLogEntryBuilder(requestId).withRequestBody((ChangePasswordRequest) msg).build(); } else if (msg instanceof CreateApiKeyRequest) { assert CreateApiKeyAction.NAME.equals(action); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java index 1c1fed5540248..b4c154e99b466 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java @@ -49,7 +49,6 @@ import org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyRequest; import org.elasticsearch.xpack.core.security.action.user.AuthenticateAction; import org.elasticsearch.xpack.core.security.action.user.AuthenticateRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.GetUserPrivilegesAction; import org.elasticsearch.xpack.core.security.action.user.GetUserPrivilegesResponse; import org.elasticsearch.xpack.core.security.action.user.HasPrivilegesAction; @@ -84,6 +83,7 @@ import org.elasticsearch.xpack.core.security.authz.privilege.Privilege; import org.elasticsearch.xpack.core.security.support.StringMatcher; import org.elasticsearch.xpack.core.sql.SqlAsyncActionNames; +import org.elasticsearch.xpack.security.action.user.TransportChangePasswordAction; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore; @@ -112,7 +112,7 @@ public class RBACEngine implements AuthorizationEngine { private static final Predicate SAME_USER_PRIVILEGE = StringMatcher.of( - ChangePasswordAction.NAME, + TransportChangePasswordAction.TYPE.name(), AuthenticateAction.NAME, HasPrivilegesAction.NAME, GetUserPrivilegesAction.NAME, @@ -219,7 +219,7 @@ static boolean checkSameUserPermissions(String action, TransportRequest request, } final boolean sameUsername = authentication.getEffectiveSubject().getUser().principal().equals(username); - if (sameUsername && ChangePasswordAction.NAME.equals(action)) { + if (sameUsername && TransportChangePasswordAction.TYPE.name().equals(action)) { return checkChangePasswordAction(authentication); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/operator/DefaultOperatorOnlyRegistry.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/operator/DefaultOperatorOnlyRegistry.java index 2f5f809702ccd..e335bd8583a88 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/operator/DefaultOperatorOnlyRegistry.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/operator/DefaultOperatorOnlyRegistry.java @@ -7,12 +7,12 @@ package org.elasticsearch.xpack.security.operator; -import org.elasticsearch.action.admin.cluster.allocation.DeleteDesiredBalanceAction; -import org.elasticsearch.action.admin.cluster.allocation.GetDesiredBalanceAction; -import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction; -import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction; -import org.elasticsearch.action.admin.cluster.desirednodes.DeleteDesiredNodesAction; +import org.elasticsearch.action.admin.cluster.allocation.TransportDeleteDesiredBalanceAction; +import org.elasticsearch.action.admin.cluster.allocation.TransportGetDesiredBalanceAction; +import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; +import org.elasticsearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.elasticsearch.action.admin.cluster.desirednodes.GetDesiredNodesAction; +import org.elasticsearch.action.admin.cluster.desirednodes.TransportDeleteDesiredNodesAction; import org.elasticsearch.action.admin.cluster.desirednodes.UpdateDesiredNodesAction; import org.elasticsearch.action.admin.cluster.node.shutdown.PrevalidateNodeRemovalAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; @@ -34,8 +34,8 @@ public class DefaultOperatorOnlyRegistry implements OperatorOnlyRegistry { public static final Set SIMPLE_ACTIONS = Set.of( - AddVotingConfigExclusionsAction.NAME, - ClearVotingConfigExclusionsAction.NAME, + TransportAddVotingConfigExclusionsAction.TYPE.name(), + TransportClearVotingConfigExclusionsAction.TYPE.name(), PutLicenseAction.NAME, DeleteLicenseAction.NAME, // Autoscaling does not publish its actions to core, literal strings are needed. @@ -50,11 +50,11 @@ public class DefaultOperatorOnlyRegistry implements OperatorOnlyRegistry { // Node removal prevalidation API PrevalidateNodeRemovalAction.NAME, // Desired Nodes API - DeleteDesiredNodesAction.NAME, + TransportDeleteDesiredNodesAction.TYPE.name(), GetDesiredNodesAction.NAME, UpdateDesiredNodesAction.NAME, - GetDesiredBalanceAction.NAME, - DeleteDesiredBalanceAction.NAME + TransportGetDesiredBalanceAction.TYPE.name(), + TransportDeleteDesiredBalanceAction.TYPE.name() ); private final ClusterSettings clusterSettings; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java index 6a4bcac251461..9c222c7cc88b3 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java @@ -24,8 +24,8 @@ import org.elasticsearch.xcontent.ParseField; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentParser; -import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutAction; import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutRequest; +import org.elasticsearch.xpack.security.action.saml.TransportSamlCompleteLogoutAction; import java.io.IOException; import java.util.List; @@ -82,7 +82,7 @@ protected RestChannelConsumer innerPrepareRequest(RestRequest request, NodeClien samlCompleteLogoutRequest.getValidRequestIds() ); return channel -> client.execute( - SamlCompleteLogoutAction.INSTANCE, + TransportSamlCompleteLogoutAction.TYPE, samlCompleteLogoutRequest, new RestBuilderListener<>(channel) { @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java index b76d2b7cf7c42..68500c4d07e26 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java @@ -22,9 +22,9 @@ import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.security.SecurityContext; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequestBuilder; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.user.User; +import org.elasticsearch.xpack.security.action.user.ChangePasswordRequestBuilder; import java.io.IOException; import java.util.List; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java index bfa78b60c8b66..f34450cbbe1ef 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java @@ -18,7 +18,7 @@ import org.elasticsearch.rest.ServerlessScope; import org.elasticsearch.rest.action.RestBuilderListener; import org.elasticsearch.xcontent.XContentBuilder; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequestBuilder; +import org.elasticsearch.xpack.security.action.user.SetEnabledRequestBuilder; import java.io.IOException; import java.util.List; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java index a7a0efbbf4aac..9eac5512520b2 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java @@ -12,7 +12,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -67,7 +67,9 @@ class ServerTransportFilter { * be sent back to the sender. */ void inbound(String action, TransportRequest request, TransportChannel transportChannel, ActionListener listener) { - if (TransportCloseIndexAction.NAME.equals(action) || OpenIndexAction.NAME.equals(action) || DeleteIndexAction.NAME.equals(action)) { + if (TransportCloseIndexAction.NAME.equals(action) + || OpenIndexAction.NAME.equals(action) + || TransportDeleteIndexAction.TYPE.name().equals(action)) { IndicesRequest indicesRequest = (IndicesRequest) request; try { destructiveOperations.failDestructive(indicesRequest.indices()); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java index 721df8867c96a..a2ab6c1864783 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.MockIndicesRequest; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.support.ActionFilterChain; import org.elasticsearch.action.support.DestructiveOperations; @@ -229,7 +229,7 @@ public void testApplyDestructiveOperations() throws Exception { IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), randomFrom("*", "_all", "test*") ); - String action = randomFrom(TransportCloseIndexAction.NAME, OpenIndexAction.NAME, DeleteIndexAction.NAME); + String action = randomFrom(TransportCloseIndexAction.NAME, OpenIndexAction.NAME, TransportDeleteIndexAction.TYPE.name()); ActionListener listener = mock(ActionListener.class); Task task = mock(Task.class); User user = new User("username", "r1", "r2"); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/ChangePasswordRequestBuilderTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/ChangePasswordRequestBuilderTests.java index a3021453ee028..df5cebdf735ac 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/ChangePasswordRequestBuilderTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/ChangePasswordRequestBuilderTests.java @@ -16,7 +16,6 @@ import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequestBuilder; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import java.io.IOException; diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java index 47811fe8a3e7e..3385b02147890 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java @@ -83,13 +83,11 @@ import org.elasticsearch.xpack.core.security.action.service.CreateServiceAccountTokenRequest; import org.elasticsearch.xpack.core.security.action.service.DeleteServiceAccountTokenAction; import org.elasticsearch.xpack.core.security.action.service.DeleteServiceAccountTokenRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; import org.elasticsearch.xpack.core.security.action.user.DeleteUserAction; import org.elasticsearch.xpack.core.security.action.user.DeleteUserRequest; import org.elasticsearch.xpack.core.security.action.user.PutUserAction; import org.elasticsearch.xpack.core.security.action.user.PutUserRequest; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledAction; import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequest; import org.elasticsearch.xpack.core.security.audit.logfile.CapturingLogger; import org.elasticsearch.xpack.core.security.authc.Authentication; @@ -115,6 +113,8 @@ import org.elasticsearch.xpack.core.security.user.InternalUsers; import org.elasticsearch.xpack.core.security.user.User; import org.elasticsearch.xpack.core.security.user.UsernamesField; +import org.elasticsearch.xpack.security.action.user.TransportChangePasswordAction; +import org.elasticsearch.xpack.security.action.user.TransportSetEnabledAction; import org.elasticsearch.xpack.security.audit.AuditLevel; import org.elasticsearch.xpack.security.audit.AuditTrail; import org.elasticsearch.xpack.security.audit.AuditUtil; @@ -1337,7 +1337,7 @@ public void testSecurityConfigChangeEventFormattingForUsers() throws IOException // enable user setEnabledRequest.enabled(true); setEnabledRequest.username(username); - auditTrail.accessGranted(requestId, authentication, SetEnabledAction.NAME, setEnabledRequest, authorizationInfo); + auditTrail.accessGranted(requestId, authentication, TransportSetEnabledAction.TYPE.name(), setEnabledRequest, authorizationInfo); output = CapturingLogger.output(logger.getName(), Level.INFO); assertThat(output.size(), is(2)); String generatedEnableUserAuditEventString = output.get(1); @@ -1362,7 +1362,7 @@ public void testSecurityConfigChangeEventFormattingForUsers() throws IOException // disable user setEnabledRequest.enabled(false); setEnabledRequest.username(username); - auditTrail.accessGranted(requestId, authentication, SetEnabledAction.NAME, setEnabledRequest, authorizationInfo); + auditTrail.accessGranted(requestId, authentication, TransportSetEnabledAction.TYPE.name(), setEnabledRequest, authorizationInfo); output = CapturingLogger.output(logger.getName(), Level.INFO); assertThat(output.size(), is(2)); String generatedDisableUserAuditEventString = output.get(1); @@ -1386,7 +1386,13 @@ public void testSecurityConfigChangeEventFormattingForUsers() throws IOException changePasswordRequest.setRefreshPolicy(randomFrom(WriteRequest.RefreshPolicy.values())); changePasswordRequest.username(username); changePasswordRequest.passwordHash(randomFrom(randomAlphaOfLengthBetween(0, 8).toCharArray(), null)); - auditTrail.accessGranted(requestId, authentication, ChangePasswordAction.NAME, changePasswordRequest, authorizationInfo); + auditTrail.accessGranted( + requestId, + authentication, + TransportChangePasswordAction.TYPE.name(), + changePasswordRequest, + authorizationInfo + ); output = CapturingLogger.output(logger.getName(), Level.INFO); assertThat(output.size(), is(2)); String generatedChangePasswordAuditEventString = output.get(1); @@ -1960,8 +1966,8 @@ public void testSecurityConfigChangedEventSelection() { new Tuple<>(PutUserAction.NAME, new PutUserRequest()), new Tuple<>(PutRoleAction.NAME, new PutRoleRequest()), new Tuple<>(PutRoleMappingAction.NAME, new PutRoleMappingRequest()), - new Tuple<>(SetEnabledAction.NAME, new SetEnabledRequest()), - new Tuple<>(ChangePasswordAction.NAME, new ChangePasswordRequest()), + new Tuple<>(TransportSetEnabledAction.TYPE.name(), new SetEnabledRequest()), + new Tuple<>(TransportChangePasswordAction.TYPE.name(), new ChangePasswordRequest()), new Tuple<>(CreateApiKeyAction.NAME, new CreateApiKeyRequest()), new Tuple<>(GrantApiKeyAction.NAME, new GrantApiKeyRequest()), new Tuple<>(PutPrivilegesAction.NAME, new PutPrivilegesRequest()), diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java index 71b91619c66b3..772512a7f69d0 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.mapping.put.AutoPutMappingAction; import org.elasticsearch.action.admin.indices.refresh.RefreshAction; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction; @@ -137,7 +137,7 @@ public void testElasticFleetServerPrivileges() { assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(index), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(index), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(index), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(index), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(index), is(false)); @@ -152,7 +152,7 @@ public void testElasticFleetServerPrivileges() { assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(profilingIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(profilingIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(profilingIndex), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(profilingIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(profilingIndex), is(true)); @@ -166,7 +166,7 @@ public void testElasticFleetServerPrivileges() { assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(index), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(index), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(index), is(true)); @@ -195,7 +195,7 @@ public void testElasticFleetServerPrivileges() { assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(dotFleetIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(dotFleetIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(dotFleetIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(dotFleetIndex), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(dotFleetIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(dotFleetIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher("indices:foo").test(dotFleetIndex), is(false)); }); @@ -210,7 +210,7 @@ public void testElasticFleetServerPrivileges() { assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(dotFleetSecretsIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(dotFleetSecretsIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(dotFleetSecretsIndex), is(false)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(dotFleetSecretsIndex), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(dotFleetSecretsIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(dotFleetSecretsIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher("indices:foo").test(dotFleetSecretsIndex), is(false)); @@ -229,7 +229,7 @@ public void testElasticFleetServerPrivileges() { assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(apmSampledTracesIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(apmSampledTracesIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(apmSampledTracesIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(apmSampledTracesIndex), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(apmSampledTracesIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(apmSampledTracesIndex), is(false)); final String privilegeName = randomAlphaOfLengthBetween(3, 16); @@ -367,7 +367,7 @@ public void testElasticEnterpriseSearchServerAccount() { assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(enterpriseSearchIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(enterpriseSearchIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(enterpriseSearchIndex), is(true)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 875bf37d4c164..ad05cb20ffbbf 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -22,8 +22,8 @@ import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexRequest; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; @@ -879,14 +879,14 @@ public void testRemoteIndicesOnlyWorkWithApplicableRequestTypes() { mockEmptyMetadata(); final String requestId = AuditUtil.getOrGenerateRequestId(threadContext); assertThrowsAuthorizationException( - () -> authorize(authentication, DeleteIndexAction.NAME, request), - DeleteIndexAction.NAME, + () -> authorize(authentication, TransportDeleteIndexAction.TYPE.name(), request), + TransportDeleteIndexAction.TYPE.name(), "test user" ); verify(auditTrail).accessDenied( eq(requestId), eq(authentication), - eq(DeleteIndexAction.NAME), + eq(TransportDeleteIndexAction.TYPE.name()), eq(request), authzInfoRoles(Role.EMPTY.names()) ); @@ -2351,7 +2351,10 @@ public void testSuperusersCannotExecuteWriteOperationAgainstSecurityIndex() { new Tuple<>(PutMappingAction.NAME, new PutMappingRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7))) ); requests.add( - new Tuple<>(DeleteIndexAction.NAME, new DeleteIndexRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7))) + new Tuple<>( + TransportDeleteIndexAction.TYPE.name(), + new DeleteIndexRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)) + ) ); for (final Tuple requestTuple : requests) { final String action = requestTuple.v1(); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java index 7defd0f11bfac..45838e75940b4 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java @@ -15,8 +15,8 @@ import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; @@ -1541,7 +1541,10 @@ public void testNonRemotableRequestDoesNotAllowRemoteIndices() { new CloseIndexRequest("remote:foo").indicesOptions(options), TransportCloseIndexAction.NAME ), - new Tuple(new DeleteIndexRequest("remote:foo").indicesOptions(options), DeleteIndexAction.NAME), + new Tuple( + new DeleteIndexRequest("remote:foo").indicesOptions(options), + TransportDeleteIndexAction.TYPE.name() + ), new Tuple(new PutMappingRequest("remote:foo").indicesOptions(options), PutMappingAction.NAME) ); IndexNotFoundException e = expectThrows( @@ -1555,7 +1558,10 @@ public void testNonRemotableRequestDoesNotAllowRemoteWildcardIndices() { IndicesOptions options = IndicesOptions.fromOptions(randomBoolean(), true, true, true); Tuple tuple = randomFrom( new Tuple(new CloseIndexRequest("*:*").indicesOptions(options), TransportCloseIndexAction.NAME), - new Tuple(new DeleteIndexRequest("*:*").indicesOptions(options), DeleteIndexAction.NAME), + new Tuple( + new DeleteIndexRequest("*:*").indicesOptions(options), + TransportDeleteIndexAction.TYPE.name() + ), new Tuple(new PutMappingRequest("*:*").indicesOptions(options), PutMappingAction.NAME) ); final ResolvedIndices resolved = resolveIndices(tuple.v1(), buildAuthorizedIndices(user, tuple.v2())); @@ -1576,7 +1582,7 @@ public void testCompositeIndicesRequestIsNotSupported() { } public void testResolveAdminAction() { - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, DeleteIndexAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, TransportDeleteIndexAction.TYPE.name()); { RefreshRequest request = new RefreshRequest("*"); List indices = resolveIndices(request, authorizedIndices).getLocal(); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java index 3540f0bd6a753..753f498e2fb90 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java @@ -41,9 +41,7 @@ import org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyRequest; import org.elasticsearch.xpack.core.security.action.user.AuthenticateAction; import org.elasticsearch.xpack.core.security.action.user.AuthenticateRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequestBuilder; import org.elasticsearch.xpack.core.security.action.user.DeleteUserAction; import org.elasticsearch.xpack.core.security.action.user.GetUserPrivilegesAction; import org.elasticsearch.xpack.core.security.action.user.GetUserPrivilegesRequest; @@ -98,6 +96,8 @@ import org.elasticsearch.xpack.core.security.support.Automatons; import org.elasticsearch.xpack.core.security.test.TestRestrictedIndices; import org.elasticsearch.xpack.core.security.user.User; +import org.elasticsearch.xpack.security.action.user.ChangePasswordRequestBuilder; +import org.elasticsearch.xpack.security.action.user.TransportChangePasswordAction; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; import org.elasticsearch.xpack.security.authz.RBACEngine.RBACAuthorizationInfo; import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore; @@ -247,7 +247,7 @@ public void testSameUserPermission() { final TransportRequest request = changePasswordRequest ? new ChangePasswordRequestBuilder(mock(Client.class)).username(user.principal()).request() : new HasPrivilegesRequestBuilder(mock(Client.class)).username(user.principal()).request(); - final String action = changePasswordRequest ? ChangePasswordAction.NAME : HasPrivilegesAction.NAME; + final String action = changePasswordRequest ? TransportChangePasswordAction.TYPE.name() : HasPrivilegesAction.NAME; final Authentication.RealmRef authenticatedBy = new Authentication.RealmRef( randomAlphaOfLengthBetween(3, 8), changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealmSettings.TYPE) : randomAlphaOfLengthBetween(4, 12), @@ -267,7 +267,7 @@ public void testSameUserPermissionDoesNotAllowNonMatchingUsername() { final TransportRequest request = changePasswordRequest ? new ChangePasswordRequestBuilder(mock(Client.class)).username(username).request() : new HasPrivilegesRequestBuilder(mock(Client.class)).username(username).request(); - final String action = changePasswordRequest ? ChangePasswordAction.NAME : HasPrivilegesAction.NAME; + final String action = changePasswordRequest ? TransportChangePasswordAction.TYPE.name() : HasPrivilegesAction.NAME; final Authentication.RealmRef authenticatedBy = new Authentication.RealmRef( randomAlphaOfLengthBetween(3, 8), @@ -331,7 +331,7 @@ public void testSameUserPermissionRunAsChecksAuthenticatedBy() { final TransportRequest request = changePasswordRequest ? new ChangePasswordRequestBuilder(mock(Client.class)).username(username).request() : new HasPrivilegesRequestBuilder(mock(Client.class)).username(username).request(); - final String action = changePasswordRequest ? ChangePasswordAction.NAME : AuthenticateAction.NAME; + final String action = changePasswordRequest ? TransportChangePasswordAction.TYPE.name() : AuthenticateAction.NAME; final Authentication.RealmRef authenticatedBy = AuthenticationTestHelper.randomRealmRef(false); final Authentication.RealmRef lookedUpBy = new Authentication.RealmRef( @@ -367,7 +367,7 @@ public void testSameUserPermissionDoesNotAllowChangePasswordForOtherRealms() { final ChangePasswordRequest request = new ChangePasswordRequestBuilder(mock(Client.class)).username( authentication.getEffectiveSubject().getUser().principal() ).request(); - final String action = ChangePasswordAction.NAME; + final String action = TransportChangePasswordAction.TYPE.name(); assertThat(request, instanceOf(UserRequest.class)); assertFalse(RBACEngine.checkSameUserPermissions(action, request, authentication)); @@ -378,7 +378,7 @@ public void testSameUserPermissionDoesNotAllowChangePasswordForApiKey() { final ChangePasswordRequest request = new ChangePasswordRequestBuilder(mock(Client.class)).username( authentication.getEffectiveSubject().getUser().principal() ).request(); - final String action = ChangePasswordAction.NAME; + final String action = TransportChangePasswordAction.TYPE.name(); assertThat(request, instanceOf(UserRequest.class)); assertFalse(RBACEngine.checkSameUserPermissions(action, request, authentication)); @@ -389,7 +389,7 @@ public void testSameUserPermissionDoesNotAllowChangePasswordForAccessToken() { final ChangePasswordRequest request = new ChangePasswordRequestBuilder(mock(Client.class)).username( authentication.getEffectiveSubject().getUser().principal() ).request(); - final String action = ChangePasswordAction.NAME; + final String action = TransportChangePasswordAction.TYPE.name(); assertThat(request, instanceOf(UserRequest.class)); assertFalse(RBACEngine.checkSameUserPermissions(action, request, authentication)); @@ -416,7 +416,7 @@ public void testSameUserPermissionDoesNotAllowChangePasswordForLookedUpByOtherRe final ChangePasswordRequest request = new ChangePasswordRequestBuilder(mock(Client.class)).username( authentication.getEffectiveSubject().getUser().principal() ).request(); - final String action = ChangePasswordAction.NAME; + final String action = TransportChangePasswordAction.TYPE.name(); assertThat(request, instanceOf(UserRequest.class)); assertFalse(RBACEngine.checkSameUserPermissions(action, request, authentication)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java index 9bd5d416940d3..57e48581d159c 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java @@ -12,8 +12,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.state.ClusterStateAction; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.StreamInput; @@ -568,7 +568,7 @@ public void testProfileSecuredRequestHandlerDecrementsRefCountOnFailure() throws final SecurityServerTransportInterceptor.ProfileSecuredRequestHandler requestHandler = new SecurityServerTransportInterceptor.ProfileSecuredRequestHandler<>( logger, - DeleteIndexAction.NAME, + TransportDeleteIndexAction.TYPE.name(), randomBoolean(), threadPool.executor(randomBoolean() ? ThreadPool.Names.SAME : ThreadPool.Names.GENERIC), (request, channel, task) -> fail("should fail at destructive operations check to trigger listener failure"), diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java index 1ecd85cadab46..f6e5601c75c6a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.MockIndicesRequest; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.DestructiveOperations; @@ -188,7 +188,7 @@ public void testCrossClusterAccessInboundMissingHeadersFail() { } public void testInboundDestructiveOperations() { - String action = randomFrom(TransportCloseIndexAction.NAME, OpenIndexAction.NAME, DeleteIndexAction.NAME); + String action = randomFrom(TransportCloseIndexAction.NAME, OpenIndexAction.NAME, TransportDeleteIndexAction.TYPE.name()); TransportRequest request = new MockIndicesRequest( IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), randomFrom("*", "_all", "test*") diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index 684100b45a743..e8d06e6f8cbe2 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -13,6 +13,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.RoutingNodesHelper; @@ -421,6 +422,21 @@ public void testNodeShutdownWithUnassignedShards() throws Exception { assertBusy(() -> assertNodeShutdownStatus(nodeAId, STALLED)); } + public void testRemoveNodeWaitsForAutoExpandReplicas() throws Exception { + final var nodes = internalCluster().startNodes(2); + final var indexName = randomIdentifier(); + createIndex(indexName, indexSettings(1, 0).put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1").build()); + ensureGreen(indexName); + + final var nodeToShutdownName = randomFrom(nodes); + final var nodeToShutdownId = getNodeId(nodeToShutdownName); + putNodeShutdown(nodeToShutdownId, SingleNodeShutdownMetadata.Type.REMOVE, null); + assertBusy(() -> assertNodeShutdownStatus(nodeToShutdownId, COMPLETE)); + internalCluster().stopNode(nodeToShutdownName); + + ensureGreen(indexName); + } + private void indexRandomData(String index) throws Exception { int numDocs = scaledRandomIntBetween(100, 1000); IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs]; diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java index 7946bb7e46627..fcd70d5c215f1 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.shutdown; -import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -20,12 +19,10 @@ import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; -import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.NodesShutdownMetadata; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; -import org.elasticsearch.cluster.routing.RerouteService; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.cluster.service.MasterService; import org.elasticsearch.cluster.service.MasterServiceTaskQueue; import org.elasticsearch.common.Priority; import org.elasticsearch.common.inject.Inject; @@ -40,10 +37,12 @@ import java.util.Objects; import java.util.function.Predicate; +import static org.elasticsearch.cluster.routing.allocation.allocator.AllocationActionListener.rerouteCompletionIsNotRequired; + public class TransportPutShutdownNodeAction extends AcknowledgedTransportMasterNodeAction { private static final Logger logger = LogManager.getLogger(TransportPutShutdownNodeAction.class); - private final RerouteService rerouteService; + private final AllocationService allocationService; private final MasterServiceTaskQueue taskQueue; private final PutShutdownNodeExecutor executor = new PutShutdownNodeExecutor(); @@ -81,38 +80,6 @@ private static boolean putShutdownNodeState( return true; } - private static void ackAndMaybeReroute(Request request, ActionListener listener, RerouteService rerouteService) { - boolean shouldReroute = switch (request.getType()) { - case REMOVE, SIGTERM, REPLACE -> true; - default -> false; - }; - - if (shouldReroute) { - rerouteService.reroute("node registered for removal from cluster", Priority.URGENT, new ActionListener<>() { - @Override - public void onResponse(Void ignored) {} - - @Override - public void onFailure(Exception e) { - logger.log( - MasterService.isPublishFailureException(e) ? Level.DEBUG : Level.WARN, - () -> "failed to reroute after registering node [" + request.getNodeId() + "] for shutdown", - e - ); - } - }); - } else { - logger.trace( - () -> "not starting reroute after registering node [" - + request.getNodeId() - + "] for shutdown of type [" - + request.getType() - + "]" - ); - } - listener.onResponse(AcknowledgedResponse.TRUE); - } - // package private for tests record PutShutdownNodeTask(Request request, ActionListener listener) implements ClusterStateTaskListener { @Override @@ -130,6 +97,7 @@ public ClusterState execute(BatchExecutionContext batchExec var shutdownMetadata = new HashMap<>(initialState.metadata().nodeShutdowns().getAll()); Predicate nodeExistsPredicate = batchExecutionContext.initialState().getNodes()::nodeExists; boolean changed = false; + boolean needsReroute = false; for (final var taskContext : batchExecutionContext.taskContexts()) { var request = taskContext.getTask().request(); try (var ignored = taskContext.captureResponseHeaders()) { @@ -138,17 +106,34 @@ public ClusterState execute(BatchExecutionContext batchExec taskContext.onFailure(e); continue; } - taskContext.success(() -> ackAndMaybeReroute(request, taskContext.getTask().listener(), rerouteService)); + switch (request.getType()) { + case REMOVE, SIGTERM, REPLACE -> needsReroute = true; + } + taskContext.success(() -> { + logger.trace( + () -> "finished registering node [" + request.getNodeId() + "] for shutdown of type [" + request.getType() + "]" + ); + taskContext.getTask().listener.onResponse(AcknowledgedResponse.TRUE); + }); } if (changed == false) { - return batchExecutionContext.initialState(); + return initialState; } - return ClusterState.builder(batchExecutionContext.initialState()) - .metadata( - Metadata.builder(batchExecutionContext.initialState().metadata()) - .putCustom(NodesShutdownMetadata.TYPE, new NodesShutdownMetadata(shutdownMetadata)) - ) - .build(); + + final var updatedState = initialState.copyAndUpdateMetadata( + b -> b.putCustom(NodesShutdownMetadata.TYPE, new NodesShutdownMetadata(shutdownMetadata)) + ); + + if (needsReroute == false) { + return updatedState; + } + + // Reroute inline with the update, rather than using the RerouteService, in order to atomically update things like auto-expand + // replicas to account for the shutdown metadata. If the reroute were separate then the get-shutdown API might observe the + // intermediate state and report that nodes are ready to shut down prematurely. Even if the client were to wait for the + // put-shutdown API to complete there's a risk that it gets disconnected and retries, but the retry could well be a no-op which + // short-circuits past the cluster state update and therefore also doesn't wait for the background reroute. + return allocationService.reroute(updatedState, "reroute after put-shutdown", rerouteCompletionIsNotRequired()); } } @@ -156,7 +141,7 @@ public ClusterState execute(BatchExecutionContext batchExec public TransportPutShutdownNodeAction( TransportService transportService, ClusterService clusterService, - RerouteService rerouteService, + AllocationService allocationService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver @@ -172,7 +157,7 @@ public TransportPutShutdownNodeAction( indexNameExpressionResolver, EsExecutors.DIRECT_EXECUTOR_SERVICE ); - this.rerouteService = rerouteService; + this.allocationService = allocationService; taskQueue = clusterService.createTaskQueue("put-shutdown", Priority.URGENT, new PutShutdownNodeExecutor()); } diff --git a/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeActionTests.java b/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeActionTests.java index 1ea85f4ef07cf..d3f13a343df3c 100644 --- a/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeActionTests.java +++ b/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeActionTests.java @@ -15,7 +15,7 @@ import org.elasticsearch.cluster.ClusterStateTaskExecutor.TaskContext; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata.Type; -import org.elasticsearch.cluster.routing.RerouteService; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.MasterServiceTaskQueue; import org.elasticsearch.core.TimeValue; @@ -39,6 +39,7 @@ import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -64,7 +65,8 @@ public void init() { var threadPool = mock(ThreadPool.class); var transportService = MockUtils.setupTransportServiceWithThreadpoolExecutor(threadPool); clusterService = mock(ClusterService.class); - var rerouteService = mock(RerouteService.class); + var allocationService = mock(AllocationService.class); + when(allocationService.reroute(any(ClusterState.class), anyString(), any())).then(invocation -> invocation.getArgument(0)); var actionFilters = mock(ActionFilters.class); var indexNameExpressionResolver = mock(IndexNameExpressionResolver.class); when(clusterService.createTaskQueue(any(), any(), Mockito.>any())).thenReturn( @@ -73,7 +75,7 @@ public void init() { action = new TransportPutShutdownNodeAction( transportService, clusterService, - rerouteService, + allocationService, threadPool, actionFilters, indexNameExpressionResolver diff --git a/x-pack/plugin/slm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java b/x-pack/plugin/slm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java index 65666c6dd7fdb..6d0cd2142fe6e 100644 --- a/x-pack/plugin/slm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java +++ b/x-pack/plugin/slm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java @@ -6,8 +6,8 @@ */ package org.elasticsearch.xpack.slm; -import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryAction; import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest; +import org.elasticsearch.action.admin.cluster.repositories.put.TransportPutRepositoryAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; @@ -60,7 +60,7 @@ protected Collection> getPlugins() { public void testSLMIsInRunningModeWhenILMIsDisabled() throws Exception { client().execute( - PutRepositoryAction.INSTANCE, + TransportPutRepositoryAction.TYPE, new PutRepositoryRequest().name("repo") .type("fs") .settings(Settings.builder().put("repositories.fs.location", repositoryLocation).build()) diff --git a/x-pack/plugin/stack/src/javaRestTest/java/org/elasticsearch/xpack/stack/EcsDynamicTemplatesIT.java b/x-pack/plugin/stack/src/javaRestTest/java/org/elasticsearch/xpack/stack/EcsDynamicTemplatesIT.java index 25cea3b3f6e0a..75588baf6e6f4 100644 --- a/x-pack/plugin/stack/src/javaRestTest/java/org/elasticsearch/xpack/stack/EcsDynamicTemplatesIT.java +++ b/x-pack/plugin/stack/src/javaRestTest/java/org/elasticsearch/xpack/stack/EcsDynamicTemplatesIT.java @@ -182,6 +182,38 @@ public void testNestedFields() throws IOException { verifyEcsMappings(indexName); } + public void testNumericMessage() throws IOException { + String indexName = "test-numeric-message"; + createTestIndex(indexName); + Map fieldsMap = createTestDocument(false); + fieldsMap.put("message", 123); // Should be mapped as match_only_text + indexDocument(indexName, fieldsMap); + verifyEcsMappings(indexName); + } + + public void testUsage() throws IOException { + String indexName = "test-usage"; + createTestIndex(indexName); + Map fieldsMap = createTestDocument(false); + // Only non-root numeric (or coercable to numeric) "usage" fields should match + // ecs_usage_*_scaled_float; root fields and intermediate object fields should not match. + fieldsMap.put("host.cpu.usage", 123); // should be mapped as scaled_float + fieldsMap.put("string.usage", "123"); // should also be mapped as scale_float + fieldsMap.put("usage", 123); + fieldsMap.put("root.usage.long", 123); + fieldsMap.put("root.usage.float", 123.456); + indexDocument(indexName, fieldsMap); + + final Map rawMappings = getMappings(indexName); + final Map flatFieldMappings = new HashMap<>(); + processRawMappingsSubtree(rawMappings, flatFieldMappings, new HashMap<>(), ""); + assertEquals("scaled_float", flatFieldMappings.get("host.cpu.usage")); + assertEquals("scaled_float", flatFieldMappings.get("string.usage")); + assertEquals("long", flatFieldMappings.get("usage")); + assertEquals("long", flatFieldMappings.get("root.usage.long")); + assertEquals("float", flatFieldMappings.get("root.usage.float")); + } + private static void indexDocument(String indexName, Map flattenedFieldsMap) throws IOException { try (XContentBuilder bodyBuilder = JsonXContent.contentBuilder()) { Request indexRequest = new Request("POST", "/" + indexName + "/_doc"); diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java index 8dc8238b8230b..eb7e3eb91fe0f 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java @@ -43,7 +43,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry { // The stack template registry version. This number must be incremented when we make changes // to built-in templates. - public static final int REGISTRY_VERSION = 4; + public static final int REGISTRY_VERSION = 5; public static final String TEMPLATE_VERSION_VARIABLE = "xpack.stack.template.version"; public static final Setting STACK_TEMPLATES_ENABLED = Setting.boolSetting( diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportDeleteTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportDeleteTransformAction.java index 1c2f83c38a38e..d96ba88faff9a 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportDeleteTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportDeleteTransformAction.java @@ -10,8 +10,8 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; @@ -158,7 +158,7 @@ private void deleteDestinationIndex( config.getHeaders(), TRANSFORM_ORIGIN, client, - DeleteIndexAction.INSTANCE, + TransportDeleteIndexAction.TYPE, deleteDestIndexRequest, deleteDestIndexListener ); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java index e597254bfe713..ee394c7a128b4 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java @@ -12,8 +12,8 @@ import org.apache.lucene.util.SetOnce; import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; @@ -179,7 +179,7 @@ private void deleteDestinationIndexIfCreatedByTheTransform( } String destIndex = transformConfigAndVersionHolder.get().v1().getDestination().getIndex(); DeleteIndexRequest deleteDestIndexRequest = new DeleteIndexRequest(destIndex); - executeAsyncWithOrigin(client, TRANSFORM_ORIGIN, DeleteIndexAction.INSTANCE, deleteDestIndexRequest, finalListener); + executeAsyncWithOrigin(client, TRANSFORM_ORIGIN, TransportDeleteIndexAction.TYPE, deleteDestIndexRequest, finalListener); }, listener::onFailure); // <2> Check if the destination index was created by transform diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java index e87cf1ca7fc8d..b3cdea8ee80d8 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java @@ -15,8 +15,8 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteRequest; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; import org.elasticsearch.action.bulk.BulkItemResponse; @@ -304,7 +304,7 @@ public void deleteOldIndices(ActionListener listener) { IndicesOptions.LENIENT_EXPAND_OPEN ); - executeAsyncWithOrigin(client, TRANSFORM_ORIGIN, DeleteIndexAction.INSTANCE, deleteRequest, ActionListener.wrap(response -> { + executeAsyncWithOrigin(client, TRANSFORM_ORIGIN, TransportDeleteIndexAction.TYPE, deleteRequest, ActionListener.wrap(response -> { if (response.isAcknowledged() == false) { listener.onFailure(new ElasticsearchStatusException("Failed to delete internal indices", RestStatus.INTERNAL_SERVER_ERROR)); return; diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 14579fd50b8e2..fc1d200c91b82 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -68,6 +68,7 @@ import org.elasticsearch.xpack.core.watcher.execution.TriggeredWatchStoreField; import org.elasticsearch.xpack.core.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.core.watcher.input.none.NoneInput; +import org.elasticsearch.xpack.core.watcher.support.WatcherDateTimeUtils; import org.elasticsearch.xpack.core.watcher.transform.TransformRegistry; import org.elasticsearch.xpack.core.watcher.transport.actions.QueryWatchesAction; import org.elasticsearch.xpack.core.watcher.transport.actions.ack.AckWatchAction; @@ -533,6 +534,7 @@ public void afterBulk(long executionId, BulkRequest request, Exception failure) listener = new WatcherIndexingListener(watchParser, getClock(), triggerService, watcherLifeCycleService.getState()); clusterService.addListener(listener); + logger.info("Watcher initialized components at {}", WatcherDateTimeUtils.dateTimeFormatter.formatMillis(getClock().millis())); // note: clock is needed here until actions can be constructed directly instead of by guice return Arrays.asList( new ClockHolder(getClock()), diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java index d6531fb8f145a..ba07c3137340d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.Maps; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.xpack.core.watcher.support.WatcherDateTimeUtils; import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent; import org.elasticsearch.xpack.core.watcher.watch.Watch; import org.elasticsearch.xpack.watcher.trigger.schedule.Schedule; @@ -59,6 +60,7 @@ public TickerScheduleTriggerEngine(Settings settings, ScheduleRegistry scheduleR @Override public synchronized void start(Collection jobs) { long startTime = clock.millis(); + logger.info("Watcher starting watches at {}", WatcherDateTimeUtils.dateTimeFormatter.formatMillis(startTime)); Map startingSchedules = Maps.newMapWithExpectedSize(jobs.size()); for (Watch job : jobs) { if (job.trigger() instanceof ScheduleTrigger trigger) { @@ -154,6 +156,11 @@ static class ActiveSchedule { this.schedule = schedule; this.startTime = startTime; this.scheduledTime = schedule.nextScheduledTimeAfter(startTime, startTime); + logger.debug( + "Watcher: activating schedule for watch '{}', first run at {}", + name, + WatcherDateTimeUtils.dateTimeFormatter.formatMillis(scheduledTime) + ); } /** diff --git a/x-pack/qa/password-protected-keystore/src/javaRestTest/java/org/elasticsearch/password_protected_keystore/ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT.java b/x-pack/qa/password-protected-keystore/src/javaRestTest/java/org/elasticsearch/password_protected_keystore/ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT.java index 49950b553bb20..0625ec166e32c 100644 --- a/x-pack/qa/password-protected-keystore/src/javaRestTest/java/org/elasticsearch/password_protected_keystore/ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT.java +++ b/x-pack/qa/password-protected-keystore/src/javaRestTest/java/org/elasticsearch/password_protected_keystore/ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT.java @@ -37,12 +37,12 @@ public class ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT extends ESR .nodes(NUM_NODES) .keystorePassword(KEYSTORE_PASSWORD) .name("javaRestTest") + .keystore(nodeSpec -> Map.of("xpack.security.transport.ssl.secure_key_passphrase", "transport-password")) .setting("xpack.security.enabled", "true") .setting("xpack.security.authc.anonymous.roles", "anonymous") .setting("xpack.security.transport.ssl.enabled", "true") .setting("xpack.security.transport.ssl.certificate", "transport.crt") .setting("xpack.security.transport.ssl.key", "transport.key") - .setting("xpack.security.transport.ssl.key_passphrase", "transport-password") .setting("xpack.security.transport.ssl.certificate_authorities", "ca.crt") .rolesFile(Resource.fromClasspath("roles.yml")) .configFile("transport.key", Resource.fromClasspath("ssl/transport.key"))