hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [1/3] hbase git commit: HBASE-19379 TestEndToEndSplitTransaction fails with NPE
Date Thu, 30 Nov 2017 02:04:56 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 4c413e0c5 -> f3614f20c
  refs/heads/branch-1.4 fb070f1d4 -> ea8123e81


HBASE-19379 TestEndToEndSplitTransaction fails with NPE


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f3614f20
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f3614f20
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f3614f20

Branch: refs/heads/branch-1
Commit: f3614f20c00a455dd59d6ca46abaa00123b946f9
Parents: 4c413e0
Author: Andrew Purtell <apurtell@apache.org>
Authored: Wed Nov 29 16:37:07 2017 -0800
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Wed Nov 29 17:10:52 2017 -0800

----------------------------------------------------------------------
 .../apache/hadoop/hbase/HRegionLocation.java    | 73 +++++++++++++++-----
 1 file changed, 55 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f3614f20/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java
index 373e76b..ff78ddc 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java
@@ -61,29 +61,71 @@ public class HRegionLocation implements Comparable<HRegionLocation>
{
         + ", hostname=" + this.serverName + ", seqNum=" + seqNum;
   }
 
-  /**
-   * @see java.lang.Object#equals(java.lang.Object)
-   */
   @Override
-  public boolean equals(Object o) {
-    if (this == o) {
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((regionInfo == null) ? 0 : regionInfo.hashCode());
+    result = prime * result + (int) (seqNum ^ (seqNum >>> 32));
+    result = prime * result + ((serverName == null) ? 0 : serverName.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) {
       return true;
     }
-    if (o == null) {
+    if (obj == null) {
+      return false;
+    }
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+    HRegionLocation other = (HRegionLocation) obj;
+    if (regionInfo == null) {
+      if (other.regionInfo != null) {
+        return false;
+      }
+    } else if (!regionInfo.equals(other.regionInfo)) {
       return false;
     }
-    if (!(o instanceof HRegionLocation)) {
+    if (seqNum != other.seqNum) {
       return false;
     }
-    return this.compareTo((HRegionLocation)o) == 0;
+    if (serverName == null) {
+      if (other.serverName != null) {
+        return false;
+      }
+    } else if (!serverName.equals(other.serverName)) {
+      return false;
+    }
+    return true;
   }
 
-  /**
-   * @see java.lang.Object#hashCode()
-   */
   @Override
-  public int hashCode() {
-    return this.serverName.hashCode();
+  public int compareTo(HRegionLocation other) {
+    if (regionInfo == null) {
+      if (other.regionInfo != null) {
+        return 1;
+      }
+    } else {
+      int compare = regionInfo.compareTo(other.regionInfo);
+      if (compare != 0) {
+        return compare;
+      }
+    }
+    if (serverName == null) {
+      if (other.serverName != null) {
+        return 1;
+      }
+    } else {
+      int compare = serverName.compareTo(other.serverName);
+      if (compare != 0) {
+        return compare;
+      }
+    }
+    return Long.compare(seqNum, other.seqNum);
   }
 
   /** @return HRegionInfo */
@@ -113,9 +155,4 @@ public class HRegionLocation implements Comparable<HRegionLocation>
{
   public ServerName getServerName() {
     return serverName;
   }
-
-  @Override
-  public int compareTo(HRegionLocation o) {
-    return serverName.compareTo(o.getServerName());
-  }
 }


Mime
View raw message