HBASE-12238 A few ugly exceptions on startup

This commit is contained in:
stack 2014-10-29 21:42:29 -07:00
parent 842a77e4a5
commit 5062edebcf
4 changed files with 25 additions and 17 deletions

View File

@ -96,8 +96,8 @@ public class MetaTableLocator {
*/ */
public List<Pair<HRegionInfo, ServerName>> getMetaRegionsAndLocations(ZooKeeperWatcher zkw) { public List<Pair<HRegionInfo, ServerName>> getMetaRegionsAndLocations(ZooKeeperWatcher zkw) {
ServerName serverName = new MetaTableLocator().getMetaRegionLocation(zkw); ServerName serverName = new MetaTableLocator().getMetaRegionLocation(zkw);
List<Pair<HRegionInfo, ServerName>> list = new ArrayList<>(); List<Pair<HRegionInfo, ServerName>> list = new ArrayList<Pair<HRegionInfo, ServerName>>();
list.add(new Pair<>(HRegionInfo.FIRST_META_REGIONINFO, serverName)); list.add(new Pair<HRegionInfo, ServerName>(HRegionInfo.FIRST_META_REGIONINFO, serverName));
return list; return list;
} }
@ -114,7 +114,7 @@ public class MetaTableLocator {
private List<HRegionInfo> getListOfHRegionInfos( private List<HRegionInfo> getListOfHRegionInfos(
final List<Pair<HRegionInfo, ServerName>> pairs) { final List<Pair<HRegionInfo, ServerName>> pairs) {
if (pairs == null || pairs.isEmpty()) return null; if (pairs == null || pairs.isEmpty()) return null;
List<HRegionInfo> result = new ArrayList<>(pairs.size()); List<HRegionInfo> result = new ArrayList<HRegionInfo>(pairs.size());
for (Pair<HRegionInfo, ServerName> pair: pairs) { for (Pair<HRegionInfo, ServerName> pair: pairs) {
result.add(pair.getFirst()); result.add(pair.getFirst());
} }
@ -265,7 +265,7 @@ public class MetaTableLocator {
} }
} }
LOG.info("Failed verification of " + Bytes.toStringBinary(regionName) + LOG.info("Failed verification of " + Bytes.toStringBinary(regionName) +
" at address=" + address + ", exception=" + t); " at address=" + address + ", exception=" + t.getMessage());
return false; return false;
} }

View File

@ -262,7 +262,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
* </ol> * </ol>
* <p> * <p>
* Remaining steps of initialization occur in * Remaining steps of initialization occur in
* {@link #finishActiveMasterInitialization(MonitoredTask)} after * #finishActiveMasterInitialization(MonitoredTask) after
* the master becomes the active one. * the master becomes the active one.
* *
* @throws KeeperException * @throws KeeperException
@ -291,6 +291,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
this.metricsMaster = new MetricsMaster( new MetricsMasterWrapperImpl(this)); this.metricsMaster = new MetricsMaster( new MetricsMasterWrapperImpl(this));
// Do we publish the status? // Do we publish the status?
boolean shouldPublish = conf.getBoolean(HConstants.STATUS_PUBLISHED, boolean shouldPublish = conf.getBoolean(HConstants.STATUS_PUBLISHED,
HConstants.STATUS_PUBLISHED_DEFAULT); HConstants.STATUS_PUBLISHED_DEFAULT);
Class<? extends ClusterStatusPublisher.Publisher> publisherClass = Class<? extends ClusterStatusPublisher.Publisher> 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 explicitly. If we crash before then, ZooKeeper will delete
* this node for us since it is ephemeral. * this node for us since it is ephemeral.
*/ */
LOG.info("Adding ZNode for " + backupZNode + " in backup master directory"); LOG.info("Adding backup master ZNode " + backupZNode);
MasterAddressTracker.setMasterAddress(zooKeeper, backupZNode, serverName); if (!MasterAddressTracker.setMasterAddress(zooKeeper, backupZNode, serverName)) {
LOG.warn("Failed create of " + backupZNode + " by " + serverName);
}
activeMasterManager = new ActiveMasterManager(zooKeeper, serverName, this); activeMasterManager = new ActiveMasterManager(zooKeeper, serverName, this);
// Start a thread to try to become the active master, so we won't block here // Start a thread to try to become the active master, so we won't block here

View File

@ -166,7 +166,10 @@ public class HMasterCommandLine extends ServerCommandLine {
// login the zookeeper server principal (if using security) // login the zookeeper server principal (if using security)
ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file", ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file",
"hbase.zookeeper.server.kerberos.principal", null); "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); int clientPort = zooKeeperCluster.startup(zkDataPath);
if (clientPort != zkClientPort) { if (clientPort != zkClientPort) {
String errorMsg = "Could not start ZK at requested port of " + String errorMsg = "Could not start ZK at requested port of " +
@ -176,13 +179,15 @@ public class HMasterCommandLine extends ServerCommandLine {
System.err.println(errorMsg); System.err.println(errorMsg);
throw new IOException(errorMsg); throw new IOException(errorMsg);
} }
conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort));
Integer.toString(clientPort));
conf.setInt(HConstants.ZK_SESSION_TIMEOUT, 10 *1000);
// Need to have the zk cluster shutdown when master is shutdown. // Need to have the zk cluster shutdown when master is shutdown.
// Run a subclass that does the zk cluster shutdown on its way out. // Run a subclass that does the zk cluster shutdown on its way out.
LocalHBaseCluster cluster = new LocalHBaseCluster(conf, conf.getInt("hbase.masters", 1), int mastersCount = conf.getInt("hbase.masters", 1);
conf.getInt("hbase.regionservers", 1), LocalHMaster.class, HRegionServer.class); 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); ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
cluster.startup(); cluster.startup();
waitOnMasterThreads(cluster); waitOnMasterThreads(cluster);

View File

@ -165,8 +165,7 @@ public class MiniZooKeeperCluster {
standaloneServerFactory = new NIOServerCnxnFactory(); standaloneServerFactory = new NIOServerCnxnFactory();
standaloneServerFactory.configure( standaloneServerFactory.configure(
new InetSocketAddress(tentativePort), new InetSocketAddress(tentativePort),
configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS, configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS, 1000));
1000));
} catch (BindException e) { } catch (BindException e) {
LOG.debug("Failed binding ZK Server to client port: " + LOG.debug("Failed binding ZK Server to client port: " +
tentativePort, e); tentativePort, e);
@ -181,6 +180,7 @@ public class MiniZooKeeperCluster {
// Start up this ZK server // Start up this ZK server
standaloneServerFactory.startup(server); standaloneServerFactory.startup(server);
// Runs a 'stat' against the servers.
if (!waitForServerUp(tentativePort, CONNECTION_TIMEOUT)) { if (!waitForServerUp(tentativePort, CONNECTION_TIMEOUT)) {
throw new IOException("Waiting for startup of standalone server"); throw new IOException("Waiting for startup of standalone server");
} }
@ -196,8 +196,8 @@ public class MiniZooKeeperCluster {
activeZKServerIndex = 0; activeZKServerIndex = 0;
started = true; started = true;
int clientPort = clientPortList.get(activeZKServerIndex); int clientPort = clientPortList.get(activeZKServerIndex);
LOG.info("Started MiniZK Cluster and connect 1 ZK server " + LOG.info("Started MiniZooKeeperCluster and ran successful 'stat' " +
"on client port: " + clientPort); "on client port=" + clientPort);
return clientPort; return clientPort;
} }