From 2e3fbfd88bc712b2e9322d9b7813085f9dbcaf1e Mon Sep 17 00:00:00 2001 From: Sachin Kale Date: Tue, 24 Oct 2023 13:22:55 +0530 Subject: [PATCH] Change to forceAllocate Signed-off-by: Sachin Kale --- .../remotestore/RemoteStoreRestoreIT.java | 10 +++---- .../restore/RestoreRemoteStoreRequest.java | 28 +++++++++---------- .../cluster/routing/RecoverySource.java | 22 +++++++-------- .../recovery/RemoteStoreRestoreService.java | 10 +++---- .../opensearch/index/shard/StoreRecovery.java | 2 +- .../cluster/RestRestoreRemoteStoreAction.java | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java index cbe7f3406998c..e202b9f6d34a7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java @@ -38,7 +38,7 @@ import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.greaterThan; -@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE, numDataNodes = 0) +@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0) public class RemoteStoreRestoreIT extends BaseRemoteStoreRestoreIT { /** @@ -236,7 +236,7 @@ public void testRestoreFlowNoRedIndex() throws Exception { verifyRestoredData(indexStats, INDEX_NAME); } - public void testRestoreFlowWithForceEmptyTranslogNoOp() throws Exception { + public void testRestoreFlowWithForceAllocateNoOp() throws Exception { prepareCluster(1, 3, INDEX_NAME, 0, 1); Map indexStats = indexData(randomIntBetween(2, 3), randomBoolean(), INDEX_NAME); @@ -252,7 +252,7 @@ public void testRestoreFlowWithForceEmptyTranslogNoOp() throws Exception { client().admin() .cluster() .restoreRemoteStore( - new RestoreRemoteStoreRequest().indices(INDEX_NAME).restoreAllShards(true).forceEmptyTranslog(true), + new RestoreRemoteStoreRequest().indices(INDEX_NAME).restoreAllShards(true).forceAllocate(true), PlainActionFuture.newFuture() ); ensureGreen(INDEX_NAME); @@ -267,7 +267,7 @@ public void testRestoreFlowWithForceEmptyTranslogNoOp() throws Exception { ); } - public void testRestoreFlowWithForceEmptyTranslog() throws Exception { + public void testRestoreFlowWithForceAllocate() throws Exception { prepareCluster(1, 3, INDEX_NAME, 0, 1); Map indexStats = indexData(randomIntBetween(2, 3), randomBoolean(), INDEX_NAME); @@ -292,7 +292,7 @@ public void testRestoreFlowWithForceEmptyTranslog() throws Exception { client().admin() .cluster() .restoreRemoteStore( - new RestoreRemoteStoreRequest().indices(INDEX_NAME).restoreAllShards(true).forceEmptyTranslog(true), + new RestoreRemoteStoreRequest().indices(INDEX_NAME).restoreAllShards(true).forceAllocate(true), PlainActionFuture.newFuture() ); ensureGreen(INDEX_NAME); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java index 60928d641c2ab..c3e8834941e1c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java @@ -38,7 +38,7 @@ public class RestoreRemoteStoreRequest extends ClusterManagerNodeRequest> indexMetadataMap = new HashMap<>(); @@ -183,7 +183,7 @@ public RemoteRestoreResult restore( } } } - return executeRestore(currentState, indexMetadataMap, restoreAllShards, remoteMetadata, forceEmptyTranslog); + return executeRestore(currentState, indexMetadataMap, restoreAllShards, remoteMetadata, forceAllocate); } /** @@ -198,7 +198,7 @@ private RemoteRestoreResult executeRestore( Map> indexMetadataMap, boolean restoreAllShards, Metadata remoteMetadata, - boolean forceEmptyTranslog + boolean forceAllocate ) { final String restoreUUID = UUIDs.randomBase64UUID(); List indicesToBeRestored = new ArrayList<>(); @@ -237,7 +237,7 @@ private RemoteRestoreResult executeRestore( restoreUUID, updatedIndexMetadata.getCreationVersion(), indexId, - forceEmptyTranslog + forceAllocate ); rtBuilder.addAsRemoteStoreRestore(updatedIndexMetadata, recoverySource, indexShardRoutingTableMap, restoreAllShards); diff --git a/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java b/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java index 7d0cbaf9986fa..71d12514969ae 100644 --- a/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java +++ b/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java @@ -554,7 +554,7 @@ private void recoverFromRemoteStore(IndexShard indexShard) throws IndexShardReco store.createEmpty(indexShard.indexSettings().getIndexVersionCreated().luceneVersion, translogHeader.getTranslogUUID()); } } else if (remoteSegmentEmpty == false && remoteTranslogEmpty) { - if (((RecoverySource.RemoteStoreRecoverySource) indexShard.shardRouting.recoverySource()).forceEmptyTranslog()) { + if (((RecoverySource.RemoteStoreRecoverySource) indexShard.shardRouting.recoverySource()).forceAllocate()) { bootstrapFromLastCommit(indexShard, store); } } diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestRestoreRemoteStoreAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestRestoreRemoteStoreAction.java index 73dfa4ba0a656..5bd0d8dfba663 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestRestoreRemoteStoreAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestRestoreRemoteStoreAction.java @@ -45,7 +45,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC ); restoreRemoteStoreRequest.waitForCompletion(request.paramAsBoolean("wait_for_completion", false)); restoreRemoteStoreRequest.restoreAllShards(request.paramAsBoolean("restore_all_shards", false)); - restoreRemoteStoreRequest.forceEmptyTranslog(request.paramAsBoolean("force_empty_translog", false)); + restoreRemoteStoreRequest.forceAllocate(request.paramAsBoolean("force_allocate", false)); request.applyContentParser(p -> restoreRemoteStoreRequest.source(p.mapOrdered())); return channel -> client.admin().cluster().restoreRemoteStore(restoreRemoteStoreRequest, new RestToXContentListener<>(channel)); }