diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java index 6e185d22a25..4a4dcd892ad 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java @@ -96,8 +96,8 @@ public class MetaTableLocator { */ public List> getMetaRegionsAndLocations(ZooKeeperWatcher zkw) { ServerName serverName = new MetaTableLocator().getMetaRegionLocation(zkw); - List> list = new ArrayList<>(); - list.add(new Pair<>(HRegionInfo.FIRST_META_REGIONINFO, serverName)); + List> list = new ArrayList>(); + list.add(new Pair(HRegionInfo.FIRST_META_REGIONINFO, serverName)); return list; } @@ -114,7 +114,7 @@ public class MetaTableLocator { private List getListOfHRegionInfos( final List> pairs) { if (pairs == null || pairs.isEmpty()) return null; - List result = new ArrayList<>(pairs.size()); + List result = new ArrayList(pairs.size()); for (Pair pair: pairs) { result.add(pair.getFirst()); } @@ -265,7 +265,7 @@ public class MetaTableLocator { } } LOG.info("Failed verification of " + Bytes.toStringBinary(regionName) + - " at address=" + address + ", exception=" + t); + " at address=" + address + ", exception=" + t.getMessage()); return false; } 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 507d31d6792..6bbff40fe26 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 @@ -262,7 +262,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server { * *

* Remaining steps of initialization occur in - * {@link #finishActiveMasterInitialization(MonitoredTask)} after + * #finishActiveMasterInitialization(MonitoredTask) after * the master becomes the active one. * * @throws KeeperException @@ -291,6 +291,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server { this.metricsMaster = new MetricsMaster( new MetricsMasterWrapperImpl(this)); // Do we publish the status? + boolean shouldPublish = conf.getBoolean(HConstants.STATUS_PUBLISHED, HConstants.STATUS_PUBLISHED_DEFAULT); Class publisherClass = @@ -1267,8 +1268,10 @@ public class HMaster extends HRegionServer implements MasterServices, Server { * this node explicitly. If we crash before then, ZooKeeper will delete * this node for us since it is ephemeral. */ - LOG.info("Adding ZNode for " + backupZNode + " in backup master directory"); - MasterAddressTracker.setMasterAddress(zooKeeper, backupZNode, serverName); + LOG.info("Adding backup master ZNode " + backupZNode); + if (!MasterAddressTracker.setMasterAddress(zooKeeper, backupZNode, serverName)) { + LOG.warn("Failed create of " + backupZNode + " by " + serverName); + } activeMasterManager = new ActiveMasterManager(zooKeeper, serverName, this); // Start a thread to try to become the active master, so we won't block here diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java index d01e61819f2..f1606f11ef6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java @@ -166,7 +166,10 @@ public class HMasterCommandLine extends ServerCommandLine { // login the zookeeper server principal (if using security) ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file", "hbase.zookeeper.server.kerberos.principal", null); - + int localZKClusterSessionTimeout = + conf.getInt(HConstants.ZK_SESSION_TIMEOUT + ".localHBaseCluster", 10*1000); + conf.setInt(HConstants.ZK_SESSION_TIMEOUT, localZKClusterSessionTimeout); + LOG.info("Starting a zookeeper cluster"); int clientPort = zooKeeperCluster.startup(zkDataPath); if (clientPort != zkClientPort) { String errorMsg = "Could not start ZK at requested port of " + @@ -176,13 +179,15 @@ public class HMasterCommandLine extends ServerCommandLine { System.err.println(errorMsg); throw new IOException(errorMsg); } - conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, - Integer.toString(clientPort)); - conf.setInt(HConstants.ZK_SESSION_TIMEOUT, 10 *1000); + conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort)); // Need to have the zk cluster shutdown when master is shutdown. // Run a subclass that does the zk cluster shutdown on its way out. - LocalHBaseCluster cluster = new LocalHBaseCluster(conf, conf.getInt("hbase.masters", 1), - conf.getInt("hbase.regionservers", 1), LocalHMaster.class, HRegionServer.class); + int mastersCount = conf.getInt("hbase.masters", 1); + int regionServersCount = conf.getInt("hbase.regionservers", 1); + LOG.info("Starting up instance of localHBaseCluster; master=" + mastersCount + + ", regionserversCount=" + regionServersCount); + LocalHBaseCluster cluster = new LocalHBaseCluster(conf, mastersCount, regionServersCount, + LocalHMaster.class, HRegionServer.class); ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster); cluster.startup(); waitOnMasterThreads(cluster); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java index 8d8d2108875..e3ac47e1d97 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java @@ -165,8 +165,7 @@ public class MiniZooKeeperCluster { standaloneServerFactory = new NIOServerCnxnFactory(); standaloneServerFactory.configure( new InetSocketAddress(tentativePort), - configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS, - 1000)); + configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS, 1000)); } catch (BindException e) { LOG.debug("Failed binding ZK Server to client port: " + tentativePort, e); @@ -181,6 +180,7 @@ public class MiniZooKeeperCluster { // Start up this ZK server standaloneServerFactory.startup(server); + // Runs a 'stat' against the servers. if (!waitForServerUp(tentativePort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for startup of standalone server"); } @@ -196,8 +196,8 @@ public class MiniZooKeeperCluster { activeZKServerIndex = 0; started = true; int clientPort = clientPortList.get(activeZKServerIndex); - LOG.info("Started MiniZK Cluster and connect 1 ZK server " + - "on client port: " + clientPort); + LOG.info("Started MiniZooKeeperCluster and ran successful 'stat' " + + "on client port=" + clientPort); return clientPort; }