From ee305d0b95e00e66dd20ab0a4ce6687df6cf8875 Mon Sep 17 00:00:00 2001 From: Rishikesh Pasham <62345295+Rishikesh1159@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:44:06 -0800 Subject: [PATCH] Remove state update of singleIndexWithSegmentReplicationDisabled (#6526) Signed-off-by: Rishikesh1159 --- .../SegmentReplicationStatsIT.java | 27 ------------------- ...ransportSegmentReplicationStatsAction.java | 14 ---------- 2 files changed, 41 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationStatsIT.java index 6969f28a784d9..b527347c786d5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationStatsIT.java @@ -8,7 +8,6 @@ package org.opensearch.indices.replication; -import org.opensearch.OpenSearchStatusException; import org.opensearch.action.admin.indices.replication.SegmentReplicationStatsResponse; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; @@ -144,30 +143,4 @@ public void testSegmentReplicationStatsResponseForActiveAndCompletedOnly() throw waitForAssertions.countDown(); } - public void testSegmentReplicationStatsResponseOnDocumentReplicationIndex() { - final String primaryNode = internalCluster().startNode(); - prepareCreate( - INDEX_NAME, - Settings.builder().put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.DOCUMENT) - - ).get(); - ensureYellowAndNoInitializingShards(INDEX_NAME); - final String replicaNode = internalCluster().startNode(); - ensureGreen(INDEX_NAME); - - // index 10 docs - for (int i = 0; i < 10; i++) { - client().prepareIndex(INDEX_NAME).setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet(); - } - refresh(INDEX_NAME); - OpenSearchStatusException exception = assertThrows( - OpenSearchStatusException.class, - () -> client().admin().indices().prepareSegmentReplicationStats(INDEX_NAME).execute().actionGet() - ); - // Verify exception message - String expectedMessage = "Segment Replication is not enabled on Index: test-idx-1"; - assertEquals(expectedMessage, exception.getMessage()); - - } - } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java index b216824f420cc..67849002ab811 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java @@ -8,7 +8,6 @@ package org.opensearch.action.admin.indices.replication; -import org.opensearch.OpenSearchStatusException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.DefaultShardOperationFailedException; import org.opensearch.action.support.broadcast.node.TransportBroadcastByNodeAction; @@ -27,7 +26,6 @@ import org.opensearch.indices.IndicesService; import org.opensearch.indices.replication.SegmentReplicationState; import org.opensearch.indices.replication.SegmentReplicationTargetService; -import org.opensearch.rest.RestStatus; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -52,7 +50,6 @@ public class TransportSegmentReplicationStatsAction extends TransportBroadcastBy private final SegmentReplicationTargetService targetService; private final IndicesService indicesService; - private String singleIndexWithSegmentReplicationDisabled = null; @Inject public TransportSegmentReplicationStatsAction( @@ -91,12 +88,6 @@ protected SegmentReplicationStatsResponse newResponse( List shardFailures, ClusterState clusterState ) { - // throw exception if API call is made on single index with segment replication disabled. - if (singleIndexWithSegmentReplicationDisabled != null) { - String index = singleIndexWithSegmentReplicationDisabled; - singleIndexWithSegmentReplicationDisabled = null; - throw new OpenSearchStatusException("Segment Replication is not enabled on Index: " + index, RestStatus.BAD_REQUEST); - } String[] shards = request.shards(); Set set = new HashSet<>(); if (shards.length > 0) { @@ -135,11 +126,6 @@ protected SegmentReplicationState shardOperation(SegmentReplicationStatsRequest IndexShard indexShard = indexService.getShard(shardRouting.shardId().id()); ShardId shardId = shardRouting.shardId(); - // check if API call is made on single index with segment replication disabled. - if (request.indices().length == 1 && indexShard.indexSettings().isSegRepEnabled() == false) { - singleIndexWithSegmentReplicationDisabled = shardRouting.getIndexName(); - return null; - } if (indexShard.indexSettings().isSegRepEnabled() == false || shardRouting.primary()) { return null; }