1818import org .elasticsearch .cluster .routing .RecoverySource .PeerRecoverySource ;
1919import org .elasticsearch .cluster .routing .RecoverySource .SnapshotRecoverySource ;
2020import org .elasticsearch .common .Randomness ;
21- import org .elasticsearch .common .collect .ImmutableOpenIntMap ;
2221import org .elasticsearch .common .io .stream .StreamInput ;
2322import org .elasticsearch .common .io .stream .StreamOutput ;
2423import org .elasticsearch .common .util .CollectionUtils ;
2928import java .io .IOException ;
3029import java .util .ArrayList ;
3130import java .util .Arrays ;
31+ import java .util .HashMap ;
3232import java .util .HashSet ;
3333import java .util .List ;
3434import java .util .Map ;
@@ -66,7 +66,7 @@ public class IndexRoutingTable implements SimpleDiffable<IndexRoutingTable> {
6666
6767 private final List <ShardRouting > allActiveShards ;
6868
69- IndexRoutingTable (Index index , ImmutableOpenIntMap < IndexShardRoutingTable > shards ) {
69+ IndexRoutingTable (Index index , Map < Integer , IndexShardRoutingTable > shards ) {
7070 this .index = index ;
7171 this .shuffler = new RotationShardShuffler (Randomness .get ().nextInt ());
7272 this .shards = new IndexShardRoutingTable [shards .size ()];
@@ -328,7 +328,7 @@ public static Builder builder(Index index) {
328328 public static class Builder {
329329
330330 private final Index index ;
331- private final ImmutableOpenIntMap . Builder < IndexShardRoutingTable > shards = ImmutableOpenIntMap . builder ();
331+ private final Map < Integer , IndexShardRoutingTable > shards = new HashMap <> ();
332332
333333 public Builder (Index index ) {
334334 this .index = index ;
@@ -487,7 +487,7 @@ private Builder initializeEmpty(IndexMetadata indexMetadata, UnassignedInfo unas
487487 }
488488
489489 public Builder addReplica () {
490- for (var shardNumber : shards .keys ()) {
490+ for (var shardNumber : shards .keySet ()) {
491491 ShardId shardId = new ShardId (index , shardNumber );
492492 // version 0, will get updated when reroute will happen
493493 ShardRouting shard = ShardRouting .newUnassigned (
@@ -502,7 +502,7 @@ public Builder addReplica() {
502502 }
503503
504504 public Builder removeReplica () {
505- for (var shardId : shards .keys ()) {
505+ for (var shardId : shards .keySet ()) {
506506 IndexShardRoutingTable indexShard = shards .get (shardId );
507507 if (indexShard .replicaShards ().isEmpty ()) {
508508 // nothing to do here!
@@ -557,7 +557,7 @@ public Builder addShard(ShardRouting shard) {
557557 }
558558
559559 public IndexRoutingTable build () {
560- return new IndexRoutingTable (index , shards . build () );
560+ return new IndexRoutingTable (index , shards );
561561 }
562562 }
563563
0 commit comments