HBASE-1816 Master Rewrite; redo how we check rootdir in HMaster constructor -- was broke when deploying on cluster
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@830768 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fd02c343fa
commit
d6adcd04f5
|
@ -404,9 +404,8 @@
|
|||
<name>zookeeper.retries</name>
|
||||
<value>5</value>
|
||||
<description>How many times to retry connections to ZooKeeper. Used for
|
||||
reading/writing root region location, checking/writing out of safe mode.
|
||||
Used together with ${zookeeper.pause} in an exponential backoff fashion
|
||||
when making queries to ZooKeeper.
|
||||
reading/writing root region location. Used together with ${zookeeper.pause}
|
||||
in an exponential backoff fashion when making queries to ZooKeeper.
|
||||
</description>
|
||||
</property>
|
||||
<property>
|
||||
|
@ -435,16 +434,6 @@
|
|||
this means the root location is stored at /hbase/root-region-server.
|
||||
</description>
|
||||
</property>
|
||||
<property>
|
||||
<name>zookeeper.znode.safemode</name>
|
||||
<value>safe-mode</value>
|
||||
<description>Path to ephemeral ZNode signifying cluster is out of safe mode.
|
||||
This is created by the master when scanning is done. Clients wait for this
|
||||
node before querying the cluster. If a relative path is given, the parent
|
||||
folder will be ${zookeeper.znode.parent}. By default, this means the safe
|
||||
mode flag is stored at /hbase/safe-mode.
|
||||
</description>
|
||||
</property>
|
||||
|
||||
<!--
|
||||
The following three properties are used together to create the list of
|
||||
|
|
|
@ -157,16 +157,18 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
*/
|
||||
public HMaster(HBaseConfiguration conf) throws IOException {
|
||||
this.conf = conf;
|
||||
this.fs = FileSystem.get(this.conf);
|
||||
this.rootdir = getAndCheckRootDir(this.conf, this.fs);
|
||||
// Set back into the configuration the qualified rootdir path.
|
||||
this.conf.set(HConstants.HBASE_DIR, rootdir.toString());
|
||||
// Set filesystem to be that of this.rootdir.
|
||||
// Set filesystem to be that of this.rootdir else we get complaints about
|
||||
// mismatched filesystems if hbase.rootdir is hdfs and fs.defaultFS is
|
||||
// default localfs. Presumption is that rootdir is fully-qualified before
|
||||
// we get to here with appropriate fs scheme.
|
||||
this.rootdir = FSUtils.getRootDir(this.conf);
|
||||
this.conf.set("fs.defaultFS", this.rootdir.toString());
|
||||
this.fs = FileSystem.get(this.conf);
|
||||
checkRootDir(this.rootdir, this.conf, this.fs);
|
||||
|
||||
// Get my address and create an rpc server instance. The rpc-server port
|
||||
// can be ephemeral...ensure we have the correct info
|
||||
HServerAddress a = new HServerAddress(getMyAddress());
|
||||
HServerAddress a = new HServerAddress(getMyAddress(this.conf));
|
||||
this.rpcServer = HBaseRPC.getServer(this, a.getBindAddress(),
|
||||
a.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
|
||||
false, conf);
|
||||
|
@ -198,19 +200,19 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
}
|
||||
|
||||
/*
|
||||
* Get the rootdir. Make sure its wholesome before returning.
|
||||
* Get the rootdir. Make sure its wholesome and exists before returning.
|
||||
* @param rd
|
||||
* @param conf
|
||||
* @param fs
|
||||
* @return Fully qualified path to wholesome hbase root dir.
|
||||
* @return hbase.rootdir (after checks for existence and bootstrapping if
|
||||
* needed populating the directory with necessary bootup files).
|
||||
* @throws IOException
|
||||
*/
|
||||
private Path getAndCheckRootDir(final HBaseConfiguration c,
|
||||
private static Path checkRootDir(final Path rd, final HBaseConfiguration c,
|
||||
final FileSystem fs)
|
||||
throws IOException {
|
||||
Path rd = FSUtils.verifyAndQualifyRootDir(c);
|
||||
// If FS is in safe mode wait till out of it.
|
||||
FSUtils.waitOnSafeMode(c, c.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000));
|
||||
|
||||
// Filesystem is good. Go ahead and check for hbase.rootdir.
|
||||
if (!fs.exists(rd)) {
|
||||
fs.mkdirs(rd);
|
||||
|
@ -225,21 +227,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
return rd;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return This masters' address.
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
private String getMyAddress() throws UnknownHostException {
|
||||
// Find out our address up in DNS.
|
||||
String addressStr = DNS.getDefaultHost(
|
||||
conf.get("hbase.master.dns.interface","default"),
|
||||
conf.get("hbase.master.dns.nameserver","default"));
|
||||
addressStr += ":" +
|
||||
this.conf.get(MASTER_PORT, Integer.toString(DEFAULT_MASTER_PORT));
|
||||
return addressStr;
|
||||
}
|
||||
|
||||
private void bootstrap(final Path rd, final HBaseConfiguration c)
|
||||
private static void bootstrap(final Path rd, final HBaseConfiguration c)
|
||||
throws IOException {
|
||||
LOG.info("BOOTSTRAP: creating ROOT and first META regions");
|
||||
try {
|
||||
|
@ -271,12 +259,25 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
* @param hri Set all family block caching to <code>b</code>
|
||||
* @param b
|
||||
*/
|
||||
private void setBlockCaching(final HRegionInfo hri, final boolean b) {
|
||||
private static void setBlockCaching(final HRegionInfo hri, final boolean b) {
|
||||
for (HColumnDescriptor hcd: hri.getTableDesc().families.values()) {
|
||||
hcd.setBlockCacheEnabled(b);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @return This masters' address.
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
private static String getMyAddress(final HBaseConfiguration c)
|
||||
throws UnknownHostException {
|
||||
// Find out our address up in DNS.
|
||||
String s = DNS.getDefaultHost(c.get("hbase.master.dns.interface","default"),
|
||||
c.get("hbase.master.dns.nameserver","default"));
|
||||
s += ":" + c.get(MASTER_PORT, Integer.toString(DEFAULT_MASTER_PORT));
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the file system is still accessible.
|
||||
* If not, sets closed
|
||||
|
|
|
@ -237,19 +237,6 @@ public class FSUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify and qualify rootdir in <code>conf</code>. Does not test for
|
||||
* existence of the rootdir.
|
||||
* @param conf.
|
||||
* @return Verified and qualified rootdir.
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Path verifyAndQualifyRootDir(final HBaseConfiguration conf)
|
||||
throws IOException {
|
||||
Path dir = FSUtils.getRootDir(conf, false);
|
||||
return FileSystem.get(conf).makeQualified(FSUtils.validateRootPath(dir));
|
||||
}
|
||||
|
||||
/**
|
||||
* If DFS, check safe mode and if so, wait until we clear it.
|
||||
* @param conf
|
||||
|
@ -290,33 +277,12 @@ public class FSUtils {
|
|||
|
||||
/**
|
||||
* @param c
|
||||
* @return Path to hbase root directory: i.e. <code>hbase.rootdir</code> as a
|
||||
* Path.
|
||||
* @return Path to hbase root directory: i.e. <code>hbase.rootdir</code> from
|
||||
* configuration as a Path.
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Path getRootDir(final HBaseConfiguration c) throws IOException {
|
||||
return getRootDir(c, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param c
|
||||
* @param test If true, test for presence and throw exception if not present.
|
||||
* @return Path to hbase root directory: i.e. <code>hbase.rootdir</code> as a
|
||||
* Path.
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Path getRootDir(final HBaseConfiguration c, final boolean test)
|
||||
throws IOException {
|
||||
FileSystem fs = FileSystem.get(c);
|
||||
// Get root directory of HBase installation
|
||||
Path rootdir = fs.makeQualified(new Path(c.get(HConstants.HBASE_DIR)));
|
||||
if (test && !fs.exists(rootdir)) {
|
||||
String message = "HBase root directory " + rootdir.toString() +
|
||||
" does not exist.";
|
||||
LOG.error(message);
|
||||
throw new FileNotFoundException(message);
|
||||
}
|
||||
return rootdir;
|
||||
return new Path(c.get(HConstants.HBASE_DIR));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue