Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ protected void shardOperationOnReplica(ShardRequest shardRequest, IndexShard rep
}

private void executeShardOperation(final ShardRequest request, final IndexShard indexShard) throws IOException {
if (indexShard.routingEntry().isPromotableToPrimary() == false) {
return;
}

final ShardId shardId = indexShard.shardId();
if (indexShard.getActiveOperationsCount() != IndexShard.OPERATIONS_BLOCKED) {
throw new IllegalStateException("Index shard " + shardId + " is not blocking all operations during closing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.TestShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue;
Expand Down Expand Up @@ -94,6 +95,9 @@ public void setUp() throws Exception {

final ShardId shardId = new ShardId("index", "_na_", randomIntBetween(0, 3));
when(indexShard.shardId()).thenReturn(shardId);
when(indexShard.routingEntry()).thenReturn(
TestShardRouting.newShardRouting(shardId, randomAlphaOfLength(5), true, ShardRoutingState.STARTED)
);

clusterService = createClusterService(threadPool);

Expand Down