From 872f742886fcd06ba7b8afa9f34c07469690dfca Mon Sep 17 00:00:00 2001 From: Shubh Sahu Date: Mon, 1 Apr 2024 15:43:10 +0530 Subject: [PATCH] code refactoring and spotless checks Signed-off-by: Shubh Sahu --- .../remotemigration/ResizeIndexMigrationTestCase.java | 2 -- .../action/admin/indices/shrink/TransportResizeAction.java | 5 +++-- .../admin/indices/shrink/TransportResizeActionTests.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java b/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java index b84d546d5d4f9..90e570a7367ae 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java @@ -14,7 +14,6 @@ import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.indices.replication.common.ReplicationType; -import org.opensearch.node.remotestore.RemoteStoreNodeService; import org.opensearch.test.OpenSearchIntegTestCase; import java.util.List; @@ -137,7 +136,6 @@ public void testFailResizeIndexWhileRemoteStoreToDocRepMigration() throws Except addRemote = false; String nonRemoteNodeName = internalCluster().startNode(); - logger.info("-->Create index on remote node and SETTING_REMOTE_STORE_ENABLED is true. Resize should not happen"); Settings.Builder builder = Settings.builder().put(SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT); client.admin() diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java index 5139e6a5c21b6..4faeceac4df8a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java @@ -382,10 +382,11 @@ private static void validateClusterModeSettings( if (clusterSettings.get(RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING) .equals(RemoteStoreNodeService.CompatibilityMode.MIXED)) { boolean isRemoteStoreEnabled = sourceIndexMetadata.getSettings().getAsBoolean(SETTING_REMOTE_STORE_ENABLED, false); - if ((clusterSettings.get(RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING).equals(RemoteStoreNodeService.Direction.REMOTE_STORE) + if ((clusterSettings.get(RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING) + .equals(RemoteStoreNodeService.Direction.REMOTE_STORE) && isRemoteStoreEnabled == false) || (clusterSettings.get(RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING).equals(RemoteStoreNodeService.Direction.DOCREP) - && isRemoteStoreEnabled == true)) { + && isRemoteStoreEnabled == true)) { throw new IllegalStateException( "index Resizing for type [" + type diff --git a/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java index fbec551317c47..90ceace5c999a 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java @@ -667,7 +667,7 @@ public void testResizeFailuresDuringMigration() { if (compatibilityMode == CompatibilityMode.MIXED) { if ((migrationDirection == RemoteStoreNodeService.Direction.REMOTE_STORE && isRemoteStoreEnabled == false) - || migrationDirection == RemoteStoreNodeService.Direction.DOCREP && isRemoteStoreEnabled == true ){ + || migrationDirection == RemoteStoreNodeService.Direction.DOCREP && isRemoteStoreEnabled == true) { ClusterState finalState = clusterState; IllegalStateException ise = expectThrows( IllegalStateException.class,