String addressStr = DNS.getDefaultHost(
conf.get("hbase.master.dns.interface","default"),
conf.get("hbase.master.dns.nameserver","default"));
addressStr += ":" +
conf.get(MASTER_PORT, Integer.toString(DEFAULT_MASTER_PORT));
HServerAddress address = new HServerAddress(addressStr);
LOG.info("My address is " + address);
this.conf = conf;
this.rootdir = new Path(conf.get(HBASE_DIR));
try {
FSUtils.validateRootPath(this.rootdir);
} catch (IOException e) {
LOG.fatal("Not starting HMaster because the root directory path '" +
this.rootdir + "' is not valid. Check the setting of the" +
" configuration parameter '" + HBASE_DIR + "'", e);
throw e;
}
this.threadWakeFrequency = conf.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000);
// The filesystem hbase wants to use is probably not what is set into
// fs.default.name; its value is probably the default.
this.conf.set("fs.default.name", this.rootdir.toString());
this.fs = FileSystem.get(conf);
this.conf.set(HConstants.HBASE_DIR, this.rootdir.toString());
this.rand = new Random();
// If FS is in safe mode wait till out of it.
FSUtils.waitOnSafeMode(this.conf, this.threadWakeFrequency);
try {
// Make sure the hbase root directory exists!
if (!fs.exists(rootdir)) {
fs.mkdirs(rootdir);
FSUtils.setVersion(fs, rootdir);
} else {
FSUtils.checkVersion(fs, rootdir, true);
}
// Make sure the root region directory exists!
if (!FSUtils.rootRegionExists(fs, rootdir)) {
bootstrap();
}
} catch (IOException e) {
LOG.fatal("Not starting HMaster because:", e);
throw e;
}
this.numRetries = conf.getInt("hbase.client.retries.number", 2);
this.maxRegionOpenTime =
conf.getLong("hbase.hbasemaster.maxregionopen", 120 * 1000);
this.leaseTimeout = conf.getInt("hbase.master.lease.period", 120 * 1000);
this.server = HBaseRPC.getServer(this, address.getBindAddress(),
address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
false, conf);
// The rpc-server port can be ephemeral... ensure we have the correct info
this.address = new HServerAddress(server.getListenerAddress());
// dont retry too much
conf.setInt("hbase.client.retries.number", 3);
this.connection = ServerConnectionManager.getConnection(conf);