Permalink
Browse files

equals objects should have equal hashCodes

  • Loading branch information...
mebigfatguy committed Dec 26, 2010
1 parent 4443fb2 commit 96fbc9e52890560ab28ed5ebaef83f272e10cf9b
Showing with 15 additions and 0 deletions.
  1. +10 −0 src/java/voldemort/cluster/Cluster.java
  2. +5 −0 src/java/voldemort/cluster/Zone.java
@@ -170,4 +170,14 @@ public boolean equals(Object second) {
return true;
}
+
+ @Override
+ public int hashCode() {
+ int hc = getNodes().size();
+ for(Node node: getNodes()) {
+ hc ^= node.getHost().hashCode();
+ }
+
+ return hc;
+ }
}
@@ -57,6 +57,11 @@ public boolean equals(Object object) {
return true;
}
+ @Override
+ public int hashCode() {
+ return getId() ^ getProximityList().size();
+ }
+
public int getId() {
return this.zoneId;
}

0 comments on commit 96fbc9e

Please sign in to comment.