You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2016/11/10 01:07:10 UTC
[2/2] hbase git commit: HBASE-16985 TestClusterId failed due to wrong
hbase rootdir
HBASE-16985 TestClusterId failed due to wrong hbase rootdir
Signed-off-by: Michael Stack <st...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1462cf77
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1462cf77
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1462cf77
Branch: refs/heads/master
Commit: 1462cf77ef4aa7c77a9c1b218caa6075d25ae653
Parents: de3a512
Author: Guanghao Zhang <zg...@gmail.com>
Authored: Wed Nov 2 10:13:37 2016 +0800
Committer: Michael Stack <st...@apache.org>
Committed: Wed Nov 9 17:06:58 2016 -0800
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/master/HMaster.java | 2 +-
.../hbase/regionserver/HRegionServer.java | 39 ++++++++++++++------
2 files changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/1462cf77/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 204577d..0136ff5 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
@@ -406,7 +406,7 @@ public class HMaster extends HRegionServer implements MasterServices {
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/1462cf77/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 89f7a05..312e8c1 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
@@ -583,16 +583,7 @@ public class HRegionServer extends HasThread implements
}
};
- // 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 = getFsTableDescriptors();
+ initializeFileSystem();
service = new ExecutorService(getServerName().toShortString());
spanReceiverHost = SpanReceiverHost.getInstance(getConfiguration());
@@ -648,6 +639,19 @@ 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 = getFsTableDescriptors();
+ }
+
protected TableDescriptors getFsTableDescriptors() throws IOException {
return new FSTableDescriptors(this.conf,
this.fs, this.rootDir, !canUpdateTableDescriptor(), false);
@@ -1386,6 +1390,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.
@@ -1408,13 +1413,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) {