Skip to content

Commit 613538e

Browse files
authored
Revert "Optimize calculating the presence of a quorum (#83638) (#83674)" (#83679)
This reverts commit e1935d7.
1 parent 45b2cf5 commit 613538e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationMetadata.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,9 @@ public void writeTo(StreamOutput out) throws IOException {
346346
}
347347

348348
public boolean hasQuorum(Collection<String> votes) {
349-
int votedNodesCount = 0;
350-
for (String nodeId : nodeIds) {
351-
if (votes.contains(nodeId)) {
352-
votedNodesCount++;
353-
}
354-
}
355-
return votedNodesCount * 2 > nodeIds.size();
349+
final HashSet<String> intersection = new HashSet<>(nodeIds);
350+
intersection.retainAll(votes);
351+
return intersection.size() * 2 > nodeIds.size();
356352
}
357353

358354
public Set<String> getNodeIds() {

0 commit comments

Comments
 (0)