diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java index 1c2224710eb..0655b18ea87 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java @@ -25,11 +25,10 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import org.apache.hadoop.hbase.shaded.com.google.common.base.Objects; import org.apache.yetus.audience.InterfaceAudience; import org.apache.hadoop.hbase.master.RegionState; -import com.google.common.base.Objects; - /** * Status information on the HBase cluster. *
@@ -198,7 +197,6 @@ public class ClusterStatus { return false; } ClusterStatus other = (ClusterStatus) o; - //TODO Override the equals() methods in ServerLoad. return Objects.equal(getHBaseVersion(), other.getHBaseVersion()) && Objects.equal(this.liveServers, other.liveServers) && getDeadServerNames().containsAll(other.getDeadServerNames()) && diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java index c6cc4e9a40d..2fdb7319851 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.TreeMap; import java.util.TreeSet; +import org.apache.hadoop.hbase.shaded.com.google.common.base.Objects; import org.apache.yetus.audience.InterfaceAudience; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos; @@ -364,4 +365,31 @@ public class ServerLoad { public long getReportTime() { return reportTime; } + + @Override + public int hashCode() { + return Objects.hashCode(stores, storefiles, storeUncompressedSizeMB, + storefileSizeMB, memstoreSizeMB, storefileIndexSizeKB, readRequestsCount, + filteredReadRequestsCount, writeRequestsCount, rootIndexSizeKB, totalStaticIndexSizeKB, + totalStaticBloomSizeKB, totalCompactingKVs, currentCompactedKVs); + } + + @Override + public boolean equals(Object other) { + if (other == this) return true; + if (other instanceof ServerLoad) { + ServerLoad sl = ((ServerLoad) other); + return stores == sl.stores && storefiles == sl.storefiles && + storeUncompressedSizeMB == sl.storeUncompressedSizeMB && + storefileSizeMB == sl.storefileSizeMB && memstoreSizeMB == sl.memstoreSizeMB && + storefileIndexSizeKB == sl.storefileIndexSizeKB && readRequestsCount == sl.readRequestsCount && + filteredReadRequestsCount == sl.filteredReadRequestsCount && + writeRequestsCount == sl.writeRequestsCount && rootIndexSizeKB == sl.rootIndexSizeKB && + totalStaticIndexSizeKB == sl.totalStaticIndexSizeKB && + totalStaticBloomSizeKB == sl.totalStaticBloomSizeKB && + totalCompactingKVs == sl.totalCompactingKVs && + currentCompactedKVs == sl.currentCompactedKVs; + } + return false; + } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java index 2f0331028b2..bf0adf35066 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java @@ -81,6 +81,7 @@ public class TestClientClusterStatus { Assert.assertTrue(origin.getDeadServersSize() == defaults.getDeadServersSize()); Assert.assertTrue(origin.getRegionsCount() == defaults.getRegionsCount()); Assert.assertTrue(origin.getServersSize() == defaults.getServersSize()); + Assert.assertTrue(origin.equals(defaults)); } @Test @@ -100,7 +101,7 @@ public class TestClientClusterStatus { Assert.assertNotNull(status.hashCode()); ClusterStatus nullEqualsCheck = ADMIN.getClusterStatus(EnumSet.noneOf(Option.class)); - Assert.assertNotNull(status.equals(nullEqualsCheck)); + Assert.assertTrue(status.equals(nullEqualsCheck)); } @Test