Repository: hbase
Updated Branches:
  refs/heads/branch-1 1e322e68a -> e929156f9


HBASE-16985 TestClusterId failed due to wrong hbase rootdir

Signed-off-by: Michael Stack <[email protected]>


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

Branch: refs/heads/branch-1
Commit: e929156f96de004b2b8a0535463eff7fe8c38116
Parents: 1e322e6
Author: Guanghao Zhang <[email protected]>
Authored: Wed Nov 2 10:52:09 2016 +0800
Committer: Michael Stack <[email protected]>
Committed: Wed Nov 9 17:19:31 2016 -0800

----------------------------------------------------------------------
 .../hbase/regionserver/HRegionServer.java       | 36 ++++++++++++++------
 1 file changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e929156f/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 689daf1..7050377 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
@@ -575,17 +575,7 @@ public class HRegionServer extends HasThread implements
 
     useZKForAssignment = ConfigUtil.useZKForAssignment(conf);
 
-    // Set 'fs.defaultFS' to match the filesystem on hbase.rootdir else
-    // underlying hadoop hdfs accessors will be going against wrong filesystem
-    // (unless all is set to defaults).
-    FSUtils.setFsDefault(this.conf, FSUtils.getRootDir(this.conf));
-    // Get fs instance used by this RS.  Do we use checksum verification in 
the hbase? If hbase
-    // checksum verification enabled, then automatically switch off hdfs 
checksum verification.
-    boolean useHBaseChecksum = 
conf.getBoolean(HConstants.HBASE_CHECKSUM_VERIFICATION, true);
-    this.fs = new HFileSystem(this.conf, useHBaseChecksum);
-    this.rootDir = FSUtils.getRootDir(this.conf);
-    this.tableDescriptors = new FSTableDescriptors(
-      this.conf, this.fs, this.rootDir, !canUpdateTableDescriptor(), false);
+    initializeFileSystem();
 
     service = new ExecutorService(getServerName().toShortString());
     spanReceiverHost = SpanReceiverHost.getInstance(getConfiguration());
@@ -638,6 +628,20 @@ public class HRegionServer extends HasThread implements
     choreService.scheduleChore(compactedFileDischarger);
   }
 
+  private void initializeFileSystem() throws IOException {
+    // Set 'fs.defaultFS' to match the filesystem on hbase.rootdir else
+    // underlying hadoop hdfs accessors will be going against wrong filesystem
+    // (unless all is set to defaults).
+    FSUtils.setFsDefault(this.conf, FSUtils.getRootDir(this.conf));
+    // Get fs instance used by this RS.  Do we use checksum verification in 
the hbase? If hbase
+    // checksum verification enabled, then automatically switch off hdfs 
checksum verification.
+    boolean useHBaseChecksum = 
conf.getBoolean(HConstants.HBASE_CHECKSUM_VERIFICATION, true);
+    this.fs = new HFileSystem(this.conf, useHBaseChecksum);
+    this.rootDir = FSUtils.getRootDir(this.conf);
+    this.tableDescriptors = new FSTableDescriptors(
+      this.conf, this.fs, this.rootDir, !canUpdateTableDescriptor(), false);
+  }
+
   protected void setInitLatch(CountDownLatch latch) {
     this.initLatch = latch;
   }
@@ -1362,6 +1366,7 @@ public class HRegionServer extends HasThread implements
   protected void handleReportForDutyResponse(final RegionServerStartupResponse 
c)
   throws IOException {
     try {
+      boolean updateRootDir = false;
       for (NameStringPair e : c.getMapEntriesList()) {
         String key = e.getName();
         // The hostname the master sees us as.
@@ -1385,11 +1390,20 @@ public class HRegionServer extends HasThread implements
           continue;
         }
         String value = e.getValue();
+        if (key.equals(HConstants.HBASE_DIR)) {
+          if (value != null && !value.equals(conf.get(HConstants.HBASE_DIR))) {
+            updateRootDir = true;
+          }
+        }
         if (LOG.isDebugEnabled()) {
           LOG.info("Config from master: " + key + "=" + value);
         }
         this.conf.set(key, value);
       }
+      if (updateRootDir) {
+        // initialize file system by the config fs.defaultFS and hbase.rootdir 
from master
+        initializeFileSystem();
+      }
 
       // hack! Maps DFSClient => RegionServer for logs.  HDFS made this
       // config param for task trackers, but we can piggyback off of it.

Reply via email to