hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-16985 TestClusterId failed due to wrong hbase rootdir
Date Wed, 07 Dec 2016 20:55:50 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 9a5d1b689 -> 39d344fe7


HBASE-16985 TestClusterId failed due to wrong hbase rootdir

Signed-off-by: Michael Stack <stack@apache.org>


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

Branch: refs/heads/branch-1.2
Commit: 39d344fe77282a254098dc989ed3332704e24a50
Parents: 9a5d1b6
Author: Guanghao Zhang <zghaobac@gmail.com>
Authored: Thu Nov 10 13:10:16 2016 +0800
Committer: Michael Stack <stack@apache.org>
Committed: Wed Dec 7 12:55:40 2016 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/master/HMaster.java |  2 +-
 .../hbase/regionserver/HRegionServer.java       | 41 ++++++++++++++------
 2 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/39d344fe/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 124ea09..59a9faa 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -382,7 +382,7 @@ public class HMaster extends HRegionServer implements MasterServices,
Server {
     this.rsFatals = new MemoryBoundedLogMessageBuffer(
       conf.getLong("hbase.master.buffer.for.rs.fatals", 1*1024*1024));
 
-    LOG.info("hbase.rootdir=" + FSUtils.getRootDir(this.conf) +
+    LOG.info("hbase.rootdir=" + getRootDir() +
       ", hbase.cluster.distributed=" + this.conf.getBoolean(HConstants.CLUSTER_DISTRIBUTED,
false));
 
     // Disable usage of meta replicas in the master

http://git-wip-us.apache.org/repos/asf/hbase/blob/39d344fe/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 62b4985..9fa0a69 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
@@ -559,17 +559,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());
@@ -610,6 +600,20 @@ public class HRegionServer extends HasThread implements
     }
   }
 
+  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);
+  }
+
   /*
    * Returns true if configured hostname should be used
    */
@@ -1325,6 +1329,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.
@@ -1347,13 +1352,25 @@ 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);
+          LOG.debug("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.
       if (this.conf.get("mapreduce.task.attempt.id") == null) {


Mime
View raw message