Skip to content
Merged
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 @@ -18,7 +18,6 @@
import org.elasticsearch.cluster.routing.RecoverySource.PeerRecoverySource;
import org.elasticsearch.cluster.routing.RecoverySource.SnapshotRecoverySource;
import org.elasticsearch.common.Randomness;
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.util.CollectionUtils;
Expand All @@ -29,6 +28,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -66,7 +66,7 @@ public class IndexRoutingTable implements SimpleDiffable<IndexRoutingTable> {

private final List<ShardRouting> allActiveShards;

IndexRoutingTable(Index index, ImmutableOpenIntMap<IndexShardRoutingTable> shards) {
IndexRoutingTable(Index index, Map<Integer, IndexShardRoutingTable> shards) {
this.index = index;
this.shuffler = new RotationShardShuffler(Randomness.get().nextInt());
this.shards = new IndexShardRoutingTable[shards.size()];
Expand Down Expand Up @@ -328,7 +328,7 @@ public static Builder builder(Index index) {
public static class Builder {

private final Index index;
private final ImmutableOpenIntMap.Builder<IndexShardRoutingTable> shards = ImmutableOpenIntMap.builder();
private final Map<Integer, IndexShardRoutingTable> shards = new HashMap<>();

public Builder(Index index) {
this.index = index;
Expand Down Expand Up @@ -487,7 +487,7 @@ private Builder initializeEmpty(IndexMetadata indexMetadata, UnassignedInfo unas
}

public Builder addReplica() {
for (var shardNumber : shards.keys()) {
for (var shardNumber : shards.keySet()) {
ShardId shardId = new ShardId(index, shardNumber);
// version 0, will get updated when reroute will happen
ShardRouting shard = ShardRouting.newUnassigned(
Expand All @@ -502,7 +502,7 @@ public Builder addReplica() {
}

public Builder removeReplica() {
for (var shardId : shards.keys()) {
for (var shardId : shards.keySet()) {
IndexShardRoutingTable indexShard = shards.get(shardId);
if (indexShard.replicaShards().isEmpty()) {
// nothing to do here!
Expand Down Expand Up @@ -557,7 +557,7 @@ public Builder addShard(ShardRouting shard) {
}

public IndexRoutingTable build() {
return new IndexRoutingTable(index, shards.build());
return new IndexRoutingTable(index, shards);
}
}

Expand Down