Index: src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (revision 1061092) +++ src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (working copy) @@ -408,11 +408,7 @@ */ public void shutdownMiniCluster() throws IOException { LOG.info("Shutting down minicluster"); - if (this.hbaseCluster != null) { - this.hbaseCluster.shutdown(); - // Wait till hbase is down before going on to shutdown zk. - this.hbaseCluster.join(); - } + shutdownMiniHBaseCluster(); if (!this.passedZkCluster) shutdownMiniZKCluster(); if (this.dfsCluster != null) { // The below throws an exception per dn, AsynchronousCloseException. @@ -431,6 +427,19 @@ } /** + * Shutdown HBase mini cluster. Does not shutdown zk or dfs if running. + * @throws IOException + */ + public void shutdownMiniHBaseCluster() throws IOException { + if (this.hbaseCluster != null) { + this.hbaseCluster.shutdown(); + // Wait till hbase is down before going on to shutdown zk. + this.hbaseCluster.join(); + } + this.hbaseCluster = null; + } + + /** * Creates an hbase rootdir in user home directory. Also creates hbase * version file. Normally you won't make use of this method. Root hbasedir * is created for you as part of mini cluster startup. You'd only use this Index: src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTrackerOnCluster.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTrackerOnCluster.java (revision 0) +++ src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTrackerOnCluster.java (revision 0) @@ -0,0 +1,62 @@ +/** + * Copyright 2011 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.catalog; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.Abortable; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HServerAddress; +import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; +import org.junit.Test; + +/** + * Do {@link CatalogTracker} tests on running cluster. + */ +public class TestCatalogTrackerOnCluster { + private static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); + private static final Log LOG = + LogFactory.getLog(TestCatalogTrackerOnCluster.class); + + /** + * @throws Exception + * @see https://issues.apache.org/jira/browse/HBASE-3445 + */ + @Test public void testBadOriginalRootLocation() throws Exception { + // Launch cluster so it does bootstrapping. + UTIL.startMiniCluster(); + // Shutdown hbase. + UTIL.shutdownMiniHBaseCluster(); + // Mess with the root location in the running zk. Set it to be nonsense. + ZooKeeperWatcher zookeeper = new ZooKeeperWatcher(UTIL.getConfiguration(), + "Bad Root Location Writer", new Abortable() { + @Override + public void abort(String why, Throwable e) { + LOG.error("Abort was called on 'bad root location writer'", e); + } + }); + HServerAddress nonsense = new HServerAddress("example.org:1234"); + RootLocationEditor.setRootLocation(zookeeper, nonsense); + // Bring back up the hbase cluster. See if it can deal with nonsense root + // location. + UTIL.startMiniHBaseCluster(1, 1); + UTIL.shutdownMiniCluster(); + } +} Index: src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java (revision 1061092) +++ src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java (working copy) @@ -112,7 +112,7 @@ @Test public void testThatIfMETAMovesWeAreNotified() throws IOException, InterruptedException, KeeperException { HConnection connection = Mockito.mock(HConnection.class); - final CatalogTracker ct = constructAndStartCatalogTracker(connection); + constructAndStartCatalogTracker(connection); try { RootLocationEditor.setRootLocation(this.watcher, new HServerAddress("example.com:1234")); Index: src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (revision 1061092) +++ src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (working copy) @@ -22,6 +22,7 @@ import java.io.EOFException; import java.io.IOException; import java.net.ConnectException; +import java.net.SocketTimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.commons.logging.Log; @@ -388,6 +389,9 @@ } else { throw e; } + } catch (SocketTimeoutException e) { + // We were passed the wrong address. Return 'protocol' == null. + LOG.debug("Timed out connecting to " + address); } catch (IOException ioe) { Throwable cause = ioe.getCause(); if (cause != null && cause instanceof EOFException) {