HBASE-18990 ServerLoad doesn't override #equals which leads to #equals in ClusterStatus always false
Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
7f1cd12e8c
commit
b96e2f055d
|
@ -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.
|
||||
* <p>
|
||||
|
@ -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()) &&
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue