From 0f5640198ce64bece62fd3f8fb48a3e07c31f2e5 Mon Sep 17 00:00:00 2001 From: Rishikesh1159 Date: Fri, 2 Dec 2022 16:10:30 +0000 Subject: [PATCH] Apply spotless check. Signed-off-by: Rishikesh1159 --- .../indices/replication/SegmentReplicationIT.java | 13 ++++++------- .../indices/cluster/IndicesClusterStateService.java | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java index d2f1238d060a2..e112d87807040 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java @@ -24,7 +24,6 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.routing.IndexShardRoutingTable; import org.opensearch.cluster.routing.ShardRouting; -import org.opensearch.cluster.routing.ShardRoutingState; import org.opensearch.cluster.routing.allocation.command.CancelAllocationCommand; import org.opensearch.common.Nullable; import org.opensearch.common.Priority; @@ -73,7 +72,7 @@ public class SegmentReplicationIT extends OpenSearchIntegTestCase { @BeforeClass public static void assumeFeatureFlag() { - assumeTrue("Segment replication Feature flag is enabled", true); + assumeTrue("Segment replication Feature flag is enabled", Boolean.parseBoolean(System.getProperty(FeatureFlags.REPLICATION_TYPE))); } @Override @@ -208,7 +207,10 @@ public void testAddNewReplicaFailure() throws Exception { final String primary = internalCluster().startNode(); logger.info("--> creating test index ..."); - prepareCreate(INDEX_NAME, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)).get(); + prepareCreate( + INDEX_NAME, + Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) + ).get(); logger.info("--> index 10 docs"); for (int i = 0; i < 10; i++) { @@ -229,10 +231,7 @@ public void testAddNewReplicaFailure() throws Exception { final String replica = internalCluster().startNode(); // Mock transport service to add behaviour of throwing corruption exception during segment replication process. - MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance( - TransportService.class, - primary - )); + MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, primary)); mockTransportService.addSendBehavior( internalCluster().getInstance(TransportService.class, replica), (connection, requestId, action, request, options) -> { diff --git a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java index b5587400ff9cf..555e84dda025f 100644 --- a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java +++ b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java @@ -785,7 +785,8 @@ public void handleRecoveryDone(ReplicationState state, ShardRouting shardRouting IndexShard indexShard = (IndexShard) indexService.getShardOrNull(shardRouting.id()); // For Segment Replication enabled indices, we want replica shards to start a replication event to fetch latest segments before it // is marked as Started. - if (indexShard != null && indexShard.indexSettings().isSegRepEnabled() + if (indexShard != null + && indexShard.indexSettings().isSegRepEnabled() && shardRouting.primary() == false && shardRouting.state() == ShardRoutingState.INITIALIZING && indexShard.state() == IndexShardState.POST_RECOVERY) {