From 91b480cfb67989d15a30eb6acf2165965de0cff0 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Fri, 6 Nov 2020 10:41:18 -0600 Subject: [PATCH 1/4] remote deprecated _upgrade API --- .../api/indices.get_upgrade.json | 61 ------ .../rest-api-spec/api/indices.upgrade.json | 69 ------ .../test/indices.upgrade/10_basic.yml | 112 ---------- .../test/indices.upgrade/20_deprecated.yml | 102 --------- .../admin/cluster/node/tasks/TasksIT.java | 14 +- .../metadata/UpgradeIndexSettingsIT.java | 50 ----- .../elasticsearch/action/ActionModule.java | 13 -- .../upgrade/get/IndexShardUpgradeStatus.java | 78 ------- .../upgrade/get/IndexUpgradeStatus.java | 95 --------- .../upgrade/get/ShardUpgradeStatus.java | 80 ------- .../get/TransportUpgradeStatusAction.java | 117 ----------- .../upgrade/get/UpgradeStatusAction.java | 32 --- .../upgrade/get/UpgradeStatusRequest.java | 42 ---- .../get/UpgradeStatusRequestBuilder.java | 31 --- .../upgrade/get/UpgradeStatusResponse.java | 185 ---------------- .../upgrade/post/ShardUpgradeResult.java | 82 -------- .../upgrade/post/TransportUpgradeAction.java | 197 ------------------ .../post/TransportUpgradeSettingsAction.java | 82 -------- .../indices/upgrade/post/UpgradeAction.java | 35 ---- .../indices/upgrade/post/UpgradeRequest.java | 85 -------- .../upgrade/post/UpgradeRequestBuilder.java | 42 ---- .../indices/upgrade/post/UpgradeResponse.java | 82 -------- .../upgrade/post/UpgradeSettingsAction.java | 34 --- ...radeSettingsClusterStateUpdateRequest.java | 53 ----- .../upgrade/post/UpgradeSettingsRequest.java | 89 -------- .../post/UpgradeSettingsRequestBuilder.java | 47 ----- .../client/IndicesAdminClient.java | 52 ----- .../org/elasticsearch/client/Requests.java | 12 -- .../client/support/AbstractClient.java | 38 ---- .../MetadataUpdateSettingsService.java | 36 ---- .../elasticsearch/index/shard/IndexShard.java | 23 -- .../indices/RestUpgradeActionDeprecated.java | 64 ------ .../RestUpgradeStatusActionDeprecated.java | 62 ------ .../authz/store/ReservedRolesStoreTests.java | 7 +- .../datastreams/DataStreamIT.java | 4 - .../MultipleIndicesPermissionsTests.java | 6 - .../authz/AuthorizationServiceTests.java | 5 - 37 files changed, 8 insertions(+), 2210 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_upgrade.json delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/indices.upgrade.json delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/10_basic.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/20_deprecated.yml delete mode 100644 server/src/internalClusterTest/java/org/elasticsearch/cluster/metadata/UpgradeIndexSettingsIT.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexShardUpgradeStatus.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/ShardUpgradeStatus.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusAction.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequest.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequestBuilder.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/ShardUpgradeResult.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeAction.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequest.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequestBuilder.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeResponse.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsClusterStateUpdateRequest.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequest.java delete mode 100644 server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequestBuilder.java delete mode 100644 server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java delete mode 100644 server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_upgrade.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_upgrade.json deleted file mode 100644 index 68cfdf25aeea2..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_upgrade.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "indices.get_upgrade":{ - "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html", - "description":"DEPRECATED Returns a progress status of current upgrade." - }, - "stability":"stable", - "url":{ - "paths":[ - { - "path":"/_upgrade", - "methods":[ - "GET" - ], - "deprecated":{ - "version":"8.0.0", - "description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - } - }, - { - "path":"/{index}/_upgrade", - "methods":[ - "GET" - ], - "parts":{ - "index":{ - "type":"list", - "description":"A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" - } - }, - "deprecated":{ - "version":"8.0.0", - "description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - } - } - ] - }, - "params":{ - "ignore_unavailable":{ - "type":"boolean", - "description":"Whether specified concrete indices should be ignored when unavailable (missing or closed)" - }, - "allow_no_indices":{ - "type":"boolean", - "description":"Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" - }, - "expand_wildcards":{ - "type":"enum", - "options":[ - "open", - "closed", - "hidden", - "none", - "all" - ], - "default":"open", - "description":"Whether to expand wildcard expression to concrete indices that are open, closed or both." - } - } - } -} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.upgrade.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.upgrade.json deleted file mode 100644 index 406fbacda307c..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.upgrade.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "indices.upgrade":{ - "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html", - "description":"DEPRECATED Upgrades to the current version of Lucene." - }, - "stability":"stable", - "url":{ - "paths":[ - { - "path":"/_upgrade", - "methods":[ - "POST" - ], - "deprecated":{ - "version":"8.0.0", - "description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - } - }, - { - "path":"/{index}/_upgrade", - "methods":[ - "POST" - ], - "parts":{ - "index":{ - "type":"list", - "description":"A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" - } - }, - "deprecated":{ - "version":"8.0.0", - "description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - } - } - ] - }, - "params":{ - "allow_no_indices":{ - "type":"boolean", - "description":"Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" - }, - "expand_wildcards":{ - "type":"enum", - "options":[ - "open", - "closed", - "hidden", - "none", - "all" - ], - "default":"open", - "description":"Whether to expand wildcard expression to concrete indices that are open, closed or both." - }, - "ignore_unavailable":{ - "type":"boolean", - "description":"Whether specified concrete indices should be ignored when unavailable (missing or closed)" - }, - "wait_for_completion":{ - "type":"boolean", - "description":"Specify whether the request should block until the all segments are upgraded (default: false)" - }, - "only_ancient_segments":{ - "type":"boolean", - "description":"If true, only ancient (an older Lucene major release) segments will be upgraded" - } - } - } -} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/10_basic.yml deleted file mode 100644 index d4479680f475d..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/10_basic.yml +++ /dev/null @@ -1,112 +0,0 @@ ---- -"Basic test for upgrade indices": - - skip: - version: " - 7.10.99" - reason: "_upgrade api is deprecated since 7.11.0" - features: ["warnings", "node_selector"] - - - do: - indices.create: - index: test_index - body: - settings: - index: - number_of_replicas: 0 - - - do: - indices.upgrade: - index: test_index - warnings: - - "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - node_selector: - version: "7.11.0 - " - - - match: {upgraded_indices.test_index.oldest_lucene_segment_version: '/(\d\.)+\d/'} - - is_true: upgraded_indices.test_index.upgrade_version - ---- -"Upgrade indices ignore unavailable": - - skip: - version: " - 7.10.99" - reason: "_upgrade api is deprecated since 7.11.0" - features: ["warnings", "node_selector"] - - - do: - indices.create: - index: test_index - body: - settings: - index: - number_of_shards: 1 - number_of_replicas: 0 - - - do: - indices.upgrade: - index: ["does_not_exist", "test_index"] - ignore_unavailable: true - warnings: - - "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - node_selector: - version: "7.11.0 - " - - - match: {_shards.total: 1} - - is_true: upgraded_indices.test_index.upgrade_version - - is_false: upgraded_indices.does_not_exist - ---- -"Upgrade indices allow no indices": - - skip: - version: " - 7.10.99" - reason: "_upgrade api is deprecated since 7.11.0" - features: ["warnings", "node_selector"] - - - do: - indices.upgrade: - index: test_index - ignore_unavailable: true - allow_no_indices: true - warnings: - - "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - node_selector: - version: "7.11.0 - " - - - match: {_shards.total: 0} - ---- -"Upgrade indices disallow no indices": - - skip: - version: " - 7.10.99" - reason: "_upgrade api is deprecated since 7.11.0" - features: ["warnings", "node_selector"] - - - do: - catch: missing - indices.upgrade: - index: test_index - ignore_unavailable: true - allow_no_indices: false - warnings: - - "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - node_selector: - version: "7.11.0 - " - ---- -"Upgrade indices disallow unavailable": - - skip: - version: " - 7.10.99" - reason: "_upgrade api is deprecated since 7.11.0" - features: ["warnings", "node_selector"] - - - do: - indices.create: - index: test_index - - - do: - catch: missing - indices.upgrade: - index: ["test_index", "does_not_exist"] - ignore_unavailable: false - warnings: - - "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API." - node_selector: - version: "7.11.0 - " diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/20_deprecated.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/20_deprecated.yml deleted file mode 100644 index 3801b6d02f265..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/20_deprecated.yml +++ /dev/null @@ -1,102 +0,0 @@ ---- -"Basic test for upgrade indices < 7.11.0": - - skip: - version: "7.11.0 - " - reason: "_upgrade api has deprecation header since 7.11.0" - features: "node_selector" - - - do: - indices.create: - index: test_index - body: - settings: - index: - number_of_replicas: 0 - - - do: - indices.upgrade: - index: test_index - node_selector: - version: " - 7.10.99" - - - match: {upgraded_indices.test_index.oldest_lucene_segment_version: '/(\d\.)+\d/'} - - is_true: upgraded_indices.test_index.upgrade_version - ---- -"Upgrade indices ignore unavailable < 7.11.0": - - skip: - version: "7.11.0 - " - reason: "_upgrade api has deprecation header since 7.11.0" - features: "node_selector" - - - do: - indices.create: - index: test_index - body: - settings: - index: - number_of_shards: 1 - number_of_replicas: 0 - - - do: - indices.upgrade: - index: ["does_not_exist", "test_index"] - ignore_unavailable: true - node_selector: - version: " - 7.10.99" - - - match: {_shards.total: 1} - - is_true: upgraded_indices.test_index.upgrade_version - - is_false: upgraded_indices.does_not_exist - ---- -"Upgrade indices allow no indices < 7.11.0": - - skip: - version: "7.11.0 - " - reason: "_upgrade api has deprecation header since 7.11.0" - features: "node_selector" - - - do: - indices.upgrade: - index: test_index - ignore_unavailable: true - allow_no_indices: true - node_selector: - version: " - 7.10.99" - - - match: {_shards.total: 0} - ---- -"Upgrade indices disallow no indices < 7.11.0": - - skip: - version: "7.11.0 - " - reason: "_upgrade api has deprecation header since 7.11.0" - features: "node_selector" - - - do: - catch: missing - indices.upgrade: - index: test_index - ignore_unavailable: true - allow_no_indices: false - node_selector: - version: " - 7.10.99" - ---- -"Upgrade indices disallow unavailable < 7.11.0": - - skip: - version: "7.11.0 - " - reason: "_upgrade api has deprecation header since 7.11.0" - features: "node_selector" - - - do: - indices.create: - index: test_index - - - do: - catch: missing - indices.upgrade: - index: ["test_index", "does_not_exist"] - ignore_unavailable: false - node_selector: - version: " - 7.10.99" diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java index 954042c2e4d05..4917a26be50ec 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java @@ -31,8 +31,8 @@ import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskResponse; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksAction; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; +import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeAction; import org.elasticsearch.action.admin.indices.refresh.RefreshAction; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeAction; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryAction; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.index.IndexAction; @@ -181,19 +181,19 @@ public void testTransportReplicationAllShardsTasks() { } public void testTransportBroadcastByNodeTasks() { - registerTaskManagerListeners(UpgradeAction.NAME); // main task - registerTaskManagerListeners(UpgradeAction.NAME + "[n]"); // node level tasks + registerTaskManagerListeners(ForceMergeAction.NAME); // main task + registerTaskManagerListeners(ForceMergeAction.NAME + "[n]"); // node level tasks createIndex("test"); ensureGreen("test"); // Make sure all shards are allocated - client().admin().indices().prepareUpgrade("test").get(); + client().admin().indices().prepareForceMerge("test").get(); // the percolate operation should produce one main task - assertEquals(1, numberOfEvents(UpgradeAction.NAME, Tuple::v1)); + assertEquals(1, numberOfEvents(ForceMergeAction.NAME, Tuple::v1)); // and then one operation per each node where shards are located - assertEquals(internalCluster().nodesInclude("test").size(), numberOfEvents(UpgradeAction.NAME + "[n]", Tuple::v1)); + assertEquals(internalCluster().nodesInclude("test").size(), numberOfEvents(ForceMergeAction.NAME + "[n]", Tuple::v1)); // all node level tasks should have the main task as a parent - assertParentTask(findEvents(UpgradeAction.NAME + "[n]", Tuple::v1), findEvents(UpgradeAction.NAME, Tuple::v1).get(0)); + assertParentTask(findEvents(ForceMergeAction.NAME + "[n]", Tuple::v1), findEvents(ForceMergeAction.NAME, Tuple::v1).get(0)); } public void testTransportReplicationSingleShardTasks() { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/metadata/UpgradeIndexSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/metadata/UpgradeIndexSettingsIT.java deleted file mode 100644 index d6d509de073bd..0000000000000 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/metadata/UpgradeIndexSettingsIT.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.cluster.metadata; - -import org.elasticsearch.Version; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.test.ESSingleNodeTestCase; - -import static org.hamcrest.Matchers.equalTo; - -public class UpgradeIndexSettingsIT extends ESSingleNodeTestCase { - - @Override - protected boolean forbidPrivateIndexSettings() { - return false; - } - - public void testSettingsVersion() { - createIndex( - "test", - Settings - .builder() - .put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), Version.CURRENT.minimumIndexCompatibilityVersion()) - .build()); - final long settingsVersion = - client().admin().cluster().prepareState().get().getState().metadata().index("test").getSettingsVersion(); - client().admin().indices().prepareUpgrade("test").get(); - assertThat( - client().admin().cluster().prepareState().get().getState().metadata().index("test").getSettingsVersion(), - equalTo(1 + settingsVersion)); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index b96189ef69764..e940a265fad02 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -181,12 +181,6 @@ import org.elasticsearch.action.admin.indices.template.put.TransportPutComponentTemplateAction; import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction; import org.elasticsearch.action.admin.indices.template.put.TransportPutIndexTemplateAction; -import org.elasticsearch.action.admin.indices.upgrade.get.TransportUpgradeStatusAction; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusAction; -import org.elasticsearch.action.admin.indices.upgrade.post.TransportUpgradeAction; -import org.elasticsearch.action.admin.indices.upgrade.post.TransportUpgradeSettingsAction; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeAction; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeSettingsAction; import org.elasticsearch.action.admin.indices.validate.query.TransportValidateQueryAction; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryAction; import org.elasticsearch.action.bulk.BulkAction; @@ -342,8 +336,6 @@ import org.elasticsearch.rest.action.admin.indices.RestSimulateTemplateAction; import org.elasticsearch.rest.action.admin.indices.RestSyncedFlushAction; import org.elasticsearch.rest.action.admin.indices.RestUpdateSettingsAction; -import org.elasticsearch.rest.action.admin.indices.RestUpgradeActionDeprecated; -import org.elasticsearch.rest.action.admin.indices.RestUpgradeStatusActionDeprecated; import org.elasticsearch.rest.action.admin.indices.RestValidateQueryAction; import org.elasticsearch.rest.action.cat.AbstractCatAction; import org.elasticsearch.rest.action.cat.RestAliasAction; @@ -551,9 +543,6 @@ public void reg actions.register(RefreshAction.INSTANCE, TransportRefreshAction.class); actions.register(FlushAction.INSTANCE, TransportFlushAction.class); actions.register(ForceMergeAction.INSTANCE, TransportForceMergeAction.class); - actions.register(UpgradeAction.INSTANCE, TransportUpgradeAction.class); - actions.register(UpgradeStatusAction.INSTANCE, TransportUpgradeStatusAction.class); - actions.register(UpgradeSettingsAction.INSTANCE, TransportUpgradeSettingsAction.class); actions.register(ClearIndicesCacheAction.INSTANCE, TransportClearIndicesCacheAction.class); actions.register(GetAliasesAction.INSTANCE, TransportGetAliasesAction.class); actions.register(GetSettingsAction.INSTANCE, TransportGetSettingsAction.class); @@ -710,8 +699,6 @@ public void initRestHandlers(Supplier nodesInCluster) { registerHandler.accept(new RestFlushAction()); registerHandler.accept(new RestSyncedFlushAction()); registerHandler.accept(new RestForceMergeAction()); - registerHandler.accept(new RestUpgradeActionDeprecated()); - registerHandler.accept(new RestUpgradeStatusActionDeprecated()); registerHandler.accept(new RestClearIndicesCacheAction()); registerHandler.accept(new RestResolveIndexAction()); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexShardUpgradeStatus.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexShardUpgradeStatus.java deleted file mode 100644 index c4b5820e28bed..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexShardUpgradeStatus.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import org.elasticsearch.index.shard.ShardId; - -import java.util.Arrays; -import java.util.Iterator; - -public class IndexShardUpgradeStatus implements Iterable { - - private final ShardId shardId; - - private final ShardUpgradeStatus[] shards; - - IndexShardUpgradeStatus(ShardId shardId, ShardUpgradeStatus[] shards) { - this.shardId = shardId; - this.shards = shards; - } - - public ShardId getShardId() { - return this.shardId; - } - - public ShardUpgradeStatus getAt(int i) { - return shards[i]; - } - - public ShardUpgradeStatus[] getShards() { - return this.shards; - } - - @Override - public Iterator iterator() { - return Arrays.stream(shards).iterator(); - } - - public long getTotalBytes() { - long totalBytes = 0; - for (ShardUpgradeStatus indexShardUpgradeStatus : shards) { - totalBytes += indexShardUpgradeStatus.getTotalBytes(); - } - return totalBytes; - } - - public long getToUpgradeBytes() { - long upgradeBytes = 0; - for (ShardUpgradeStatus indexShardUpgradeStatus : shards) { - upgradeBytes += indexShardUpgradeStatus.getToUpgradeBytes(); - } - return upgradeBytes; - } - - public long getToUpgradeBytesAncient() { - long upgradeBytesAncient = 0; - for (ShardUpgradeStatus indexShardUpgradeStatus : shards) { - upgradeBytesAncient += indexShardUpgradeStatus.getToUpgradeBytesAncient(); - } - return upgradeBytesAncient; - } -} \ No newline at end of file diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java deleted file mode 100644 index 68054595701ad..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -public class IndexUpgradeStatus implements Iterable { - - private final String index; - - private final Map indexShards; - - IndexUpgradeStatus(String index, ShardUpgradeStatus[] shards) { - this.index = index; - - Map> tmpIndexShards = new HashMap<>(); - for (ShardUpgradeStatus shard : shards) { - List lst = tmpIndexShards.get(shard.getShardRouting().id()); - if (lst == null) { - lst = new ArrayList<>(); - tmpIndexShards.put(shard.getShardRouting().id(), lst); - } - lst.add(shard); - } - indexShards = new HashMap<>(); - for (Map.Entry> entry : tmpIndexShards.entrySet()) { - indexShards.put(entry.getKey(), new IndexShardUpgradeStatus(entry.getValue().get(0).getShardRouting().shardId(), - entry.getValue().toArray(new ShardUpgradeStatus[entry.getValue().size()]))); - } - } - - public String getIndex() { - return this.index; - } - - /** - * A shard id to index shard upgrade status map (note, index shard upgrade status is the replication shard group that maps - * to the shard id). - */ - public Map getShards() { - return this.indexShards; - } - - @Override - public Iterator iterator() { - return indexShards.values().iterator(); - } - - public long getTotalBytes() { - long totalBytes = 0; - for (IndexShardUpgradeStatus indexShardUpgradeStatus : indexShards.values()) { - totalBytes += indexShardUpgradeStatus.getTotalBytes(); - } - return totalBytes; - } - - public long getToUpgradeBytes() { - long upgradeBytes = 0; - for (IndexShardUpgradeStatus indexShardUpgradeStatus : indexShards.values()) { - upgradeBytes += indexShardUpgradeStatus.getToUpgradeBytes(); - } - return upgradeBytes; - } - - public long getToUpgradeBytesAncient() { - long upgradeBytesAncient = 0; - for (IndexShardUpgradeStatus indexShardUpgradeStatus : indexShards.values()) { - upgradeBytesAncient += indexShardUpgradeStatus.getToUpgradeBytesAncient(); - } - return upgradeBytesAncient; - } - - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/ShardUpgradeStatus.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/ShardUpgradeStatus.java deleted file mode 100644 index 144bfb98a0b31..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/ShardUpgradeStatus.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import org.elasticsearch.action.support.broadcast.BroadcastShardResponse; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; - -public class ShardUpgradeStatus extends BroadcastShardResponse { - - private ShardRouting shardRouting; - - private long totalBytes; - - private long toUpgradeBytes; - - private long toUpgradeBytesAncient; - - public ShardUpgradeStatus(StreamInput in) throws IOException { - super(in); - shardRouting = new ShardRouting(in); - totalBytes = in.readLong(); - toUpgradeBytes = in.readLong(); - toUpgradeBytesAncient = in.readLong(); - } - - ShardUpgradeStatus(ShardRouting shardRouting, long totalBytes, long toUpgradeBytes, long upgradeBytesAncient) { - super(shardRouting.shardId()); - this.shardRouting = shardRouting; - this.totalBytes = totalBytes; - this.toUpgradeBytes = toUpgradeBytes; - this.toUpgradeBytesAncient = upgradeBytesAncient; - - } - - public ShardRouting getShardRouting() { - return this.shardRouting; - } - - public long getTotalBytes() { - return totalBytes; - } - - public long getToUpgradeBytes() { - return toUpgradeBytes; - } - - public long getToUpgradeBytesAncient() { - return toUpgradeBytesAncient; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - shardRouting.writeTo(out); - out.writeLong(totalBytes); - out.writeLong(toUpgradeBytes); - out.writeLong(toUpgradeBytesAncient); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java deleted file mode 100644 index dbd0308327c84..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import org.elasticsearch.Version; -import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.block.ClusterBlockException; -import org.elasticsearch.cluster.block.ClusterBlockLevel; -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.cluster.routing.ShardsIterator; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.engine.Segment; -import org.elasticsearch.index.shard.IndexShard; -import org.elasticsearch.indices.IndicesService; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; - -import java.io.IOException; -import java.util.List; - -public class TransportUpgradeStatusAction - extends TransportBroadcastByNodeAction { - - private final IndicesService indicesService; - - @Inject - public TransportUpgradeStatusAction(ClusterService clusterService, TransportService transportService, - IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver) { - super(UpgradeStatusAction.NAME, clusterService, transportService, actionFilters, indexNameExpressionResolver, - UpgradeStatusRequest::new, ThreadPool.Names.MANAGEMENT); - this.indicesService = indicesService; - } - - /** - * Getting upgrade stats from *all* active shards. - */ - @Override - protected ShardsIterator shards(ClusterState clusterState, UpgradeStatusRequest request, String[] concreteIndices) { - return clusterState.routingTable().allShards(concreteIndices); - } - - @Override - protected ClusterBlockException checkGlobalBlock(ClusterState state, UpgradeStatusRequest request) { - return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ); - } - - @Override - protected ClusterBlockException checkRequestBlock(ClusterState state, UpgradeStatusRequest countRequest, String[] concreteIndices) { - return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, concreteIndices); - } - - @Override - protected ShardUpgradeStatus readShardResult(StreamInput in) throws IOException { - return new ShardUpgradeStatus(in); - } - - @Override - protected UpgradeStatusResponse newResponse(UpgradeStatusRequest request, int totalShards, int successfulShards, int failedShards, - List responses, - List shardFailures, ClusterState clusterState) { - return new UpgradeStatusResponse(responses.toArray(new ShardUpgradeStatus[responses.size()]), totalShards, successfulShards, - failedShards, shardFailures); - } - - @Override - protected UpgradeStatusRequest readRequestFrom(StreamInput in) throws IOException { - return new UpgradeStatusRequest(in); - } - - @Override - protected ShardUpgradeStatus shardOperation(UpgradeStatusRequest request, ShardRouting shardRouting) { - IndexService indexService = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()); - IndexShard indexShard = indexService.getShard(shardRouting.shardId().id()); - List segments = indexShard.segments(false); - long total_bytes = 0; - long to_upgrade_bytes = 0; - long to_upgrade_bytes_ancient = 0; - for (Segment seg : segments) { - total_bytes += seg.sizeInBytes; - if (seg.version.major != Version.CURRENT.luceneVersion.major) { - to_upgrade_bytes_ancient += seg.sizeInBytes; - to_upgrade_bytes += seg.sizeInBytes; - } else if (seg.version.minor != Version.CURRENT.luceneVersion.minor) { - // TODO: this comparison is bogus! it would cause us to upgrade even with the same format - // instead, we should check if the codec has changed - to_upgrade_bytes += seg.sizeInBytes; - } - } - - return new ShardUpgradeStatus(indexShard.routingEntry(), total_bytes, to_upgrade_bytes, to_upgrade_bytes_ancient); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusAction.java deleted file mode 100644 index 27060c061929f..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusAction.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import org.elasticsearch.action.ActionType; - -public class UpgradeStatusAction extends ActionType { - - public static final UpgradeStatusAction INSTANCE = new UpgradeStatusAction(); - public static final String NAME = "indices:monitor/upgrade"; - - private UpgradeStatusAction() { - super(NAME, UpgradeStatusResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequest.java deleted file mode 100644 index c42a9c11860c2..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import org.elasticsearch.action.support.broadcast.BroadcastRequest; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.io.stream.StreamInput; - -import java.io.IOException; - -public class UpgradeStatusRequest extends BroadcastRequest { - - public UpgradeStatusRequest() { - this(Strings.EMPTY_ARRAY); - } - - public UpgradeStatusRequest(StreamInput in) throws IOException { - super(in); - } - - public UpgradeStatusRequest(String... indices) { - super(indices); - } - -} \ No newline at end of file diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequestBuilder.java deleted file mode 100644 index e359b191ffdba..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusRequestBuilder.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder; -import org.elasticsearch.client.ElasticsearchClient; - -public class UpgradeStatusRequestBuilder - extends BroadcastOperationRequestBuilder { - - public UpgradeStatusRequestBuilder(ElasticsearchClient client, UpgradeStatusAction action) { - super(client, action, new UpgradeStatusRequest()); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java deleted file mode 100644 index cce1c5a673527..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.get; - -import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.broadcast.BroadcastResponse; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.XContentBuilder; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class UpgradeStatusResponse extends BroadcastResponse { - private ShardUpgradeStatus[] shards; - - private Map indicesUpgradeStatus; - - UpgradeStatusResponse(StreamInput in) throws IOException { - super(in); - shards = new ShardUpgradeStatus[in.readVInt()]; - for (int i = 0; i < shards.length; i++) { - shards[i] = new ShardUpgradeStatus(in); - } - } - - UpgradeStatusResponse(ShardUpgradeStatus[] shards, int totalShards, int successfulShards, int failedShards, - List shardFailures) { - super(totalShards, successfulShards, failedShards, shardFailures); - this.shards = shards; - } - - public Map getIndices() { - if (indicesUpgradeStatus != null) { - return indicesUpgradeStatus; - } - Map indicesUpgradeStats = new HashMap<>(); - - Set indices = new HashSet<>(); - for (ShardUpgradeStatus shard : shards) { - indices.add(shard.getIndex()); - } - - for (String indexName : indices) { - List shards = new ArrayList<>(); - for (ShardUpgradeStatus shard : this.shards) { - if (shard.getShardRouting().getIndexName().equals(indexName)) { - shards.add(shard); - } - } - indicesUpgradeStats.put(indexName, new IndexUpgradeStatus(indexName, shards.toArray(new ShardUpgradeStatus[shards.size()]))); - } - this.indicesUpgradeStatus = indicesUpgradeStats; - return indicesUpgradeStats; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeVInt(shards.length); - for (ShardUpgradeStatus shard : shards) { - shard.writeTo(out); - } - } - - public long getTotalBytes() { - long totalBytes = 0; - for (IndexUpgradeStatus indexShardUpgradeStatus : getIndices().values()) { - totalBytes += indexShardUpgradeStatus.getTotalBytes(); - } - return totalBytes; - } - - public long getToUpgradeBytes() { - long upgradeBytes = 0; - for (IndexUpgradeStatus indexShardUpgradeStatus : getIndices().values()) { - upgradeBytes += indexShardUpgradeStatus.getToUpgradeBytes(); - } - return upgradeBytes; - } - - public long getToUpgradeBytesAncient() { - long upgradeBytesAncient = 0; - for (IndexUpgradeStatus indexShardUpgradeStatus : getIndices().values()) { - upgradeBytesAncient += indexShardUpgradeStatus.getToUpgradeBytesAncient(); - } - return upgradeBytesAncient; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(); - builder.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(getTotalBytes())); - builder.humanReadableField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, new ByteSizeValue(getToUpgradeBytes())); - builder.humanReadableField(Fields.SIZE_TO_UPGRADE_ANCIENT_IN_BYTES, Fields.SIZE_TO_UPGRADE_ANCIENT, - new ByteSizeValue(getToUpgradeBytesAncient())); - - String level = params.param("level", "indices"); - boolean outputShards = "shards".equals(level); - boolean outputIndices = "indices".equals(level) || outputShards; - if (outputIndices) { - builder.startObject(Fields.INDICES); - for (IndexUpgradeStatus indexUpgradeStatus : getIndices().values()) { - builder.startObject(indexUpgradeStatus.getIndex()); - - builder.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(indexUpgradeStatus.getTotalBytes())); - builder.humanReadableField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, - new ByteSizeValue(indexUpgradeStatus.getToUpgradeBytes())); - builder.humanReadableField(Fields.SIZE_TO_UPGRADE_ANCIENT_IN_BYTES, Fields.SIZE_TO_UPGRADE_ANCIENT, - new ByteSizeValue(indexUpgradeStatus.getToUpgradeBytesAncient())); - if (outputShards) { - builder.startObject(Fields.SHARDS); - for (IndexShardUpgradeStatus indexShardUpgradeStatus : indexUpgradeStatus) { - builder.startArray(Integer.toString(indexShardUpgradeStatus.getShardId().id())); - for (ShardUpgradeStatus shardUpgradeStatus : indexShardUpgradeStatus) { - builder.startObject(); - - builder.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(getTotalBytes())); - builder.humanReadableField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, - new ByteSizeValue(getToUpgradeBytes())); - builder.humanReadableField(Fields.SIZE_TO_UPGRADE_ANCIENT_IN_BYTES, Fields.SIZE_TO_UPGRADE_ANCIENT, - new ByteSizeValue(getToUpgradeBytesAncient())); - - builder.startObject(Fields.ROUTING); - builder.field(Fields.STATE, shardUpgradeStatus.getShardRouting().state()); - builder.field(Fields.PRIMARY, shardUpgradeStatus.getShardRouting().primary()); - builder.field(Fields.NODE, shardUpgradeStatus.getShardRouting().currentNodeId()); - if (shardUpgradeStatus.getShardRouting().relocatingNodeId() != null) { - builder.field(Fields.RELOCATING_NODE, shardUpgradeStatus.getShardRouting().relocatingNodeId()); - } - builder.endObject(); - - builder.endObject(); - } - builder.endArray(); - } - builder.endObject(); - } - builder.endObject(); - } - builder.endObject(); - } - builder.endObject(); - return builder; - } - - static final class Fields { - static final String INDICES = "indices"; - static final String SHARDS = "shards"; - static final String ROUTING = "routing"; - static final String STATE = "state"; - static final String PRIMARY = "primary"; - static final String NODE = "node"; - static final String RELOCATING_NODE = "relocating_node"; - static final String SIZE = "size"; - static final String SIZE_IN_BYTES = "size_in_bytes"; - static final String SIZE_TO_UPGRADE = "size_to_upgrade"; - static final String SIZE_TO_UPGRADE_ANCIENT = "size_to_upgrade_ancient"; - static final String SIZE_TO_UPGRADE_IN_BYTES = "size_to_upgrade_in_bytes"; - static final String SIZE_TO_UPGRADE_ANCIENT_IN_BYTES = "size_to_upgrade_ancient_in_bytes"; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/ShardUpgradeResult.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/ShardUpgradeResult.java deleted file mode 100644 index 14dae446d1f0e..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/ShardUpgradeResult.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.Version; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.index.shard.ShardId; - -import java.io.IOException; -import java.text.ParseException; - -class ShardUpgradeResult implements Writeable { - - private ShardId shardId; - - private org.apache.lucene.util.Version oldestLuceneSegment; - - private Version upgradeVersion; - - private boolean primary; - - ShardUpgradeResult(ShardId shardId, boolean primary, Version upgradeVersion, org.apache.lucene.util.Version oldestLuceneSegment) { - this.shardId = shardId; - this.primary = primary; - this.upgradeVersion = upgradeVersion; - this.oldestLuceneSegment = oldestLuceneSegment; - } - - ShardUpgradeResult(StreamInput in) throws IOException { - shardId = new ShardId(in); - primary = in.readBoolean(); - upgradeVersion = Version.readVersion(in); - try { - oldestLuceneSegment = org.apache.lucene.util.Version.parse(in.readString()); - } catch (ParseException ex) { - throw new IOException("failed to parse lucene version [" + oldestLuceneSegment + "]", ex); - } - } - - public ShardId getShardId() { - return shardId; - } - - public org.apache.lucene.util.Version oldestLuceneSegment() { - return this.oldestLuceneSegment; - } - - public Version upgradeVersion() { - return this.upgradeVersion; - } - - public boolean primary() { - return primary; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - shardId.writeTo(out); - out.writeBoolean(primary); - Version.writeVersion(upgradeVersion, out); - out.writeString(oldestLuceneSegment.toString()); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java deleted file mode 100644 index 265af56d6a772..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.Version; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.PrimaryMissingActionException; -import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction; -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.cluster.ClusterState; -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.routing.IndexRoutingTable; -import org.elasticsearch.cluster.routing.RoutingTable; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.cluster.routing.ShardsIterator; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.collect.Tuple; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.index.shard.IndexShard; -import org.elasticsearch.indices.IndicesService; -import org.elasticsearch.tasks.Task; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; - -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Upgrade index/indices action. - */ -public class TransportUpgradeAction extends TransportBroadcastByNodeAction { - - private final IndicesService indicesService; - private final NodeClient client; - - @Inject - public TransportUpgradeAction(ClusterService clusterService, TransportService transportService, IndicesService indicesService, - ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - NodeClient client) { - super(UpgradeAction.NAME, clusterService, transportService, actionFilters, indexNameExpressionResolver, - UpgradeRequest::new, ThreadPool.Names.FORCE_MERGE); - this.indicesService = indicesService; - this.client = client; - } - - @Override - protected UpgradeResponse newResponse(UpgradeRequest request, int totalShards, int successfulShards, int failedShards, - List shardUpgradeResults, - List shardFailures, ClusterState clusterState) { - Map successfulPrimaryShards = new HashMap<>(); - Map> versions = new HashMap<>(); - for (ShardUpgradeResult result : shardUpgradeResults) { - successfulShards++; - String index = result.getShardId().getIndex().getName(); - if (result.primary()) { - Integer count = successfulPrimaryShards.get(index); - successfulPrimaryShards.put(index, count == null ? 1 : count + 1); - } - Tuple versionTuple = versions.get(index); - if (versionTuple == null) { - versions.put(index, new Tuple<>(result.upgradeVersion(), result.oldestLuceneSegment())); - } else { - // We already have versions for this index - let's see if we need to update them based on the current shard - Version version = versionTuple.v1(); - org.apache.lucene.util.Version luceneVersion = versionTuple.v2(); - // For the metadata we are interested in the _latest_ Elasticsearch version that was processing the metadata - // Since we rewrite the mapping during upgrade the metadata is always rewritten by the latest version - if (result.upgradeVersion().after(versionTuple.v1())) { - version = result.upgradeVersion(); - } - // For the lucene version we are interested in the _oldest_ lucene version since it determines the - // oldest version that we need to support - if (result.oldestLuceneSegment().onOrAfter(versionTuple.v2()) == false) { - luceneVersion = result.oldestLuceneSegment(); - } - versions.put(index, new Tuple<>(version, luceneVersion)); - } - } - Map> updatedVersions = new HashMap<>(); - Metadata metadata = clusterState.metadata(); - for (Map.Entry> versionEntry : versions.entrySet()) { - String index = versionEntry.getKey(); - Integer primaryCount = successfulPrimaryShards.get(index); - int expectedPrimaryCount = metadata.index(index).getNumberOfShards(); - if (primaryCount == metadata.index(index).getNumberOfShards()) { - updatedVersions.put(index, new Tuple<>(versionEntry.getValue().v1(), versionEntry.getValue().v2().toString())); - } else { - logger.warn("Not updating settings for the index [{}] because upgraded of some primary shards failed - " + - "expected[{}], received[{}]", index, expectedPrimaryCount, primaryCount == null ? 0 : primaryCount); - } - } - - return new UpgradeResponse(updatedVersions, totalShards, successfulShards, failedShards, shardFailures); - } - - @Override - protected ShardUpgradeResult shardOperation(UpgradeRequest request, ShardRouting shardRouting) throws IOException { - IndexShard indexShard = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()).getShard(shardRouting.shardId().id()); - org.apache.lucene.util.Version oldestLuceneSegment = indexShard.upgrade(request); - // We are using the current version of Elasticsearch as upgrade version since we update mapping to match the current version - return new ShardUpgradeResult(shardRouting.shardId(), indexShard.routingEntry().primary(), Version.CURRENT, oldestLuceneSegment); - } - - @Override - protected ShardUpgradeResult readShardResult(StreamInput in) throws IOException { - return new ShardUpgradeResult(in); - } - - @Override - protected UpgradeRequest readRequestFrom(StreamInput in) throws IOException { - return new UpgradeRequest(in); - } - - /** - * The upgrade request works against *all* shards. - */ - @Override - protected ShardsIterator shards(ClusterState clusterState, UpgradeRequest request, String[] concreteIndices) { - ShardsIterator iterator = clusterState.routingTable().allShards(concreteIndices); - Set indicesWithMissingPrimaries = indicesWithMissingPrimaries(clusterState, concreteIndices); - if (indicesWithMissingPrimaries.isEmpty()) { - return iterator; - } - // If some primary shards are not available the request should fail. - throw new PrimaryMissingActionException("Cannot upgrade indices because the following indices are missing primary shards " + - indicesWithMissingPrimaries); - } - - /** - * Finds all indices that have not all primaries available - */ - private Set indicesWithMissingPrimaries(ClusterState clusterState, String[] concreteIndices) { - Set indices = new HashSet<>(); - RoutingTable routingTable = clusterState.routingTable(); - for (String index : concreteIndices) { - IndexRoutingTable indexRoutingTable = routingTable.index(index); - if (indexRoutingTable.allPrimaryShardsActive() == false) { - indices.add(index); - } - } - return indices; - } - - @Override - protected ClusterBlockException checkGlobalBlock(ClusterState state, UpgradeRequest request) { - return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); - } - - @Override - protected ClusterBlockException checkRequestBlock(ClusterState state, UpgradeRequest request, String[] concreteIndices) { - return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices); - } - - @Override - protected void doExecute(Task task, UpgradeRequest request, final ActionListener listener) { - super.doExecute(task, request, ActionListener.wrap(upgradeResponse -> { - if (upgradeResponse.versions().isEmpty()) { - listener.onResponse(upgradeResponse); - } else { - updateSettings(upgradeResponse, listener); - } - }, listener::onFailure)); - } - - private void updateSettings(final UpgradeResponse upgradeResponse, final ActionListener listener) { - UpgradeSettingsRequest upgradeSettingsRequest = new UpgradeSettingsRequest(upgradeResponse.versions()); - client.executeLocally(UpgradeSettingsAction.INSTANCE, upgradeSettingsRequest, ActionListener.delegateFailure( - listener, (delegatedListener, updateSettingsResponse) -> delegatedListener.onResponse(upgradeResponse))); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java deleted file mode 100644 index e1bc97c918047..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.message.ParameterizedMessage; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.block.ClusterBlockException; -import org.elasticsearch.cluster.block.ClusterBlockLevel; -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; -import org.elasticsearch.cluster.metadata.MetadataUpdateSettingsService; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.tasks.Task; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; - -public class TransportUpgradeSettingsAction extends AcknowledgedTransportMasterNodeAction { - - private static final Logger logger = LogManager.getLogger(TransportUpgradeSettingsAction.class); - - private final MetadataUpdateSettingsService updateSettingsService; - - @Inject - public TransportUpgradeSettingsAction(TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetadataUpdateSettingsService updateSettingsService, - IndexNameExpressionResolver indexNameExpressionResolver, ActionFilters actionFilters) { - super(UpgradeSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, - UpgradeSettingsRequest::new, indexNameExpressionResolver, ThreadPool.Names.SAME); - this.updateSettingsService = updateSettingsService; - } - - @Override - protected ClusterBlockException checkBlock(UpgradeSettingsRequest request, ClusterState state) { - return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); - } - - @Override - protected void masterOperation(Task task, final UpgradeSettingsRequest request, final ClusterState state, - final ActionListener listener) { - UpgradeSettingsClusterStateUpdateRequest clusterStateUpdateRequest = new UpgradeSettingsClusterStateUpdateRequest() - .ackTimeout(request.timeout()) - .versions(request.versions()) - .masterNodeTimeout(request.masterNodeTimeout()); - - updateSettingsService.upgradeIndexSettings(clusterStateUpdateRequest, new ActionListener<>() { - @Override - public void onResponse(AcknowledgedResponse response) { - listener.onResponse(response); - } - - @Override - public void onFailure(Exception t) { - logger.debug(() -> new ParameterizedMessage("failed to upgrade minimum compatibility version settings on indices [{}]", - request.versions().keySet()), t); - listener.onFailure(t); - } - }); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeAction.java deleted file mode 100644 index 22ce9a3c0cb3b..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeAction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.action.ActionType; - -/** - * Upgrade index/indices action. - */ -public class UpgradeAction extends ActionType { - - public static final UpgradeAction INSTANCE = new UpgradeAction(); - public static final String NAME = "indices:admin/upgrade"; - - private UpgradeAction() { - super(NAME, UpgradeResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequest.java deleted file mode 100644 index 1cb14ca6fd47c..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.action.support.broadcast.BroadcastRequest; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; - -/** - * A request to upgrade one or more indices. In order to update all indices, pass an empty array or - * {@code null} for the indices. - * @see org.elasticsearch.client.Requests#upgradeRequest(String...) - * @see org.elasticsearch.client.IndicesAdminClient#upgrade(UpgradeRequest) - * @see UpgradeResponse - */ -public class UpgradeRequest extends BroadcastRequest { - - public static final class Defaults { - public static final boolean UPGRADE_ONLY_ANCIENT_SEGMENTS = false; - } - - private boolean upgradeOnlyAncientSegments = Defaults.UPGRADE_ONLY_ANCIENT_SEGMENTS; - - /** - * Constructs an optimization request over one or more indices. - * - * @param indices The indices to upgrade, no indices passed means all indices will be optimized. - */ - public UpgradeRequest(String... indices) { - super(indices); - } - - public UpgradeRequest(StreamInput in) throws IOException { - super(in); - upgradeOnlyAncientSegments = in.readBoolean(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeBoolean(upgradeOnlyAncientSegments); - } - - /** - * Should the upgrade only the ancient (older major version of Lucene) segments? - * Defaults to {@code false}. - */ - public boolean upgradeOnlyAncientSegments() { - return upgradeOnlyAncientSegments; - } - - /** - * See {@link #upgradeOnlyAncientSegments()} - */ - public UpgradeRequest upgradeOnlyAncientSegments(boolean upgradeOnlyAncientSegments) { - this.upgradeOnlyAncientSegments = upgradeOnlyAncientSegments; - return this; - } - - @Override - public String toString() { - return "UpgradeRequest{" + - "upgradeOnlyAncientSegments=" + upgradeOnlyAncientSegments + - '}'; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequestBuilder.java deleted file mode 100644 index e2c20a0e508ba..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeRequestBuilder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder; -import org.elasticsearch.client.ElasticsearchClient; - -/** - * A request to upgrade one or more indices. In order to optimize on all the indices, pass an empty array or - * {@code null} for the indices. - */ -public class UpgradeRequestBuilder extends BroadcastOperationRequestBuilder { - - public UpgradeRequestBuilder(ElasticsearchClient client, UpgradeAction action) { - super(client, action, new UpgradeRequest()); - } - - /** - * Should the upgrade only the ancient (older major version of Lucene) segments? - */ - public UpgradeRequestBuilder setUpgradeOnlyAncientSegments(boolean upgradeOnlyAncientSegments) { - request.upgradeOnlyAncientSegments(upgradeOnlyAncientSegments); - return this; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeResponse.java deleted file mode 100644 index 91a34eb9210bb..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeResponse.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.Version; -import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.broadcast.BroadcastResponse; -import org.elasticsearch.common.collect.Tuple; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.XContentBuilder; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * A response for the upgrade action. - * - * - */ -public class UpgradeResponse extends BroadcastResponse { - - private final Map> versions; - - UpgradeResponse(StreamInput in) throws IOException { - super(in); - versions = in.readMap(StreamInput::readString, i -> Tuple.tuple(Version.readVersion(i), i.readString())); - } - - UpgradeResponse(Map> versions, int totalShards, int successfulShards, int failedShards, - List shardFailures) { - super(totalShards, successfulShards, failedShards, shardFailures); - this.versions = versions; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeMap(versions, StreamOutput::writeString, (o, v) -> { - Version.writeVersion(v.v1(), o); - o.writeString(v.v2()); - }); - } - - @Override - protected void addCustomXContentFields(XContentBuilder builder, Params params) throws IOException { - builder.startObject("upgraded_indices"); - for (Map.Entry> entry : versions.entrySet()) { - builder.startObject(entry.getKey()); - builder.field("upgrade_version", entry.getValue().v1()); - builder.field("oldest_lucene_segment_version", entry.getValue().v2()); - builder.endObject(); - } - builder.endObject(); - } - - /** - * Returns the highest upgrade version of the node that performed metadata upgrade and the - * the version of the oldest lucene segment for each index that was upgraded. - */ - public Map> versions() { - return versions; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java deleted file mode 100644 index c965551b8498e..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -public class UpgradeSettingsAction extends ActionType { - - public static final UpgradeSettingsAction INSTANCE = new UpgradeSettingsAction(); - public static final String NAME = "internal:indices/admin/upgrade"; - - private UpgradeSettingsAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsClusterStateUpdateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsClusterStateUpdateRequest.java deleted file mode 100644 index 7df42951d08e7..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsClusterStateUpdateRequest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.Version; -import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest; -import org.elasticsearch.common.collect.Tuple; - -import java.util.Map; - -/** - * Cluster state update request that allows to change minimum compatibility settings for some indices - */ -public class UpgradeSettingsClusterStateUpdateRequest extends ClusterStateUpdateRequest { - - private Map> versions; - - public UpgradeSettingsClusterStateUpdateRequest() { - - } - - /** - * Returns the index to version map for indices that should be updated - */ - public Map> versions() { - return versions; - } - - /** - * Sets the index to version map for indices that should be updated - */ - public UpgradeSettingsClusterStateUpdateRequest versions(Map> versions) { - this.versions = versions; - return this; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequest.java deleted file mode 100644 index 61b06bec9c1d5..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.Version; -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.support.master.AcknowledgedRequest; -import org.elasticsearch.common.collect.Tuple; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; -import java.util.Map; - -import static org.elasticsearch.action.ValidateActions.addValidationError; - -/** - * Request for an update index settings action - */ -public class UpgradeSettingsRequest extends AcknowledgedRequest { - - private Map> versions; - - public UpgradeSettingsRequest(StreamInput in) throws IOException { - super(in); - versions = in.readMap(StreamInput::readString, i -> new Tuple<>(Version.readVersion(i), i.readString())); - } - - public UpgradeSettingsRequest() { - } - - /** - * Constructs a new request to update minimum compatible version settings for one or more indices - * - * @param versions a map from index name to elasticsearch version, oldest lucene segment version tuple - */ - public UpgradeSettingsRequest(Map> versions) { - this.versions = versions; - } - - - @Override - public ActionRequestValidationException validate() { - ActionRequestValidationException validationException = null; - if (versions.isEmpty()) { - validationException = addValidationError("no indices to update", validationException); - } - return validationException; - } - - - Map> versions() { - return versions; - } - - /** - * Sets the index versions to be updated - */ - public UpgradeSettingsRequest versions(Map> versions) { - this.versions = versions; - return this; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeMap(versions, StreamOutput::writeString, (o, v) -> { - Version.writeVersion(v.v1(), out); - out.writeString(v.v2()); - }); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequestBuilder.java deleted file mode 100644 index 853077a67a752..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsRequestBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.action.admin.indices.upgrade.post; - -import org.elasticsearch.Version; -import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder; -import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.client.ElasticsearchClient; -import org.elasticsearch.common.collect.Tuple; - -import java.util.Map; - -/** - * Builder for an update index settings request - */ -public class UpgradeSettingsRequestBuilder - extends AcknowledgedRequestBuilder { - - public UpgradeSettingsRequestBuilder(ElasticsearchClient client, UpgradeSettingsAction action) { - super(client, action, new UpgradeSettingsRequest()); - } - - /** - * Sets the index versions to be updated - */ - public UpgradeSettingsRequestBuilder setVersions(Map> versions) { - request.versions(versions); - return this; - } -} diff --git a/server/src/main/java/org/elasticsearch/client/IndicesAdminClient.java b/server/src/main/java/org/elasticsearch/client/IndicesAdminClient.java index 6b1cfa04ee606..42125eadae088 100644 --- a/server/src/main/java/org/elasticsearch/client/IndicesAdminClient.java +++ b/server/src/main/java/org/elasticsearch/client/IndicesAdminClient.java @@ -96,12 +96,6 @@ import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequestBuilder; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusResponse; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequestBuilder; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequestBuilder; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; @@ -378,52 +372,6 @@ public interface IndicesAdminClient extends ElasticsearchClient { */ ForceMergeRequestBuilder prepareForceMerge(String... indices); - /** - * Explicitly upgrade one or more indices - * - * @param request The upgrade request - * @return A result future - * @see org.elasticsearch.client.Requests#upgradeRequest(String...) - */ - ActionFuture upgrade(UpgradeRequest request); - - /** - * Explicitly upgrade one or more indices - * - * @param request The upgrade request - * @param listener A listener to be notified with a result - * @see org.elasticsearch.client.Requests#upgradeRequest(String...) - */ - void upgrade(UpgradeRequest request, ActionListener listener); - - /** - * Explicitly upgrade one or more indices - */ - UpgradeStatusRequestBuilder prepareUpgradeStatus(String... indices); - - /** - * Check upgrade status of one or more indices - * - * @param request The upgrade request - * @return A result future - * @see org.elasticsearch.client.Requests#upgradeRequest(String...) - */ - ActionFuture upgradeStatus(UpgradeStatusRequest request); - - /** - * Check upgrade status of one or more indices - * - * @param request The upgrade request - * @param listener A listener to be notified with a result - * @see org.elasticsearch.client.Requests#upgradeRequest(String...) - */ - void upgradeStatus(UpgradeStatusRequest request, ActionListener listener); - - /** - * Check upgrade status of one or more indices - */ - UpgradeRequestBuilder prepareUpgrade(String... indices); - /** * Get the complete mappings of one or more types */ diff --git a/server/src/main/java/org/elasticsearch/client/Requests.java b/server/src/main/java/org/elasticsearch/client/Requests.java index 445c1935fad54..3b50c499e9b5c 100644 --- a/server/src/main/java/org/elasticsearch/client/Requests.java +++ b/server/src/main/java/org/elasticsearch/client/Requests.java @@ -54,7 +54,6 @@ import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresRequest; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.get.GetRequest; @@ -258,17 +257,6 @@ public static ForceMergeRequest forceMergeRequest(String... indices) { return new ForceMergeRequest(indices); } - /** - * Creates an upgrade request. - * - * @param indices The indices to upgrade. Use {@code null} or {@code _all} to execute against all indices - * @return The upgrade request - * @see org.elasticsearch.client.IndicesAdminClient#upgrade(UpgradeRequest) - */ - public static UpgradeRequest upgradeRequest(String... indices) { - return new UpgradeRequest(indices); - } - /** * Creates a clean indices cache request. * diff --git a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java index 763e5ec88bbc7..56bcccf01bcc5 100644 --- a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -246,14 +246,6 @@ import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateAction; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusAction; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequestBuilder; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusResponse; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeAction; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequestBuilder; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryAction; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequestBuilder; @@ -1478,36 +1470,6 @@ public ForceMergeRequestBuilder prepareForceMerge(String... indices) { return new ForceMergeRequestBuilder(this, ForceMergeAction.INSTANCE).setIndices(indices); } - @Override - public ActionFuture upgrade(final UpgradeRequest request) { - return execute(UpgradeAction.INSTANCE, request); - } - - @Override - public void upgrade(final UpgradeRequest request, final ActionListener listener) { - execute(UpgradeAction.INSTANCE, request, listener); - } - - @Override - public UpgradeRequestBuilder prepareUpgrade(String... indices) { - return new UpgradeRequestBuilder(this, UpgradeAction.INSTANCE).setIndices(indices); - } - - - @Override - public ActionFuture upgradeStatus(final UpgradeStatusRequest request) { - return execute(UpgradeStatusAction.INSTANCE, request); - } - - @Override - public void upgradeStatus(final UpgradeStatusRequest request, final ActionListener listener) { - execute(UpgradeStatusAction.INSTANCE, request, listener); - } - - @Override - public UpgradeStatusRequestBuilder prepareUpgradeStatus(String... indices) { - return new UpgradeStatusRequestBuilder(this, UpgradeStatusAction.INSTANCE).setIndices(indices); - } @Override public ActionFuture refresh(final RefreshRequest request) { return execute(RefreshAction.INSTANCE, request); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java index f5e4d410168ca..cc0bc6ec9e712 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java @@ -22,10 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.ExceptionsHelper; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsClusterStateUpdateRequest; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeSettingsClusterStateUpdateRequest; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.AckedClusterStateUpdateTask; import org.elasticsearch.cluster.ClusterState; @@ -36,7 +34,6 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Priority; import org.elasticsearch.common.ValidationException; -import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.IndexScopedSettings; @@ -52,7 +49,6 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Locale; -import java.util.Map; import java.util.Optional; import java.util.Set; @@ -316,36 +312,4 @@ private static boolean maybeUpdateClusterBlock(String[] actualIndices, ClusterBl } return changed; } - - - public void upgradeIndexSettings(final UpgradeSettingsClusterStateUpdateRequest request, - final ActionListener listener) { - clusterService.submitStateUpdateTask("update-index-compatibility-versions", - new AckedClusterStateUpdateTask(Priority.URGENT, request, wrapPreservingContext(listener, threadPool.getThreadContext())) { - - @Override - public ClusterState execute(ClusterState currentState) { - Metadata.Builder metadataBuilder = Metadata.builder(currentState.metadata()); - for (Map.Entry> entry : request.versions().entrySet()) { - String index = entry.getKey(); - IndexMetadata indexMetadata = metadataBuilder.get(index); - if (indexMetadata != null) { - if (Version.CURRENT.equals(indexMetadata.getCreationVersion()) == false) { - // no reason to pollute the settings, we didn't really upgrade anything - metadataBuilder.put( - IndexMetadata - .builder(indexMetadata) - .settings( - Settings - .builder() - .put(indexMetadata.getSettings()) - .put(IndexMetadata.SETTING_VERSION_UPGRADED, entry.getValue().v1())) - .settingsVersion(1 + indexMetadata.getSettingsVersion())); - } - } - } - return ClusterState.builder(currentState).metadata(metadataBuilder).build(); - } - }); - } } diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index d2e469012cca3..dfebe7ccf2b6a 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -45,7 +45,6 @@ import org.elasticsearch.action.ActionRunnable; import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest; -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest; import org.elasticsearch.action.support.replication.PendingReplicationActions; import org.elasticsearch.action.support.replication.ReplicationResponse; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -1099,28 +1098,6 @@ public void forceMerge(ForceMergeRequest forceMerge) throws IOException { forceMerge.onlyExpungeDeletes(), false, false, forceMerge.forceMergeUUID()); } - /** - * Upgrades the shard to the current version of Lucene and returns the minimum segment version - */ - public org.apache.lucene.util.Version upgrade(UpgradeRequest upgrade) throws IOException { - verifyActive(); - if (logger.isTraceEnabled()) { - logger.trace("upgrade with {}", upgrade); - } - org.apache.lucene.util.Version previousVersion = minimumCompatibleVersion(); - // we just want to upgrade the segments, not actually forge merge to a single segment - final Engine engine = getEngine(); - engine.forceMerge(true, // we need to flush at the end to make sure the upgrade is durable - Integer.MAX_VALUE, // we just want to upgrade the segments, not actually optimize to a single segment - false, true, upgrade.upgradeOnlyAncientSegments(), null); - org.apache.lucene.util.Version version = minimumCompatibleVersion(); - if (logger.isTraceEnabled()) { - logger.trace("upgraded segments for {} from version {} to version {}", shardId, previousVersion, version); - } - - return version; - } - public org.apache.lucene.util.Version minimumCompatibleVersion() { org.apache.lucene.util.Version luceneVersion = null; for (Segment segment : getEngine().segments(false)) { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java deleted file mode 100644 index bab4e67813132..0000000000000 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.rest.action.admin.indices; - -import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.Strings; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.action.RestToXContentListener; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import static org.elasticsearch.rest.RestRequest.Method.POST; - -public class RestUpgradeActionDeprecated extends BaseRestHandler { - public static final String UPGRADE_API_DEPRECATION_MESSAGE = - "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."; - - @Override - public List deprecatedRoutes() { - return List.of( - new DeprecatedRoute(POST, "/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE), - new DeprecatedRoute(POST, "/{index}/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE)); - } - - @Override - public List routes() { - return Collections.emptyList(); - } - - @Override - public String getName() { - return "upgrade_action"; - } - - @Override - public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { - UpgradeRequest upgradeReq = new UpgradeRequest(Strings.splitStringByCommaToArray(request.param("index"))); - upgradeReq.indicesOptions(IndicesOptions.fromRequest(request, upgradeReq.indicesOptions())); - upgradeReq.upgradeOnlyAncientSegments(request.paramAsBoolean("only_ancient_segments", false)); - return channel -> client.admin().indices().upgrade(upgradeReq, new RestToXContentListener<>(channel)); - } -} diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java deleted file mode 100644 index e1b6eb86278e3..0000000000000 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.rest.action.admin.indices; - -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.Strings; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.action.RestToXContentListener; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import static org.elasticsearch.rest.RestRequest.Method.GET; -import static org.elasticsearch.rest.action.admin.indices.RestUpgradeActionDeprecated.UPGRADE_API_DEPRECATION_MESSAGE; - -public class RestUpgradeStatusActionDeprecated extends BaseRestHandler { - - @Override - public List deprecatedRoutes() { - return List.of( - new DeprecatedRoute(GET, "/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE), - new DeprecatedRoute(GET, "/{index}/_upgrade", UPGRADE_API_DEPRECATION_MESSAGE)); - } - - @Override - public List routes() { - return Collections.emptyList(); - } - - @Override - public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { - UpgradeStatusRequest statusRequest = new UpgradeStatusRequest(Strings.splitStringByCommaToArray(request.param("index"))); - statusRequest.indicesOptions(IndicesOptions.fromRequest(request, statusRequest.indicesOptions())); - return channel -> client.admin().indices().upgradeStatus(statusRequest, new RestToXContentListener<>(channel)); - } - - @Override - public String getName() { - return "upgrade_status_action"; - } -} 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 0fffc364eaead..3e453fa72f7f9 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 @@ -31,7 +31,6 @@ import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateAction; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesAction; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateAction; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusAction; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.get.GetAction; @@ -830,10 +829,6 @@ public void testRemoteMonitoringCollectorRole() { .test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true)); assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndicesShardStoresAction.NAME) .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true)); - assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(UpgradeStatusAction.NAME) - .test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true)); - assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(UpgradeStatusAction.NAME) - .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true)); assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(RecoveryAction.NAME) .test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true)); assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(RecoveryAction.NAME) @@ -884,7 +879,7 @@ private void assertMonitoringOnRestrictedIndices(Role role) { .build(); final FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache(Settings.EMPTY); final List indexMonitoringActionNamesList = Arrays.asList(IndicesStatsAction.NAME, IndicesSegmentsAction.NAME, - GetSettingsAction.NAME, IndicesShardStoresAction.NAME, UpgradeStatusAction.NAME, RecoveryAction.NAME); + GetSettingsAction.NAME, IndicesShardStoresAction.NAME, RecoveryAction.NAME); for (final String indexMonitoringActionName : indexMonitoringActionNamesList) { String asyncSearchIndex = RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2); final Map authzMap = role.indices().authorize(indexMonitoringActionName, diff --git a/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java b/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java index fff268a64ca34..c6eeff31249da 100644 --- a/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java +++ b/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java @@ -554,9 +554,7 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception { verifyResolvability(dataStreamName, client().admin().indices().prepareStats(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().indices().prepareForceMerge(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().indices().prepareValidateQuery(dataStreamName), false); - verifyResolvability(dataStreamName, client().admin().indices().prepareUpgrade(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().indices().prepareRecoveries(dataStreamName), false); - verifyResolvability(dataStreamName, client().admin().indices().prepareUpgradeStatus(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().indices().prepareGetAliases("dummy").addIndices(dataStreamName), true); verifyResolvability(dataStreamName, client().admin().indices().prepareGetFieldMappings(dataStreamName), false); verifyResolvability( @@ -609,9 +607,7 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception { verifyResolvability(wildcardExpression, client().admin().indices().prepareStats(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareForceMerge(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareValidateQuery(wildcardExpression), false); - verifyResolvability(wildcardExpression, client().admin().indices().prepareUpgrade(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareRecoveries(wildcardExpression), false); - verifyResolvability(wildcardExpression, client().admin().indices().prepareUpgradeStatus(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareGetAliases(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareGetFieldMappings(wildcardExpression), false); verifyResolvability( diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java index 230fad1c73128..add4192814c8f 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java @@ -12,7 +12,6 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusResponse; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.MultiSearchResponse; import org.elasticsearch.action.search.SearchResponse; @@ -210,11 +209,6 @@ public void testMonitorRestrictedWildcards() throws Exception { assertThat(indicesShardsStoresResponse.getStoreStatuses().containsKey("foobar"), is(true)); assertThat(indicesShardsStoresResponse.getStoreStatuses().containsKey("foobarfoo"), is(true)); - final UpgradeStatusResponse upgradeStatusResponse = client.admin().indices().prepareUpgradeStatus(randomFrom("*", "_all", "foo*")) - .get(); - assertThat(upgradeStatusResponse.getIndices().size(), is(3)); - assertThat(upgradeStatusResponse.getIndices().keySet(), containsInAnyOrder("foo", "foobar", "foobarfoo")); - final IndicesStatsResponse indicesStatsResponse = client.admin().indices().prepareStats(randomFrom("*", "_all", "foo*")).get(); assertThat(indicesStatsResponse.getIndices().size(), is(3)); assertThat(indicesStatsResponse.getIndices().keySet(), containsInAnyOrder("foo", "foobar", "foobarfoo")); 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 61601c054c688..fa1edf32e7d85 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 @@ -36,8 +36,6 @@ import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusAction; -import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkItemRequest; import org.elasticsearch.action.bulk.BulkRequest; @@ -1147,8 +1145,6 @@ public void testGrantAllRestrictedUserCannotExecuteOperationAgainstSecurityIndic new GetSettingsRequest().indices(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)))); requests.add(new Tuple<>(IndicesShardStoresAction.NAME, new IndicesShardStoresRequest().indices(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)))); - requests.add(new Tuple<>(UpgradeStatusAction.NAME, - new UpgradeStatusRequest().indices(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)))); for (Tuple requestTuple : requests) { String action = requestTuple.v1(); @@ -1204,7 +1200,6 @@ public void testMonitoringOperationsAgainstSecurityIndexRequireAllowRestricted() requests.add(new Tuple<>(IndicesSegmentsAction.NAME, new IndicesSegmentsRequest().indices(SECURITY_MAIN_ALIAS))); requests.add(new Tuple<>(GetSettingsAction.NAME, new GetSettingsRequest().indices(SECURITY_MAIN_ALIAS))); requests.add(new Tuple<>(IndicesShardStoresAction.NAME, new IndicesShardStoresRequest().indices(SECURITY_MAIN_ALIAS))); - requests.add(new Tuple<>(UpgradeStatusAction.NAME, new UpgradeStatusRequest().indices(SECURITY_MAIN_ALIAS))); for (final Tuple requestTuple : requests) { final String action = requestTuple.v1(); From 95196e5360bd8451d9cde5c72f78579ed7bc92dc Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Fri, 6 Nov 2020 11:14:19 -0600 Subject: [PATCH 2/4] add to breaking changes doc --- .../migration/migrate_8_0/indices.asciidoc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/reference/migration/migrate_8_0/indices.asciidoc b/docs/reference/migration/migrate_8_0/indices.asciidoc index bc102ac220741..d13b5023ab313 100644 --- a/docs/reference/migration/migrate_8_0/indices.asciidoc +++ b/docs/reference/migration/migrate_8_0/indices.asciidoc @@ -8,6 +8,17 @@ //tag::notable-breaking-changes[] //end::notable-breaking-changes[] +.The deprecated `_upgrade` API has been removed. +[%collapsible] +==== +*Details* + +Previously, the `_upgrade` API upgraded indices from the previous major +version to the current version. The `_reindex` API should be used +instead for that purpose. + +*Impact* + +Requests made to the old `_upgrade` API will return an error. +==== .The force merge API's `max_num_segments` and `only_expunge_deletes` parameters cannot both be specified in the same request. [%collapsible] @@ -70,7 +81,7 @@ Use the {ref}/indices-flush.html[flush API]. Requests to the *Details* + Creating indices with soft deletes disabled was deprecated in 7.6 and is no longer supported in 8.0. The `index.soft_deletes.enabled` setting -can no longer be set to `false`. +can no longer be set to `false`. *Impact* + Discontinue use of the `index.soft_deletes.enabled` index setting. Requests that From cb3ce4bb2ff44ace8567ed248d1e72679aa337ad Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Fri, 6 Nov 2020 11:15:35 -0600 Subject: [PATCH 3/4] remove references from REST client tests --- .../java/org/elasticsearch/client/RestHighLevelClientTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index a1a30859c4cd1..253e67dfe8f8f 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -812,7 +812,6 @@ public void testApiNamingConventions() throws Exception { "get_script_context", "get_script_languages", "indices.exists_type", - "indices.get_upgrade", "indices.put_alias", "render_search_template", "scripts_painless_execute", @@ -833,7 +832,6 @@ public void testApiNamingConventions() throws Exception { "dangling_indices.import_dangling_index", "dangling_indices.list_dangling_indices", "indices.shard_stores", - "indices.upgrade", "indices.recovery", "indices.segments", "indices.stats", From e658bcdf183f7787d200c74b798c7bc5d248b757 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Fri, 6 Nov 2020 11:55:39 -0600 Subject: [PATCH 4/4] remove ref from index privilege tests --- .../org/elasticsearch/integration/IndexPrivilegeIntegTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java index d45a6b5f74b9f..a19e71fce39fa 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java @@ -459,7 +459,6 @@ private void assertUserExecutes(String user, String action, String index, boolea assertAccessIsAllowed(user, "GET", "/" + index + "/_analyze", "{ \"text\" : \"test\" }"); assertAccessIsAllowed(user, "POST", "/" + index + "/_flush"); assertAccessIsAllowed(user, "POST", "/" + index + "/_forcemerge"); - assertAccessIsAllowed(user, "POST", "/" + index + "/_upgrade", null); assertAccessIsAllowed(user, "POST", "/" + index + "/_close"); assertAccessIsAllowed(user, "POST", "/" + index + "/_open"); assertAccessIsAllowed(user, "POST", "/" + index + "/_cache/clear"); @@ -475,7 +474,6 @@ private void assertUserExecutes(String user, String action, String index, boolea assertAccessIsDenied(user, "GET", "/" + index + "/_analyze", "{ \"text\" : \"test\" }"); assertAccessIsDenied(user, "POST", "/" + index + "/_flush"); assertAccessIsDenied(user, "POST", "/" + index + "/_forcemerge"); - assertAccessIsDenied(user, "POST", "/" + index + "/_upgrade", null); assertAccessIsDenied(user, "POST", "/" + index + "/_close"); assertAccessIsDenied(user, "POST", "/" + index + "/_open"); assertAccessIsDenied(user, "POST", "/" + index + "/_cache/clear");