Permalink
Browse files

Cluster equals fix

  • Loading branch information...
bbansal committed Apr 8, 2009
1 parent 961bfd0 commit 83e35a7bc79dcc5fd846aba52934a1026b170e00
Showing with 10 additions and 5 deletions.
  1. +10 −5 src/java/voldemort/cluster/Cluster.java
@@ -30,6 +30,8 @@
import voldemort.annotations.jmx.JmxManaged;
import voldemort.utils.Utils;
+import com.google.common.collect.Sets;
+
/**
* A representation of the voldemort cluster
*
@@ -112,6 +114,11 @@ public String toString() {
@Override
public boolean equals(Object second) {
+ if(this == second)
+ return true;
+ if(second == null || second.getClass() != getClass())
+ return false;
+
Cluster secondCluster = (Cluster) second;
if(this.getNodes().size() != secondCluster.getNodes().size()) {
return false;
@@ -123,11 +130,9 @@ public boolean equals(Object second) {
return false;
}
- for(int partitionId: nodeA.getPartitionIds()) {
- if(!nodeB.getPartitionIds().contains(partitionId)) {
- return false;
- }
- }
+ if(!Sets.newHashSet(nodeA.getPartitionIds())
+ .equals(Sets.newHashSet(nodeB.getPartitionIds())))
+ return false;
}
return true;

0 comments on commit 83e35a7

Please sign in to comment.