Repository: hbase
Updated Branches:
  refs/heads/0.98 95a70c924 -> 09b89eedb


HBASE-16807, RegionServer will fail to report new active Hmaster until 
HMaster/RegionServer failover.

Signed-off-by: chenheng <chenh...@apache.org>


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

Branch: refs/heads/0.98
Commit: 09b89eedb585517d734bf3af3875e0e1ff5359e0
Parents: 95a70c9
Author: Pankaj Kumar <pankaj...@huawei.com>
Authored: Thu Oct 13 20:24:55 2016 +0800
Committer: chenheng <chenh...@apache.org>
Committed: Thu Oct 13 22:20:43 2016 +0800

----------------------------------------------------------------------
 .../hbase/regionserver/HRegionServer.java       | 21 +++++++++++++++-----
 .../TestRegionServerReportForDuty.java          |  4 ++--
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/09b89eed/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 1d8116f..37cbdc4 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -1132,7 +1132,7 @@ public class HRegionServer implements 
ClientProtos.ClientService.BlockingInterfa
       }
       // Couldn't connect to the master, get location from zk and reconnect
       // Method blocks until new master is found or we are stopped
-      createRegionServerStatusStub();
+      createRegionServerStatusStub(true);
     }
   }
 
@@ -2108,15 +2108,26 @@ public class HRegionServer implements 
ClientProtos.ClientService.BlockingInterfa
    * @return master + port, or null if server has been stopped
    */
   @VisibleForTesting
-  protected synchronized ServerName
-  createRegionServerStatusStub() {
+  protected synchronized ServerName createRegionServerStatusStub() {
+    // Create RS stub without refreshing the master node from ZK, use cached 
data
+    return createRegionServerStatusStub(false);
+  }
+
+  /**
+   * Get the current master from ZooKeeper and open the RPC connection to it. 
To get a fresh
+   * connection, the current rssStub must be null. Method will block until a 
master is available.
+   * You can break from this block by requesting the server stop.
+   * @param refresh If true then master address will be read from ZK, 
otherwise use cached data
+   * @return master + port, or null if server has been stopped
+   */
+  @VisibleForTesting
+  protected synchronized ServerName createRegionServerStatusStub(boolean 
refresh) {
     if (rssStub != null) {
       return masterAddressTracker.getMasterAddress();
     }
     ServerName sn = null;
     long previousLogTime = 0;
     RegionServerStatusService.BlockingInterface master = null;
-    boolean refresh = false; // for the first time, use cached data
     RegionServerStatusService.BlockingInterface intf = null;
     while (keepLooping() && master == null) {
       sn = this.masterAddressTracker.getMasterAddress(refresh);
@@ -2179,7 +2190,7 @@ public class HRegionServer implements 
ClientProtos.ClientService.BlockingInterfa
    * @throws IOException
    */
   private RegionServerStartupResponse reportForDuty() throws IOException {
-    ServerName masterServerName = createRegionServerStatusStub();
+    ServerName masterServerName = createRegionServerStatusStub(true);
     if (masterServerName == null) return null;
     RegionServerStartupResponse result = null;
     try {

http://git-wip-us.apache.org/repos/asf/hbase/blob/09b89eed/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerReportForDuty.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerReportForDuty.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerReportForDuty.java
index 80acb3f..3a5879f 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerReportForDuty.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerReportForDuty.java
@@ -165,8 +165,8 @@ public class TestRegionServerReportForDuty {
     }
 
     @Override
-    protected synchronized ServerName createRegionServerStatusStub() {
-      sn = super.createRegionServerStatusStub();
+    protected synchronized ServerName createRegionServerStatusStub(boolean 
refresh) {
+      sn = super.createRegionServerStatusStub(refresh);
       rpcStubCreatedFlag = true;
 
       // Wait for master switch over. Only do this for the second region 
server.

Reply via email to