18
18
import org .elasticsearch .cluster .routing .RecoverySource .PeerRecoverySource ;
19
19
import org .elasticsearch .cluster .routing .RecoverySource .SnapshotRecoverySource ;
20
20
import org .elasticsearch .common .Randomness ;
21
- import org .elasticsearch .common .collect .ImmutableOpenIntMap ;
22
21
import org .elasticsearch .common .io .stream .StreamInput ;
23
22
import org .elasticsearch .common .io .stream .StreamOutput ;
24
23
import org .elasticsearch .common .util .CollectionUtils ;
29
28
import java .io .IOException ;
30
29
import java .util .ArrayList ;
31
30
import java .util .Arrays ;
31
+ import java .util .HashMap ;
32
32
import java .util .HashSet ;
33
33
import java .util .List ;
34
34
import java .util .Map ;
@@ -66,7 +66,7 @@ public class IndexRoutingTable implements SimpleDiffable<IndexRoutingTable> {
66
66
67
67
private final List <ShardRouting > allActiveShards ;
68
68
69
- IndexRoutingTable (Index index , ImmutableOpenIntMap < IndexShardRoutingTable > shards ) {
69
+ IndexRoutingTable (Index index , Map < Integer , IndexShardRoutingTable > shards ) {
70
70
this .index = index ;
71
71
this .shuffler = new RotationShardShuffler (Randomness .get ().nextInt ());
72
72
this .shards = new IndexShardRoutingTable [shards .size ()];
@@ -328,7 +328,7 @@ public static Builder builder(Index index) {
328
328
public static class Builder {
329
329
330
330
private final Index index ;
331
- private final ImmutableOpenIntMap . Builder < IndexShardRoutingTable > shards = ImmutableOpenIntMap . builder ();
331
+ private final Map < Integer , IndexShardRoutingTable > shards = new HashMap <> ();
332
332
333
333
public Builder (Index index ) {
334
334
this .index = index ;
@@ -487,7 +487,7 @@ private Builder initializeEmpty(IndexMetadata indexMetadata, UnassignedInfo unas
487
487
}
488
488
489
489
public Builder addReplica () {
490
- for (var shardNumber : shards .keys ()) {
490
+ for (var shardNumber : shards .keySet ()) {
491
491
ShardId shardId = new ShardId (index , shardNumber );
492
492
// version 0, will get updated when reroute will happen
493
493
ShardRouting shard = ShardRouting .newUnassigned (
@@ -502,7 +502,7 @@ public Builder addReplica() {
502
502
}
503
503
504
504
public Builder removeReplica () {
505
- for (var shardId : shards .keys ()) {
505
+ for (var shardId : shards .keySet ()) {
506
506
IndexShardRoutingTable indexShard = shards .get (shardId );
507
507
if (indexShard .replicaShards ().isEmpty ()) {
508
508
// nothing to do here!
@@ -557,7 +557,7 @@ public Builder addShard(ShardRouting shard) {
557
557
}
558
558
559
559
public IndexRoutingTable build () {
560
- return new IndexRoutingTable (index , shards . build () );
560
+ return new IndexRoutingTable (index , shards );
561
561
}
562
562
}
563
563
0 commit comments