Skip to content

Commit

Permalink
Merge pull request elastic#13246 from brwe/read-post-recovery
Browse files Browse the repository at this point in the history
Allow reads on shards that are in POST_RECOVERY
  • Loading branch information
brwe committed Sep 2, 2015
2 parents 2a129f1 + 89ac6a8 commit 9f49e0e
Show file tree
Hide file tree
Showing 2 changed files with 297 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
import java.io.PrintStream;
import java.nio.channels.ClosedByInterruptException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -191,6 +192,8 @@ public class IndexShard extends AbstractIndexShardComponent {

private final IndexShardOperationCounter indexShardOperationCounter;

private EnumSet<IndexShardState> readAllowedStates = EnumSet.of(IndexShardState.STARTED, IndexShardState.RELOCATED, IndexShardState.POST_RECOVERY);

@Inject
public IndexShard(ShardId shardId, IndexSettingsService indexSettingsService, IndicesLifecycle indicesLifecycle, Store store, StoreRecoveryService storeRecoveryService,
ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache, IndexAliasesService indexAliasesService,
Expand Down Expand Up @@ -953,8 +956,8 @@ public boolean ignoreRecoveryAttempt() {

public void readAllowed() throws IllegalIndexShardStateException {
IndexShardState state = this.state; // one time volatile read
if (state != IndexShardState.STARTED && state != IndexShardState.RELOCATED) {
throw new IllegalIndexShardStateException(shardId, state, "operations only allowed when started/relocated");
if (readAllowedStates.contains(state) == false) {
throw new IllegalIndexShardStateException(shardId, state, "operations only allowed when shard state is one of " + readAllowedStates.toString());
}
}

Expand Down
Loading

0 comments on commit 9f49e0e

Please sign in to comment.