Skip to content

Commit

Permalink
Remove state update of singleIndexWithSegmentReplicationDisabled (ope…
Browse files Browse the repository at this point in the history
…nsearch-project#6526)

Signed-off-by: Rishikesh1159 <[email protected]>
  • Loading branch information
Rishikesh1159 authored Mar 2, 2023
1 parent 7b96c92 commit ee305d0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -52,7 +50,6 @@ public class TransportSegmentReplicationStatsAction extends TransportBroadcastBy

private final SegmentReplicationTargetService targetService;
private final IndicesService indicesService;
private String singleIndexWithSegmentReplicationDisabled = null;

@Inject
public TransportSegmentReplicationStatsAction(
Expand Down Expand Up @@ -91,12 +88,6 @@ protected SegmentReplicationStatsResponse newResponse(
List<DefaultShardOperationFailedException> 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<String> set = new HashSet<>();
if (shards.length > 0) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ee305d0

Please sign in to comment.