Skip to content

Commit eea791d

Browse files
author
Yannick Welsch
committed
Remove superfluous method numPrimaries
1 parent e855282 commit eea791d

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

core/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,6 @@ public boolean containsShard(ShardRouting shard) {
892892
static final class ModelIndex {
893893
private final String id;
894894
private final Map<ShardRouting, Decision> shards = new HashMap<>();
895-
private int numPrimaries = -1;
896895
private int highestPrimary = -1;
897896

898897
public ModelIndex(String id) {
@@ -924,26 +923,13 @@ public Collection<ShardRouting> getAllShards() {
924923
return shards.keySet();
925924
}
926925

927-
public int numPrimaries() {
928-
if (numPrimaries == -1) {
929-
int num = 0;
930-
for (ShardRouting shard : shards.keySet()) {
931-
if (shard.primary()) {
932-
num++;
933-
}
934-
}
935-
return numPrimaries = num;
936-
}
937-
return numPrimaries;
938-
}
939-
940926
public Decision removeShard(ShardRouting shard) {
941-
highestPrimary = numPrimaries = -1;
927+
highestPrimary = -1;
942928
return shards.remove(shard);
943929
}
944930

945931
public void addShard(ShardRouting shard, Decision decision) {
946-
highestPrimary = numPrimaries = -1;
932+
highestPrimary = -1;
947933
assert decision != null;
948934
assert !shards.containsKey(shard) : "Shard already allocated on current node: " + shards.get(shard) + " " + shard;
949935
shards.put(shard, decision);

0 commit comments

Comments
 (0)