http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
index 5f1159a..5c35611 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
@@ -19,23 +19,17 @@
 package org.apache.hadoop.hbase.master;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.ClusterStatus;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -44,34 +38,17 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.LargeTests;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
-import org.apache.hadoop.hbase.RegionTransition;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.TableStateManager;
-import org.apache.hadoop.hbase.MetaTableAccessor;
-import org.apache.hadoop.hbase.coordination.BaseCoordinatedStateManager;
 import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.master.RegionState.State;
-import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
-import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.HRegionServer;
-import org.apache.hadoop.hbase.regionserver.RegionMergeTransaction;
-import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.FSTableDescriptors;
 import org.apache.hadoop.hbase.util.FSUtils;
-import org.apache.hadoop.hbase.util.JVMClusterUtil;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
-import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-import org.apache.hadoop.hbase.util.Threads;
-import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZKTableStateManager;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.zookeeper.data.Stat;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -79,877 +56,6 @@ import org.junit.experimental.categories.Category;
 public class TestMasterFailover {
   private static final Log LOG = LogFactory.getLog(TestMasterFailover.class);
 
-  /**
-   * Complex test of master failover that tests as many permutations of the
-   * different possible states that regions in transition could be in within 
ZK.
-   * <p>
-   * This tests the proper handling of these states by the failed-over master
-   * and includes a thorough testing of the timeout code as well.
-   * <p>
-   * Starts with a single master and three regionservers.
-   * <p>
-   * Creates two tables, enabledTable and disabledTable, each containing 5
-   * regions.  The disabledTable is then disabled.
-   * <p>
-   * After reaching steady-state, the master is killed.  We then mock several
-   * states in ZK.
-   * <p>
-   * After mocking them, we will startup a new master which should become the
-   * active master and also detect that it is a failover.  The primary test
-   * passing condition will be that all regions of the enabled table are
-   * assigned and all the regions of the disabled table are not assigned.
-   * <p>
-   * The different scenarios to be tested are below:
-   * <p>
-   * <b>ZK State:  OFFLINE</b>
-   * <p>A node can get into OFFLINE state if</p>
-   * <ul>
-   * <li>An RS fails to open a region, so it reverts the state back to OFFLINE
-   * <li>The Master is assigning the region to a RS before it sends RPC
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>Master has assigned an enabled region but RS failed so a region is
-   *     not assigned anywhere and is sitting in ZK as OFFLINE</li>
-   * <li>This seems to cover both cases?</li>
-   * </ul>
-   * <p>
-   * <b>ZK State:  CLOSING</b>
-   * <p>A node can get into CLOSING state if</p>
-   * <ul>
-   * <li>An RS has begun to close a region
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>Region of enabled table was being closed but did not complete
-   * <li>Region of disabled table was being closed but did not complete
-   * </ul>
-   * <p>
-   * <b>ZK State:  CLOSED</b>
-   * <p>A node can get into CLOSED state if</p>
-   * <ul>
-   * <li>An RS has completed closing a region but not acknowledged by master 
yet
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>Region of a table that should be enabled was closed on an RS
-   * <li>Region of a table that should be disabled was closed on an RS
-   * </ul>
-   * <p>
-   * <b>ZK State:  OPENING</b>
-   * <p>A node can get into OPENING state if</p>
-   * <ul>
-   * <li>An RS has begun to open a region
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>RS was opening a region of enabled table but never finishes
-   * </ul>
-   * <p>
-   * <b>ZK State:  OPENED</b>
-   * <p>A node can get into OPENED state if</p>
-   * <ul>
-   * <li>An RS has finished opening a region but not acknowledged by master yet
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>Region of a table that should be enabled was opened on an RS
-   * <li>Region of a table that should be disabled was opened on an RS
-   * </ul>
-   * @throws Exception
-   */
-  @Test (timeout=240000)
-  public void testMasterFailoverWithMockedRIT() throws Exception {
-
-    final int NUM_MASTERS = 1;
-    final int NUM_RS = 3;
-
-    // Create config to use for this cluster
-    Configuration conf = HBaseConfiguration.create();
-    conf.setBoolean("hbase.assignment.usezk", true);
-
-    // Start the cluster
-    HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
-    TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
-    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-    log("Cluster started");
-
-    // Create a ZKW to use in the test
-    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
-
-    // get all the master threads
-    List<MasterThread> masterThreads = cluster.getMasterThreads();
-    assertEquals(1, masterThreads.size());
-
-    // only one master thread, let's wait for it to be initialized
-    assertTrue(cluster.waitForActiveAndReadyMaster());
-    HMaster master = masterThreads.get(0).getMaster();
-    assertTrue(master.isActiveMaster());
-    assertTrue(master.isInitialized());
-
-    // disable load balancing on this master
-    master.balanceSwitch(false);
-
-    // create two tables in META, each with 10 regions
-    byte [] FAMILY = Bytes.toBytes("family");
-    byte [][] SPLIT_KEYS = new byte [][] {
-        new byte[0], Bytes.toBytes("aaa"), Bytes.toBytes("bbb"),
-        Bytes.toBytes("ccc"), Bytes.toBytes("ddd"), Bytes.toBytes("eee"),
-        Bytes.toBytes("fff"), Bytes.toBytes("ggg"), Bytes.toBytes("hhh"),
-        Bytes.toBytes("iii"), Bytes.toBytes("jjj")
-    };
-
-    byte [] enabledTable = Bytes.toBytes("enabledTable");
-    HTableDescriptor htdEnabled = new 
HTableDescriptor(TableName.valueOf(enabledTable));
-    htdEnabled.addFamily(new HColumnDescriptor(FAMILY));
-
-    FileSystem filesystem = FileSystem.get(conf);
-    Path rootdir = FSUtils.getRootDir(conf);
-    FSTableDescriptors fstd = new FSTableDescriptors(filesystem, rootdir);
-    // Write the .tableinfo
-    fstd.createTableDescriptor(htdEnabled);
-
-    HRegionInfo hriEnabled = new HRegionInfo(htdEnabled.getTableName(), null, 
null);
-    createRegion(hriEnabled, rootdir, conf, htdEnabled);
-
-    List<HRegionInfo> enabledRegions = TEST_UTIL.createMultiRegionsInMeta(
-        TEST_UTIL.getConfiguration(), htdEnabled, SPLIT_KEYS);
-
-    TableName disabledTable = TableName.valueOf("disabledTable");
-    HTableDescriptor htdDisabled = new HTableDescriptor(disabledTable);
-    htdDisabled.addFamily(new HColumnDescriptor(FAMILY));
-    // Write the .tableinfo
-    fstd.createTableDescriptor(htdDisabled);
-    HRegionInfo hriDisabled = new HRegionInfo(htdDisabled.getTableName(), 
null, null);
-    createRegion(hriDisabled, rootdir, conf, htdDisabled);
-    List<HRegionInfo> disabledRegions = TEST_UTIL.createMultiRegionsInMeta(
-        TEST_UTIL.getConfiguration(), htdDisabled, SPLIT_KEYS);
-
-    TableName tableWithMergingRegions = 
TableName.valueOf("tableWithMergingRegions");
-    TEST_UTIL.createTable(tableWithMergingRegions, FAMILY, new byte [][] 
{Bytes.toBytes("m")});
-
-    log("Regions in hbase:meta and namespace have been created");
-
-    // at this point we only expect 4 regions to be assigned out
-    // (catalogs and namespace, + 2 merging regions)
-    assertEquals(4, cluster.countServedRegions());
-
-    // Move merging regions to the same region server
-    AssignmentManager am = master.getAssignmentManager();
-    RegionStates regionStates = am.getRegionStates();
-    List<HRegionInfo> mergingRegions = 
regionStates.getRegionsOfTable(tableWithMergingRegions);
-    assertEquals(2, mergingRegions.size());
-    HRegionInfo a = mergingRegions.get(0);
-    HRegionInfo b = mergingRegions.get(1);
-    HRegionInfo newRegion = RegionMergeTransaction.getMergedRegionInfo(a, b);
-    ServerName mergingServer = regionStates.getRegionServerOfRegion(a);
-    ServerName serverB = regionStates.getRegionServerOfRegion(b);
-    if (!serverB.equals(mergingServer)) {
-      RegionPlan plan = new RegionPlan(b, serverB, mergingServer);
-      am.balance(plan);
-      assertTrue(am.waitForAssignment(b));
-    }
-
-    // Let's just assign everything to first RS
-    HRegionServer hrs = cluster.getRegionServer(0);
-    ServerName serverName = hrs.getServerName();
-    HRegionInfo closingRegion = enabledRegions.remove(0);
-    // we'll need some regions to already be assigned out properly on live RS
-    List<HRegionInfo> enabledAndAssignedRegions = new ArrayList<HRegionInfo>();
-    enabledAndAssignedRegions.add(enabledRegions.remove(0));
-    enabledAndAssignedRegions.add(enabledRegions.remove(0));
-    enabledAndAssignedRegions.add(closingRegion);
-
-    List<HRegionInfo> disabledAndAssignedRegions = new 
ArrayList<HRegionInfo>();
-    disabledAndAssignedRegions.add(disabledRegions.remove(0));
-    disabledAndAssignedRegions.add(disabledRegions.remove(0));
-
-    // now actually assign them
-    for (HRegionInfo hri : enabledAndAssignedRegions) {
-      master.assignmentManager.regionPlans.put(hri.getEncodedName(),
-          new RegionPlan(hri, null, serverName));
-      master.assignRegion(hri);
-    }
-    for (HRegionInfo hri : disabledAndAssignedRegions) {
-      master.assignmentManager.regionPlans.put(hri.getEncodedName(),
-          new RegionPlan(hri, null, serverName));
-      master.assignRegion(hri);
-    }
-
-    // wait for no more RIT
-    log("Waiting for assignment to finish");
-    ZKAssign.blockUntilNoRIT(zkw);
-    log("Assignment completed");
-
-    // Stop the master
-    log("Aborting master");
-    cluster.abortMaster(0);
-    cluster.waitOnMaster(0);
-    log("Master has aborted");
-
-    /*
-     * Now, let's start mocking up some weird states as described in the method
-     * javadoc.
-     */
-
-    // Master is down, so is the meta. We need to assign it somewhere
-    // so that regions can be assigned during the mocking phase.
-    ZKAssign.createNodeOffline(
-      zkw, HRegionInfo.FIRST_META_REGIONINFO, hrs.getServerName());
-    ProtobufUtil.openRegion(hrs.getRSRpcServices(),
-      hrs.getServerName(), HRegionInfo.FIRST_META_REGIONINFO);
-
-    MetaTableLocator mtl = new MetaTableLocator();
-    while (true) {
-      ServerName sn = mtl.getMetaRegionLocation(zkw);
-      if (sn != null && sn.equals(hrs.getServerName())) {
-        break;
-      }
-      Thread.sleep(100);
-    }
-
-    List<HRegionInfo> regionsThatShouldBeOnline = new ArrayList<HRegionInfo>();
-    List<HRegionInfo> regionsThatShouldBeOffline = new 
ArrayList<HRegionInfo>();
-
-    log("Beginning to mock scenarios");
-
-    // Disable the disabledTable in ZK
-    TableStateManager zktable = new ZKTableStateManager(zkw);
-    zktable.setTableState(disabledTable, ZooKeeperProtos.Table.State.DISABLED);
-
-    /*
-     *  ZK = OFFLINE
-     */
-
-    // Region that should be assigned but is not and is in ZK as OFFLINE
-    // Cause: This can happen if the master crashed after creating the znode 
but before sending the
-    //  request to the region server
-    HRegionInfo region = enabledRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, serverName);
-
-    /*
-     * ZK = CLOSING
-     */
-    // Cause: Same as offline.
-    regionsThatShouldBeOnline.add(closingRegion);
-    ZKAssign.createNodeClosing(zkw, closingRegion, serverName);
-
-    /*
-     * ZK = CLOSED
-     */
-
-    // Region of enabled table closed but not ack
-    //Cause: Master was down while the region server updated the ZK status.
-    region = enabledRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    int version = ZKAssign.createNodeClosing(zkw, region, serverName);
-    ZKAssign.transitionNodeClosed(zkw, region, serverName, version);
-
-    // Region of disabled table closed but not ack
-    region = disabledRegions.remove(0);
-    regionsThatShouldBeOffline.add(region);
-    version = ZKAssign.createNodeClosing(zkw, region, serverName);
-    ZKAssign.transitionNodeClosed(zkw, region, serverName, version);
-
-    /*
-     * ZK = OPENED
-     */
-
-    // Region of enabled table was opened on RS
-    // Cause: as offline
-    region = enabledRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, serverName);
-    ProtobufUtil.openRegion(hrs.getRSRpcServices(), hrs.getServerName(), 
region);
-    while (true) {
-      byte [] bytes = ZKAssign.getData(zkw, region.getEncodedName());
-      RegionTransition rt = RegionTransition.parseFrom(bytes);
-      if (rt != null && 
rt.getEventType().equals(EventType.RS_ZK_REGION_OPENED)) {
-        break;
-      }
-      Thread.sleep(100);
-    }
-
-    // Region of disable table was opened on RS
-    // Cause: Master failed while updating the status for this region server.
-    region = disabledRegions.remove(0);
-    regionsThatShouldBeOffline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, serverName);
-    ProtobufUtil.openRegion(hrs.getRSRpcServices(), hrs.getServerName(), 
region);
-    while (true) {
-      byte [] bytes = ZKAssign.getData(zkw, region.getEncodedName());
-      RegionTransition rt = RegionTransition.parseFrom(bytes);
-      if (rt != null && 
rt.getEventType().equals(EventType.RS_ZK_REGION_OPENED)) {
-        break;
-      }
-      Thread.sleep(100);
-    }
-
-    /*
-     * ZK = MERGING
-     */
-
-    // Regions of table of merging regions
-    // Cause: Master was down while merging was going on
-    ((BaseCoordinatedStateManager) hrs.getCoordinatedStateManager())
-      .getRegionMergeCoordination().startRegionMergeTransaction(newRegion, 
mergingServer, a, b);
-
-    /*
-     * ZK = NONE
-     */
-
-    /*
-     * DONE MOCKING
-     */
-
-    log("Done mocking data up in ZK");
-
-    // Start up a new master
-    log("Starting up a new master");
-    master = cluster.startMaster().getMaster();
-    log("Waiting for master to be ready");
-    cluster.waitForActiveAndReadyMaster();
-    log("Master is ready");
-
-    // Get new region states since master restarted
-    regionStates = master.getAssignmentManager().getRegionStates();
-    // Merging region should remain merging
-    assertTrue(regionStates.isRegionInState(a, State.MERGING));
-    assertTrue(regionStates.isRegionInState(b, State.MERGING));
-    assertTrue(regionStates.isRegionInState(newRegion, State.MERGING_NEW));
-    // Now remove the faked merging znode, merging regions should be
-    // offlined automatically, otherwise it is a bug in AM.
-    ZKAssign.deleteNodeFailSilent(zkw, newRegion);
-
-    // Failover should be completed, now wait for no RIT
-    log("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
-    log("No more RIT in ZK, now doing final test verification");
-
-    // Grab all the regions that are online across RSs
-    Set<HRegionInfo> onlineRegions = new TreeSet<HRegionInfo>();
-    for (JVMClusterUtil.RegionServerThread rst :
-      cluster.getRegionServerThreads()) {
-      onlineRegions.addAll(ProtobufUtil.getOnlineRegions(
-        rst.getRegionServer().getRSRpcServices()));
-    }
-
-    // Now, everything that should be online should be online
-    for (HRegionInfo hri : regionsThatShouldBeOnline) {
-      assertTrue(onlineRegions.contains(hri));
-    }
-
-    // Everything that should be offline should not be online
-    for (HRegionInfo hri : regionsThatShouldBeOffline) {
-      if (onlineRegions.contains(hri)) {
-       LOG.debug(hri);
-      }
-      assertFalse(onlineRegions.contains(hri));
-    }
-
-    log("Done with verification, all passed, shutting down cluster");
-
-    // Done, shutdown the cluster
-    TEST_UTIL.shutdownMiniCluster();
-  }
-
-  /**
-   * Complex test of master failover that tests as many permutations of the
-   * different possible states that regions in transition could be in within ZK
-   * pointing to an RS that has died while no master is around to process it.
-   * <p>
-   * This tests the proper handling of these states by the failed-over master
-   * and includes a thorough testing of the timeout code as well.
-   * <p>
-   * Starts with a single master and two regionservers.
-   * <p>
-   * Creates two tables, enabledTable and disabledTable, each containing 5
-   * regions.  The disabledTable is then disabled.
-   * <p>
-   * After reaching steady-state, the master is killed.  We then mock several
-   * states in ZK.  And one of the RS will be killed.
-   * <p>
-   * After mocking them and killing an RS, we will startup a new master which
-   * should become the active master and also detect that it is a failover.  
The
-   * primary test passing condition will be that all regions of the enabled
-   * table are assigned and all the regions of the disabled table are not
-   * assigned.
-   * <p>
-   * The different scenarios to be tested are below:
-   * <p>
-   * <b>ZK State:  CLOSING</b>
-   * <p>A node can get into CLOSING state if</p>
-   * <ul>
-   * <li>An RS has begun to close a region
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>Region was being closed but the RS died before finishing the close
-   * </ul>
-   * <b>ZK State:  OPENED</b>
-   * <p>A node can get into OPENED state if</p>
-   * <ul>
-   * <li>An RS has finished opening a region but not acknowledged by master yet
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>Region of a table that should be enabled was opened by a now-dead RS
-   * <li>Region of a table that should be disabled was opened by a now-dead RS
-   * </ul>
-   * <p>
-   * <b>ZK State:  NONE</b>
-   * <p>A region could not have a transition node if</p>
-   * <ul>
-   * <li>The server hosting the region died and no master processed it
-   * </ul>
-   * <p>We will mock the scenarios</p>
-   * <ul>
-   * <li>Region of enabled table was on a dead RS that was not yet processed
-   * <li>Region of disabled table was on a dead RS that was not yet processed
-   * </ul>
-   * @throws Exception
-   */
-  @Test (timeout=180000)
-  public void testMasterFailoverWithMockedRITOnDeadRS() throws Exception {
-
-    final int NUM_MASTERS = 1;
-    final int NUM_RS = 2;
-
-    // Create and start the cluster
-    HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
-    Configuration conf = TEST_UTIL.getConfiguration();
-    conf.setBoolean("hbase.assignment.usezk", true);
-
-    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
-    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, 2);
-    TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
-    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-    log("Cluster started");
-
-    // Create a ZKW to use in the test
-    ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
-        "unittest", new Abortable() {
-
-          @Override
-          public void abort(String why, Throwable e) {
-            LOG.error("Fatal ZK Error: " + why, e);
-            org.junit.Assert.assertFalse("Fatal ZK error", true);
-          }
-
-          @Override
-          public boolean isAborted() {
-            return false;
-          }
-
-    });
-
-    // get all the master threads
-    List<MasterThread> masterThreads = cluster.getMasterThreads();
-    assertEquals(1, masterThreads.size());
-
-    // only one master thread, let's wait for it to be initialized
-    assertTrue(cluster.waitForActiveAndReadyMaster());
-    HMaster master = masterThreads.get(0).getMaster();
-    assertTrue(master.isActiveMaster());
-    assertTrue(master.isInitialized());
-
-    // disable load balancing on this master
-    master.balanceSwitch(false);
-
-    // create two tables in META, each with 30 regions
-    byte [] FAMILY = Bytes.toBytes("family");
-    byte[][] SPLIT_KEYS =
-        TEST_UTIL.getRegionSplitStartKeys(Bytes.toBytes("aaa"), 
Bytes.toBytes("zzz"), 30);
-
-    byte [] enabledTable = Bytes.toBytes("enabledTable");
-    HTableDescriptor htdEnabled = new 
HTableDescriptor(TableName.valueOf(enabledTable));
-    htdEnabled.addFamily(new HColumnDescriptor(FAMILY));
-    FileSystem filesystem = FileSystem.get(conf);
-    Path rootdir = FSUtils.getRootDir(conf);
-    FSTableDescriptors fstd = new FSTableDescriptors(filesystem, rootdir);
-    // Write the .tableinfo
-    fstd.createTableDescriptor(htdEnabled);
-    HRegionInfo hriEnabled = new HRegionInfo(htdEnabled.getTableName(),
-        null, null);
-    createRegion(hriEnabled, rootdir, conf, htdEnabled);
-
-    List<HRegionInfo> enabledRegions = TEST_UTIL.createMultiRegionsInMeta(
-        TEST_UTIL.getConfiguration(), htdEnabled, SPLIT_KEYS);
-
-    TableName disabledTable =
-        TableName.valueOf("disabledTable");
-    HTableDescriptor htdDisabled = new HTableDescriptor(disabledTable);
-    htdDisabled.addFamily(new HColumnDescriptor(FAMILY));
-    // Write the .tableinfo
-    fstd.createTableDescriptor(htdDisabled);
-    HRegionInfo hriDisabled = new HRegionInfo(htdDisabled.getTableName(), 
null, null);
-    createRegion(hriDisabled, rootdir, conf, htdDisabled);
-
-    List<HRegionInfo> disabledRegions = TEST_UTIL.createMultiRegionsInMeta(
-        TEST_UTIL.getConfiguration(), htdDisabled, SPLIT_KEYS);
-
-    log("Regions in hbase:meta and Namespace have been created");
-
-    // at this point we only expect 2 regions to be assigned out (catalogs and 
namespace  )
-    assertEquals(2, cluster.countServedRegions());
-
-    // The first RS will stay online
-    List<RegionServerThread> regionservers =
-      cluster.getRegionServerThreads();
-    HRegionServer hrs = regionservers.get(0).getRegionServer();
-
-    // The second RS is going to be hard-killed
-    RegionServerThread hrsDeadThread = regionservers.get(1);
-    HRegionServer hrsDead = hrsDeadThread.getRegionServer();
-    ServerName deadServerName = hrsDead.getServerName();
-
-    // we'll need some regions to already be assigned out properly on live RS
-    List<HRegionInfo> enabledAndAssignedRegions = new ArrayList<HRegionInfo>();
-    enabledAndAssignedRegions.addAll(enabledRegions.subList(0, 6));
-    enabledRegions.removeAll(enabledAndAssignedRegions);
-    List<HRegionInfo> disabledAndAssignedRegions = new 
ArrayList<HRegionInfo>();
-    disabledAndAssignedRegions.addAll(disabledRegions.subList(0, 6));
-    disabledRegions.removeAll(disabledAndAssignedRegions);
-
-    // now actually assign them
-    for (HRegionInfo hri : enabledAndAssignedRegions) {
-      master.assignmentManager.regionPlans.put(hri.getEncodedName(),
-          new RegionPlan(hri, null, hrs.getServerName()));
-      master.assignRegion(hri);
-    }
-    for (HRegionInfo hri : disabledAndAssignedRegions) {
-      master.assignmentManager.regionPlans.put(hri.getEncodedName(),
-          new RegionPlan(hri, null, hrs.getServerName()));
-      master.assignRegion(hri);
-    }
-
-    log("Waiting for assignment to finish");
-    ZKAssign.blockUntilNoRIT(zkw);
-    master.assignmentManager.waitUntilNoRegionsInTransition(60000);
-    log("Assignment completed");
-
-    assertTrue(" Table must be enabled.", master.getAssignmentManager()
-        .getTableStateManager().isTableState(TableName.valueOf("enabledTable"),
-        ZooKeeperProtos.Table.State.ENABLED));
-    // we also need regions assigned out on the dead server
-    List<HRegionInfo> enabledAndOnDeadRegions = new ArrayList<HRegionInfo>();
-    enabledAndOnDeadRegions.addAll(enabledRegions.subList(0, 6));
-    enabledRegions.removeAll(enabledAndOnDeadRegions);
-    List<HRegionInfo> disabledAndOnDeadRegions = new ArrayList<HRegionInfo>();
-    disabledAndOnDeadRegions.addAll(disabledRegions.subList(0, 6));
-    disabledRegions.removeAll(disabledAndOnDeadRegions);
-
-    // set region plan to server to be killed and trigger assign
-    for (HRegionInfo hri : enabledAndOnDeadRegions) {
-      master.assignmentManager.regionPlans.put(hri.getEncodedName(),
-          new RegionPlan(hri, null, deadServerName));
-      master.assignRegion(hri);
-    }
-    for (HRegionInfo hri : disabledAndOnDeadRegions) {
-      master.assignmentManager.regionPlans.put(hri.getEncodedName(),
-          new RegionPlan(hri, null, deadServerName));
-      master.assignRegion(hri);
-    }
-
-    // wait for no more RIT
-    log("Waiting for assignment to finish");
-    ZKAssign.blockUntilNoRIT(zkw);
-    master.assignmentManager.waitUntilNoRegionsInTransition(60000);
-    log("Assignment completed");
-
-    // Due to master.assignRegion(hri) could fail to assign a region to a 
specified RS
-    // therefore, we need make sure that regions are in the expected RS
-    verifyRegionLocation(hrs, enabledAndAssignedRegions);
-    verifyRegionLocation(hrs, disabledAndAssignedRegions);
-    verifyRegionLocation(hrsDead, enabledAndOnDeadRegions);
-    verifyRegionLocation(hrsDead, disabledAndOnDeadRegions);
-
-    assertTrue(" Didn't get enough regions of enabledTalbe on live rs.",
-      enabledAndAssignedRegions.size() >= 2);
-    assertTrue(" Didn't get enough regions of disalbedTable on live rs.",
-      disabledAndAssignedRegions.size() >= 2);
-    assertTrue(" Didn't get enough regions of enabledTalbe on dead rs.",
-      enabledAndOnDeadRegions.size() >= 2);
-    assertTrue(" Didn't get enough regions of disalbedTable on dead rs.",
-      disabledAndOnDeadRegions.size() >= 2);
-
-    // Stop the master
-    log("Aborting master");
-    cluster.abortMaster(0);
-    cluster.waitOnMaster(0);
-    log("Master has aborted");
-
-    /*
-     * Now, let's start mocking up some weird states as described in the method
-     * javadoc.
-     */
-
-    // Master is down, so is the meta. We need to assign it somewhere
-    // so that regions can be assigned during the mocking phase.
-    ZKAssign.createNodeOffline(
-      zkw, HRegionInfo.FIRST_META_REGIONINFO, hrs.getServerName());
-    ProtobufUtil.openRegion(hrs.getRSRpcServices(),
-      hrs.getServerName(), HRegionInfo.FIRST_META_REGIONINFO);
-
-    MetaTableLocator mtl = new MetaTableLocator();
-    while (true) {
-      ServerName sn = mtl.getMetaRegionLocation(zkw);
-      if (sn != null && sn.equals(hrs.getServerName())) {
-        break;
-      }
-      Thread.sleep(100);
-    }
-
-    List<HRegionInfo> regionsThatShouldBeOnline = new ArrayList<HRegionInfo>();
-    List<HRegionInfo> regionsThatShouldBeOffline = new 
ArrayList<HRegionInfo>();
-
-    log("Beginning to mock scenarios");
-
-    // Disable the disabledTable in ZK
-    TableStateManager zktable = new ZKTableStateManager(zkw);
-    zktable.setTableState(disabledTable, ZooKeeperProtos.Table.State.DISABLED);
-
-    assertTrue(" The enabled table should be identified on master fail over.",
-        zktable.isTableState(TableName.valueOf("enabledTable"),
-          ZooKeeperProtos.Table.State.ENABLED));
-
-    /*
-     * ZK = CLOSING
-     */
-
-    // Region of enabled table being closed on dead RS but not finished
-    HRegionInfo region = enabledAndOnDeadRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    ZKAssign.createNodeClosing(zkw, region, deadServerName);
-    LOG.debug("\n\nRegion of enabled table was CLOSING on dead RS\n" +
-        region + "\n\n");
-
-    // Region of disabled table being closed on dead RS but not finished
-    region = disabledAndOnDeadRegions.remove(0);
-    regionsThatShouldBeOffline.add(region);
-    ZKAssign.createNodeClosing(zkw, region, deadServerName);
-    LOG.debug("\n\nRegion of disabled table was CLOSING on dead RS\n" +
-        region + "\n\n");
-
-    /*
-     * ZK = CLOSED
-     */
-
-    // Region of enabled on dead server gets closed but not ack'd by master
-    region = enabledAndOnDeadRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    int version = ZKAssign.createNodeClosing(zkw, region, deadServerName);
-    ZKAssign.transitionNodeClosed(zkw, region, deadServerName, version);
-    LOG.debug("\n\nRegion of enabled table was CLOSED on dead RS\n" +
-        region + "\n\n");
-
-    // Region of disabled on dead server gets closed but not ack'd by master
-    region = disabledAndOnDeadRegions.remove(0);
-    regionsThatShouldBeOffline.add(region);
-    version = ZKAssign.createNodeClosing(zkw, region, deadServerName);
-    ZKAssign.transitionNodeClosed(zkw, region, deadServerName, version);
-    LOG.debug("\n\nRegion of disabled table was CLOSED on dead RS\n" +
-        region + "\n\n");
-
-    /*
-     * ZK = OPENING
-     */
-
-    // RS was opening a region of enabled table then died
-    region = enabledRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, deadServerName);
-    ZKAssign.transitionNodeOpening(zkw, region, deadServerName);
-    LOG.debug("\n\nRegion of enabled table was OPENING on dead RS\n" +
-        region + "\n\n");
-
-    // RS was opening a region of disabled table then died
-    region = disabledRegions.remove(0);
-    regionsThatShouldBeOffline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, deadServerName);
-    ZKAssign.transitionNodeOpening(zkw, region, deadServerName);
-    LOG.debug("\n\nRegion of disabled table was OPENING on dead RS\n" +
-        region + "\n\n");
-
-    /*
-     * ZK = OPENED
-     */
-
-    // Region of enabled table was opened on dead RS
-    region = enabledRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, deadServerName);
-    ProtobufUtil.openRegion(hrsDead.getRSRpcServices(),
-      hrsDead.getServerName(), region);
-    while (true) {
-      byte [] bytes = ZKAssign.getData(zkw, region.getEncodedName());
-      RegionTransition rt = RegionTransition.parseFrom(bytes);
-      if (rt != null && 
rt.getEventType().equals(EventType.RS_ZK_REGION_OPENED)) {
-        break;
-      }
-      Thread.sleep(100);
-    }
-    LOG.debug("\n\nRegion of enabled table was OPENED on dead RS\n" +
-        region + "\n\n");
-
-    // Region of disabled table was opened on dead RS
-    region = disabledRegions.remove(0);
-    regionsThatShouldBeOffline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, deadServerName);
-    ProtobufUtil.openRegion(hrsDead.getRSRpcServices(),
-      hrsDead.getServerName(), region);
-    while (true) {
-      byte [] bytes = ZKAssign.getData(zkw, region.getEncodedName());
-      RegionTransition rt = RegionTransition.parseFrom(bytes);
-      if (rt != null && 
rt.getEventType().equals(EventType.RS_ZK_REGION_OPENED)) {
-        break;
-      }
-      Thread.sleep(100);
-    }
-    LOG.debug("\n\nRegion of disabled table was OPENED on dead RS\n" +
-        region + "\n\n");
-
-    /*
-     * ZK = NONE
-     */
-
-    // Region of enabled table was open at steady-state on dead RS
-    region = enabledRegions.remove(0);
-    regionsThatShouldBeOnline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, deadServerName);
-    ProtobufUtil.openRegion(hrsDead.getRSRpcServices(),
-      hrsDead.getServerName(), region);
-    while (true) {
-      byte [] bytes = ZKAssign.getData(zkw, region.getEncodedName());
-      RegionTransition rt = RegionTransition.parseFrom(bytes);
-      if (rt != null && 
rt.getEventType().equals(EventType.RS_ZK_REGION_OPENED)) {
-        ZKAssign.deleteOpenedNode(zkw, region.getEncodedName(), 
rt.getServerName());
-        LOG.debug("DELETED " + rt);
-        break;
-      }
-      Thread.sleep(100);
-    }
-    LOG.debug("\n\nRegion of enabled table was open at steady-state on dead RS"
-        + "\n" + region + "\n\n");
-
-    // Region of disabled table was open at steady-state on dead RS
-    region = disabledRegions.remove(0);
-    regionsThatShouldBeOffline.add(region);
-    ZKAssign.createNodeOffline(zkw, region, deadServerName);
-    ProtobufUtil.openRegion(hrsDead.getRSRpcServices(),
-      hrsDead.getServerName(), region);
-    while (true) {
-      byte [] bytes = ZKAssign.getData(zkw, region.getEncodedName());
-      RegionTransition rt = RegionTransition.parseFrom(bytes);
-      if (rt != null && 
rt.getEventType().equals(EventType.RS_ZK_REGION_OPENED)) {
-        ZKAssign.deleteOpenedNode(zkw, region.getEncodedName(), 
rt.getServerName());
-        break;
-      }
-      Thread.sleep(100);
-    }
-    LOG.debug("\n\nRegion of disabled table was open at steady-state on dead 
RS"
-      + "\n" + region + "\n\n");
-
-    /*
-     * DONE MOCKING
-     */
-
-    log("Done mocking data up in ZK");
-
-    // Kill the RS that had a hard death
-    log("Killing RS " + deadServerName);
-    hrsDead.abort("Killing for unit test");
-    log("RS " + deadServerName + " killed");
-
-    // Start up a new master.  Wait until regionserver is completely down
-    // before starting new master because of hbase-4511.
-    while (hrsDeadThread.isAlive()) {
-      Threads.sleep(10);
-    }
-    log("Starting up a new master");
-    master = cluster.startMaster().getMaster();
-    log("Waiting for master to be ready");
-    assertTrue(cluster.waitForActiveAndReadyMaster());
-    log("Master is ready");
-
-    // Wait until SSH processing completed for dead server.
-    while (master.getServerManager().areDeadServersInProgress()) {
-      Thread.sleep(10);
-    }
-
-    // Failover should be completed, now wait for no RIT
-    log("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
-    log("No more RIT in ZK");
-    long now = System.currentTimeMillis();
-    long maxTime = 120000;
-    boolean done = 
master.assignmentManager.waitUntilNoRegionsInTransition(maxTime);
-    if (!done) {
-      RegionStates regionStates = 
master.getAssignmentManager().getRegionStates();
-      LOG.info("rit=" + regionStates.getRegionsInTransition());
-    }
-    long elapsed = System.currentTimeMillis() - now;
-    assertTrue("Elapsed=" + elapsed + ", maxTime=" + maxTime + ", done=" + 
done,
-      elapsed < maxTime);
-    log("No more RIT in RIT map, doing final test verification");
-
-    // Grab all the regions that are online across RSs
-    Set<HRegionInfo> onlineRegions = new TreeSet<HRegionInfo>();
-    now = System.currentTimeMillis();
-    maxTime = 30000;
-    for (JVMClusterUtil.RegionServerThread rst :
-        cluster.getRegionServerThreads()) {
-      try {
-        HRegionServer rs = rst.getRegionServer();
-        while (!rs.getRegionsInTransitionInRS().isEmpty()) {
-          elapsed = System.currentTimeMillis() - now;
-          assertTrue("Test timed out in getting online regions", elapsed < 
maxTime);
-          if (rs.isAborted() || rs.isStopped()) {
-            // This region server is stopped, skip it.
-            break;
-          }
-          Thread.sleep(100);
-        }
-        
onlineRegions.addAll(ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()));
-      } catch (RegionServerStoppedException e) {
-        LOG.info("Got RegionServerStoppedException", e);
-      }
-    }
-
-    // Now, everything that should be online should be online
-    for (HRegionInfo hri : regionsThatShouldBeOnline) {
-      assertTrue("region=" + hri.getRegionNameAsString() + ", " + 
onlineRegions.toString(),
-        onlineRegions.contains(hri));
-    }
-
-    // Everything that should be offline should not be online
-    for (HRegionInfo hri : regionsThatShouldBeOffline) {
-      assertFalse(onlineRegions.contains(hri));
-    }
-
-    log("Done with verification, all passed, shutting down cluster");
-
-    // Done, shutdown the cluster
-    TEST_UTIL.shutdownMiniCluster();
-  }
-
-  /**
-   * Verify regions are on the expected region server
-   */
-  private void verifyRegionLocation(HRegionServer hrs, List<HRegionInfo> 
regions)
-      throws IOException {
-    List<HRegionInfo> tmpOnlineRegions =
-      ProtobufUtil.getOnlineRegions(hrs.getRSRpcServices());
-    Iterator<HRegionInfo> itr = regions.iterator();
-    while (itr.hasNext()) {
-      HRegionInfo tmp = itr.next();
-      if (!tmpOnlineRegions.contains(tmp)) {
-        itr.remove();
-      }
-    }
-  }
-
   HRegion createRegion(final HRegionInfo  hri, final Path rootdir, final 
Configuration c,
       final HTableDescriptor htd)
   throws IOException {
@@ -970,121 +76,6 @@ public class TestMasterFailover {
     LOG.info("\n\n" + string + " \n\n");
   }
 
-  @Test (timeout=180000)
-  public void testShouldCheckMasterFailOverWhenMETAIsInOpenedState()
-      throws Exception {
-    LOG.info("Starting testShouldCheckMasterFailOverWhenMETAIsInOpenedState");
-    final int NUM_MASTERS = 1;
-    final int NUM_RS = 2;
-
-    // Start the cluster
-    HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
-    Configuration conf = TEST_UTIL.getConfiguration();
-    conf.setInt("hbase.master.info.port", -1);
-    conf.setBoolean("hbase.assignment.usezk", true);
-
-    TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
-    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-
-    // Find regionserver carrying meta.
-    HRegionServer regionServer = cluster.getMaster();
-    HRegion metaRegion = regionServer.getOnlineRegion(
-      HRegionInfo.FIRST_META_REGIONINFO.getRegionName());
-
-    TEST_UTIL.shutdownMiniHBaseCluster();
-
-    // Create a ZKW to use in the test
-    ZooKeeperWatcher zkw =
-      HBaseTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
-          metaRegion, regionServer.getServerName());
-
-    LOG.info("Staring cluster for second time");
-    TEST_UTIL.startMiniHBaseCluster(NUM_MASTERS, NUM_RS);
-
-    HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-    while (!master.isInitialized()) {
-      Thread.sleep(100);
-    }
-    // Failover should be completed, now wait for no RIT
-    log("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
-
-    zkw.close();
-    // Stop the cluster
-    TEST_UTIL.shutdownMiniCluster();
-  }
-
-  /**
-   * This tests a RIT in offline state will get re-assigned after a master 
restart
-   */
-  @Test(timeout=240000)
-  public void testOfflineRegionReAssginedAfterMasterRestart() throws Exception 
{
-    final TableName table = 
TableName.valueOf("testOfflineRegionReAssginedAfterMasterRestart");
-    final int NUM_MASTERS = 1;
-    final int NUM_RS = 2;
-
-    // Create config to use for this cluster
-    Configuration conf = HBaseConfiguration.create();
-    conf.setBoolean("hbase.assignment.usezk", true);
-
-    // Start the cluster
-    final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
-    TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
-    log("Cluster started");
-
-    TEST_UTIL.createTable(table, Bytes.toBytes("family"));
-    HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-    RegionStates regionStates = 
master.getAssignmentManager().getRegionStates();
-    HRegionInfo hri = regionStates.getRegionsOfTable(table).get(0);
-    ServerName serverName = regionStates.getRegionServerOfRegion(hri);
-    TEST_UTIL.assertRegionOnServer(hri, serverName, 200);
-
-    ServerName dstName = null;
-    for (ServerName tmpServer : 
master.serverManager.getOnlineServers().keySet()) {
-      if (!tmpServer.equals(serverName)) {
-        dstName = tmpServer;
-        break;
-      }
-    }
-    // find a different server
-    assertTrue(dstName != null);
-    // shutdown HBase cluster
-    TEST_UTIL.shutdownMiniHBaseCluster();
-    // create a RIT node in offline state
-    ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
-    ZKAssign.createNodeOffline(zkw, hri, dstName);
-    Stat stat = new Stat();
-    byte[] data =
-        ZKAssign.getDataNoWatch(zkw, hri.getEncodedName(), stat);
-    assertTrue(data != null);
-    RegionTransition rt = RegionTransition.parseFrom(data);
-    assertTrue(rt.getEventType() == EventType.M_ZK_REGION_OFFLINE);
-
-    LOG.info(hri.getEncodedName() + " region is in offline state with source 
server=" + serverName
-        + " and dst server=" + dstName);
-
-    // start HBase cluster
-    TEST_UTIL.startMiniHBaseCluster(NUM_MASTERS, NUM_RS);
-
-    while (true) {
-      master = TEST_UTIL.getHBaseCluster().getMaster();
-      if (master != null && master.isInitialized()) {
-        ServerManager serverManager = master.getServerManager();
-        if (!serverManager.areDeadServersInProgress()) {
-          break;
-        }
-      }
-      Thread.sleep(200);
-    }
-
-    // verify the region is assigned
-    master = TEST_UTIL.getHBaseCluster().getMaster();
-    master.getAssignmentManager().waitForAssignment(hri);
-    regionStates = master.getAssignmentManager().getRegionStates();
-    RegionState newState = regionStates.getRegionState(hri);
-    assertTrue(newState.isOpened());
-  }
-
   /**
    * Simple test of master failover.
    * <p>
@@ -1205,7 +196,6 @@ public class TestMasterFailover {
 
     // Create config to use for this cluster
     Configuration conf = HBaseConfiguration.create();
-    conf.setBoolean("hbase.assignment.usezk", false);
 
     // Start the cluster
     HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
@@ -1277,7 +267,7 @@ public class TestMasterFailover {
     log("Master is ready");
 
     // Wait till no region in transition any more
-    master.getAssignmentManager().waitUntilNoRegionsInTransition(60000);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
 
     // Get new region states since master restarted
     regionStates = master.getAssignmentManager().getRegionStates();

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
index 00982b0..9f18f87 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
@@ -54,7 +54,6 @@ import 
org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.Regio
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
@@ -200,7 +199,7 @@ public class TestMasterNoCluster {
         // Fake a successful close.
         Mockito.doReturn(true).when(spy).
           sendRegionClose((ServerName)Mockito.any(), 
(HRegionInfo)Mockito.any(),
-            Mockito.anyInt(), (ServerName)Mockito.any(), Mockito.anyBoolean());
+            (ServerName)Mockito.any());
         return spy;
       }
 
@@ -235,13 +234,8 @@ public class TestMasterNoCluster {
         request.setLoad(ServerLoad.EMPTY_SERVERLOAD.obtainServerLoadPB());
         master.getMasterRpcServices().regionServerReport(null, 
request.build());
       }
-      ZooKeeperWatcher zkw = master.getZooKeeper();
-      // Master should now come up.
+       // Master should now come up.
       while (!master.isInitialized()) {
-        // Fake meta is closed on rs0, try several times in case the event is 
lost
-        // due to race with HMaster#assignMeta
-        ZKAssign.transitionNodeClosed(zkw,
-          HRegionInfo.FIRST_META_REGIONINFO, sn0, -1);
         Threads.sleep(100);
       }
       assertTrue(master.isInitialized());

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
index 7ed455e..7ff8ca1 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
@@ -37,9 +37,6 @@ import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.zookeeper.KeeperException;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -63,8 +60,6 @@ public class TestMasterRestartAfterDisablingTable {
     MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
     log("Waiting for active/ready master");
     cluster.waitForActiveAndReadyMaster();
-    ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "testmasterRestart", 
null);
-    HMaster master = cluster.getMaster();
 
     // Create a table with regions
     TableName table = TableName.valueOf("tableRestart");
@@ -75,7 +70,7 @@ public class TestMasterRestartAfterDisablingTable {
         NUM_REGIONS_TO_CREATE);
     numRegions += 1; // catalogs
     log("Waiting for no more RIT\n");
-    blockUntilNoRIT(zkw, master);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     log("Disabling table\n");
     TEST_UTIL.getHBaseAdmin().disableTable(table);
 
@@ -106,7 +101,7 @@ public class TestMasterRestartAfterDisablingTable {
     admin.enableTable(table);
     admin.close();
     log("Waiting for no more RIT\n");
-    blockUntilNoRIT(zkw, master);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     log("Verifying there are " + numRegions + " assigned on cluster\n");
     regions = HBaseTestingUtility.getAllOnlineRegions(cluster);
     assertEquals("The assigned regions were not onlined after master"
@@ -122,11 +117,5 @@ public class TestMasterRestartAfterDisablingTable {
   private void log(String msg) {
     LOG.debug("\n\nTRR: " + msg + "\n");
   }
-
-  private void blockUntilNoRIT(ZooKeeperWatcher zkw, HMaster master)
-      throws KeeperException, InterruptedException {
-    ZKAssign.blockUntilNoRIT(zkw);
-    master.assignmentManager.waitUntilNoRegionsInTransition(60000);
-  }
 }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
deleted file mode 100644
index 2cae6fb..0000000
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * 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.master;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.*;
-import org.apache.hadoop.hbase.coordination.BaseCoordinatedStateManager;
-import org.apache.hadoop.hbase.coordination.OpenRegionCoordination;
-import org.apache.hadoop.hbase.coordination.ZkCoordinatedStateManager;
-import org.apache.hadoop.hbase.coordination.ZkOpenRegionCoordination;
-import org.apache.hadoop.hbase.executor.EventType;
-import org.apache.hadoop.hbase.master.handler.OpenedRegionHandler;
-import org.apache.hadoop.hbase.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.HRegionServer;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.MockServer;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZKTableStateManager;
-import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.Stat;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-
-@Category(MediumTests.class)
-public class TestOpenedRegionHandler {
-
-  private static final Log LOG = LogFactory
-      .getLog(TestOpenedRegionHandler.class);
-
-  private HBaseTestingUtility TEST_UTIL;
-  private final int NUM_MASTERS = 1;
-  private final int NUM_RS = 1;
-  private Configuration conf;
-  private Configuration resetConf;
-  private ZooKeeperWatcher zkw;
-
-  @Before
-  public void setUp() throws Exception {
-    conf = HBaseConfiguration.create();
-    conf.setBoolean("hbase.assignment.usezk", true);
-    TEST_UTIL = HBaseTestingUtility.createLocalHTU(conf);
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    // Stop the cluster
-    TEST_UTIL.shutdownMiniCluster();
-    TEST_UTIL = new HBaseTestingUtility(resetConf);
-  }
-
-  @Test
-  public void testOpenedRegionHandlerOnMasterRestart() throws Exception {
-    // Start the cluster
-    log("Starting cluster");
-    conf = HBaseConfiguration.create();
-    conf.setBoolean("hbase.assignment.usezk", true);
-    resetConf = conf;
-    TEST_UTIL = new HBaseTestingUtility(conf);
-    TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
-    String tableName = "testOpenedRegionHandlerOnMasterRestart";
-    MiniHBaseCluster cluster = createRegions(tableName);
-    abortMaster(cluster);
-
-    HRegionServer regionServer = cluster.getRegionServer(0);
-    HRegion region = getRegionBeingServed(cluster, regionServer);
-
-    // forcefully move a region to OPENED state in zk
-    // Create a ZKW to use in the test
-    zkw = HBaseTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
-        region, regionServer.getServerName());
-
-    // Start up a new master
-    log("Starting up a new master");
-    cluster.startMaster().getMaster();
-    log("Waiting for master to be ready");
-    cluster.waitForActiveAndReadyMaster();
-    log("Master is ready");
-
-    // Failover should be completed, now wait for no RIT
-    log("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
-  }
-  @Test
-  public void 
testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches()
-      throws Exception {
-    HRegion region = null;
-    try {
-      int testIndex = 0;
-      TEST_UTIL.startMiniZKCluster();
-      final Server server = new MockServer(TEST_UTIL);
-      HTableDescriptor htd = new HTableDescriptor(
-          
TableName.valueOf("testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches"));
-      HRegionInfo hri = new HRegionInfo(htd.getTableName(),
-          Bytes.toBytes(testIndex), Bytes.toBytes(testIndex + 1));
-      region = HRegion.createHRegion(hri, TEST_UTIL.getDataTestDir(), 
TEST_UTIL.getConfiguration(), htd);
-      assertNotNull(region);
-      AssignmentManager am = Mockito.mock(AssignmentManager.class);
-      RegionStates rsm = Mockito.mock(RegionStates.class);
-      Mockito.doReturn(rsm).when(am).getRegionStates();
-      when(rsm.isRegionInTransition(hri)).thenReturn(false);
-      when(rsm.getRegionState(hri)).thenReturn(
-        new RegionState(region.getRegionInfo(), RegionState.State.OPEN,
-          System.currentTimeMillis(), server.getServerName()));
-      // create a node with OPENED state
-      zkw = HBaseTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
-          region, server.getServerName());
-      when(am.getTableStateManager()).thenReturn(new ZKTableStateManager(zkw));
-      Stat stat = new Stat();
-      String nodeName = ZKAssign.getNodeName(zkw, region.getRegionInfo()
-          .getEncodedName());
-      ZKUtil.getDataAndWatch(zkw, nodeName, stat);
-
-      // use the version for the OpenedRegionHandler
-      BaseCoordinatedStateManager csm = new ZkCoordinatedStateManager();
-      csm.initialize(server);
-      csm.start();
-
-      OpenRegionCoordination orc = csm.getOpenRegionCoordination();
-      ZkOpenRegionCoordination.ZkOpenRegionDetails zkOrd =
-        new ZkOpenRegionCoordination.ZkOpenRegionDetails();
-      zkOrd.setServerName(server.getServerName());
-      zkOrd.setVersion(stat.getVersion());
-      OpenedRegionHandler handler = new OpenedRegionHandler(server, am, region
-          .getRegionInfo(), orc, zkOrd);
-      // Once again overwrite the same znode so that the version changes.
-      ZKAssign.transitionNode(zkw, region.getRegionInfo(), server
-          .getServerName(), EventType.RS_ZK_REGION_OPENED,
-          EventType.RS_ZK_REGION_OPENED, stat.getVersion());
-
-      // Should not invoke assignmentmanager.regionOnline. If it is 
-      // invoked as per current mocking it will throw null pointer exception.
-      boolean expectedException = false;
-      try {
-        handler.process();
-      } catch (Exception e) {
-        expectedException = true;
-      }
-      assertFalse("The process method should not throw any exception.",
-          expectedException);
-      List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
-          zkw.assignmentZNode);
-      String regionName = znodes.get(0);
-      assertEquals("The region should not be opened successfully.", regionName,
-          region.getRegionInfo().getEncodedName());
-    } finally {
-      HRegion.closeHRegion(region);
-      TEST_UTIL.shutdownMiniZKCluster();
-    }
-  }
-  private MiniHBaseCluster createRegions(String tableName)
-      throws InterruptedException, ZooKeeperConnectionException, IOException,
-      KeeperException {
-    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-    log("Waiting for active/ready master");
-    cluster.waitForActiveAndReadyMaster();
-    zkw = new ZooKeeperWatcher(conf, "testOpenedRegionHandler", null);
-
-    // Create a table with regions
-    byte[] table = Bytes.toBytes(tableName);
-    byte[] family = Bytes.toBytes("family");
-    TEST_UTIL.createTable(table, family);
-
-    //wait till the regions are online
-    log("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
-
-    return cluster;
-  }
-  private void abortMaster(MiniHBaseCluster cluster) {
-    // Stop the master
-    log("Aborting master");
-    cluster.abortMaster(0);
-    cluster.waitOnMaster(0);
-    log("Master has aborted");
-  }
-  private HRegion getRegionBeingServed(MiniHBaseCluster cluster,
-      HRegionServer regionServer) {
-    Collection<HRegion> onlineRegionsLocalContext = regionServer
-        .getOnlineRegionsLocalContext();
-    Iterator<HRegion> iterator = onlineRegionsLocalContext.iterator();
-    HRegion region = null;
-    while (iterator.hasNext()) {
-      region = iterator.next();
-      if (!region.getRegionInfo().isMetaTable()) {
-        break;
-      }
-    }
-    return region;
-  }
-  private void log(String msg) {
-    LOG.debug("\n\nTRR: " + msg + "\n");
-  }
-
-}
-

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
index c5ed9e9..7fc00b5 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
@@ -28,15 +28,18 @@ import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.*;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.LargeTests;
+import org.apache.hadoop.hbase.MiniHBaseCluster;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableExistsException;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.MetaScanner;
-import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.JVMClusterUtil;
 import org.apache.hadoop.hbase.util.Threads;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -46,8 +49,6 @@ public class TestRestartCluster {
   private static final Log LOG = LogFactory.getLog(TestRestartCluster.class);
   private HBaseTestingUtility UTIL = new HBaseTestingUtility();
 
-  private static final byte[] TABLENAME = Bytes.toBytes("master_transitions");
-  private static final byte [][] FAMILIES = {Bytes.toBytes("a")};
   private static final byte [][] TABLES = {
       Bytes.toBytes("restartTableOne"),
       Bytes.toBytes("restartTableTwo"),
@@ -59,35 +60,6 @@ public class TestRestartCluster {
     UTIL.shutdownMiniCluster();
   }
 
-  @Test (timeout=300000) public void testRestartClusterAfterKill()
-  throws Exception {
-    UTIL.getConfiguration().setBoolean("hbase.assignment.usezk", true);
-    UTIL.startMiniZKCluster();
-    ZooKeeperWatcher zooKeeper =
-      new ZooKeeperWatcher(UTIL.getConfiguration(), "cluster1", null, true);
-
-    // create the unassigned region, throw up a region opened state for META
-    String unassignedZNode = zooKeeper.assignmentZNode;
-    ZKUtil.createAndFailSilent(zooKeeper, unassignedZNode);
-
-    ServerName sn = ServerName.valueOf(HMaster.MASTER, 1, 
System.currentTimeMillis());
-
-    ZKAssign.createNodeOffline(zooKeeper, HRegionInfo.FIRST_META_REGIONINFO, 
sn);
-
-    LOG.debug("Created UNASSIGNED zNode for ROOT and hbase:meta regions in 
state " +
-        EventType.M_ZK_REGION_OFFLINE);
-
-    // start the HB cluster
-    LOG.info("Starting HBase cluster...");
-    UTIL.startMiniCluster(2);
-
-    UTIL.createTable(TABLENAME, FAMILIES);
-    LOG.info("Created a table, waiting for table to be available...");
-    UTIL.waitTableAvailable(TABLENAME, 60*1000);
-
-    LOG.info("Master deleted unassigned region and started up successfully.");
-  }
-
   @Test (timeout=300000)
   public void testClusterRestart() throws Exception {
     UTIL.startMiniCluster(3);
@@ -153,8 +125,7 @@ public class TestRestartCluster {
     }
 
     HMaster master = UTIL.getMiniHBaseCluster().getMaster();
-    AssignmentManager am = master.getAssignmentManager();
-    am.waitUntilNoRegionsInTransition(120000);
+    UTIL.waitUntilNoRegionsInTransition(120000);
 
     // We don't have to use SnapshotOfRegionAssignmentFromMeta.
     // We use it here because AM used to use it to load all user region 
placements

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java
index d2ab764..8bdafda 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java
@@ -41,9 +41,6 @@ import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.zookeeper.KeeperException;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -72,9 +69,6 @@ public class  TestRollingRestart {
     MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
     log("Waiting for active/ready master");
     cluster.waitForActiveAndReadyMaster();
-    ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "testRollingRestart",
-        null);
-    HMaster master = cluster.getMaster();
 
     // Create a table with regions
     TableName table = TableName.valueOf("tableRestart");
@@ -85,11 +79,11 @@ public class  TestRollingRestart {
         NUM_REGIONS_TO_CREATE);
     numRegions += 1; // catalogs
     log("Waiting for no more RIT\n");
-    blockUntilNoRIT(zkw, master);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     log("Disabling table\n");
     TEST_UTIL.getHBaseAdmin().disableTable(table);
     log("Waiting for no more RIT\n");
-    blockUntilNoRIT(zkw, master);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     NavigableSet<String> regions = 
HBaseTestingUtility.getAllOnlineRegions(cluster);
     log("Verifying only catalog and namespace regions are assigned\n");
     if (regions.size() != 2) {
@@ -99,7 +93,7 @@ public class  TestRollingRestart {
     log("Enabling table\n");
     TEST_UTIL.getHBaseAdmin().enableTable(table);
     log("Waiting for no more RIT\n");
-    blockUntilNoRIT(zkw, master);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     log("Verifying there are " + numRegions + " assigned on cluster\n");
     regions = HBaseTestingUtility.getAllOnlineRegions(cluster);
     assertRegionsAssigned(cluster, regions);
@@ -112,7 +106,7 @@ public class  TestRollingRestart {
     restarted.waitForServerOnline();
     log("Additional RS is online");
     log("Waiting for no more RIT");
-    blockUntilNoRIT(zkw, master);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     log("Verifying there are " + numRegions + " assigned on cluster");
     assertRegionsAssigned(cluster, regions);
     assertEquals(expectedNumRS, cluster.getRegionServerThreads().size());
@@ -144,7 +138,6 @@ public class  TestRollingRestart {
     log("Restarting primary master\n\n");
     activeMaster = cluster.startMaster();
     cluster.waitForActiveAndReadyMaster();
-    master = activeMaster.getMaster();
 
     // Start backup master
     log("Restarting backup master\n\n");
@@ -168,7 +161,7 @@ public class  TestRollingRestart {
       log("Waiting for RS shutdown to be handled by master");
       waitForRSShutdownToStartAndFinish(activeMaster, serverName);
       log("RS shutdown done, waiting for no more RIT");
-      blockUntilNoRIT(zkw, master);
+      TEST_UTIL.waitUntilNoRegionsInTransition(60000);
       log("Verifying there are " + numRegions + " assigned on cluster");
       assertRegionsAssigned(cluster, regions);
       expectedNumRS--;
@@ -179,7 +172,7 @@ public class  TestRollingRestart {
       expectedNumRS++;
       log("Region server " + num + " is back online");
       log("Waiting for no more RIT");
-      blockUntilNoRIT(zkw, master);
+      TEST_UTIL.waitUntilNoRegionsInTransition(60000);
       log("Verifying there are " + numRegions + " assigned on cluster");
       assertRegionsAssigned(cluster, regions);
       assertEquals(expectedNumRS, cluster.getRegionServerThreads().size());
@@ -195,12 +188,6 @@ public class  TestRollingRestart {
     TEST_UTIL.shutdownMiniCluster();
   }
 
-  private void blockUntilNoRIT(ZooKeeperWatcher zkw, HMaster master)
-  throws KeeperException, InterruptedException {
-    ZKAssign.blockUntilNoRIT(zkw);
-    master.assignmentManager.waitUntilNoRegionsInTransition(60000);
-  }
-
   private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
       ServerName serverName) throws InterruptedException {
     ServerManager sm = activeMaster.getMaster().getServerManager();

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
deleted file mode 100644
index e684d1e..0000000
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/**
- *
- * 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.master;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.hbase.MiniHBaseCluster;
-import org.apache.hadoop.hbase.TableDescriptors;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.Durability;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
-import org.apache.hadoop.hbase.regionserver.HRegionServer;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.Threads;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-import org.mockito.internal.util.reflection.Whitebox;
-
-/**
- * Test open and close of regions using zk.
- */
-@Category(MediumTests.class)
-public class TestZKBasedOpenCloseRegion {
-  private static final Log LOG = 
LogFactory.getLog(TestZKBasedOpenCloseRegion.class);
-  private static final HBaseTestingUtility TEST_UTIL = new 
HBaseTestingUtility();
-  private static final TableName TABLENAME =
-      TableName.valueOf("TestZKBasedOpenCloseRegion");
-  private static final byte [][] FAMILIES = new byte [][] {Bytes.toBytes("a"),
-    Bytes.toBytes("b"), Bytes.toBytes("c")};
-  private static int countOfRegions;
-
-  @BeforeClass public static void beforeAllTests() throws Exception {
-    Configuration c = TEST_UTIL.getConfiguration();
-    c.setBoolean("hbase.assignment.usezk", true);
-    c.setBoolean("dfs.support.append", true);
-    c.setInt("hbase.regionserver.info.port", 0);
-    TEST_UTIL.startMiniCluster(2);
-    TEST_UTIL.createTable(TABLENAME, FAMILIES);
-    HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
-    countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
-    waitUntilAllRegionsAssigned();
-    addToEachStartKey(countOfRegions);
-    t.close();
-    
TEST_UTIL.getHBaseCluster().getMaster().assignmentManager.initializeHandlerTrackers();
-  }
-
-  @AfterClass public static void afterAllTests() throws Exception {
-    TEST_UTIL.shutdownMiniCluster();
-  }
-
-  @Before public void setup() throws IOException {
-    if (TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().size() < 2) {
-      // Need at least two servers.
-      LOG.info("Started new server=" +
-        TEST_UTIL.getHBaseCluster().startRegionServer());
-
-    }
-    waitUntilAllRegionsAssigned();
-    waitOnRIT();
-  }
-
-  /**
-   * Test we reopen a region once closed.
-   * @throws Exception
-   */
-  @Test (timeout=300000) public void testReOpenRegion()
-  throws Exception {
-    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-    LOG.info("Number of region servers = " +
-      cluster.getLiveRegionServerThreads().size());
-
-    int rsIdx = 0;
-    HRegionServer regionServer =
-      TEST_UTIL.getHBaseCluster().getRegionServer(rsIdx);
-    HRegionInfo hri = getNonMetaRegion(
-      ProtobufUtil.getOnlineRegions(regionServer.getRSRpcServices()));
-    LOG.debug("Asking RS to close region " + hri.getRegionNameAsString());
-
-    LOG.info("Unassign " + hri.getRegionNameAsString());
-    cluster.getMaster().assignmentManager.unassign(hri);
-
-    while (!cluster.getMaster().assignmentManager.wasClosedHandlerCalled(hri)) 
{
-      Threads.sleep(100);
-    }
-
-    while (!cluster.getMaster().assignmentManager.wasOpenedHandlerCalled(hri)) 
{
-      Threads.sleep(100);
-    }
-
-    LOG.info("Done with testReOpenRegion");
-  }
-
-  private HRegionInfo getNonMetaRegion(final Collection<HRegionInfo> regions) {
-    HRegionInfo hri = null;
-    for (HRegionInfo i: regions) {
-      LOG.info(i.getRegionNameAsString());
-      if (!i.isMetaRegion()) {
-        hri = i;
-        break;
-      }
-    }
-    return hri;
-  }
-
-  /**
-   * This test shows how a region won't be able to be assigned to a RS
-   * if it's already "processing" it.
-   * @throws Exception
-   */
-  @Test
-  public void testRSAlreadyProcessingRegion() throws Exception {
-    LOG.info("starting testRSAlreadyProcessingRegion");
-    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-
-    HRegionServer hr0 =
-        cluster.getLiveRegionServerThreads().get(0).getRegionServer();
-    HRegionServer hr1 =
-        cluster.getLiveRegionServerThreads().get(1).getRegionServer();
-    HRegionInfo hri = 
getNonMetaRegion(ProtobufUtil.getOnlineRegions(hr0.getRSRpcServices()));
-
-    // fake that hr1 is processing the region
-    hr1.getRegionsInTransitionInRS().putIfAbsent(hri.getEncodedNameAsBytes(), 
true);
-
-    // now ask the master to move the region to hr1, will fail
-    TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
-        Bytes.toBytes(hr1.getServerName().toString()));
-
-    // make sure the region came back
-    assertEquals(hr1.getOnlineRegion(hri.getEncodedNameAsBytes()), null);
-
-    // remove the block and reset the boolean
-    hr1.getRegionsInTransitionInRS().remove(hri.getEncodedNameAsBytes());
-
-    // now try moving a region when there is no region in transition.
-    hri = 
getNonMetaRegion(ProtobufUtil.getOnlineRegions(hr1.getRSRpcServices()));
-
-    TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
-        Bytes.toBytes(hr0.getServerName().toString()));
-
-    while (!cluster.getMaster().assignmentManager.wasOpenedHandlerCalled(hri)) 
{
-      Threads.sleep(100);
-    }
-
-    // make sure the region has moved from the original RS
-    assertTrue(hr1.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);
-
-  }
-
-  private void waitOnRIT() {
-    // Close worked but we are going to open the region elsewhere.  Before 
going on, make sure
-    // this completes.
-    while (TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
-        getRegionStates().isRegionsInTransition()) {
-      LOG.info("Waiting on regions in transition: " +
-        TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
-          getRegionStates().getRegionsInTransition());
-      Threads.sleep(10);
-    }
-  }
-
-  /**
-   * If region open fails with IOException in openRegion() while doing 
tableDescriptors.get()
-   * the region should not add into regionsInTransitionInRS map
-   * @throws Exception
-   */
-  @Test
-  public void testRegionOpenFailsDueToIOException() throws Exception {
-    HRegionInfo REGIONINFO = new HRegionInfo(TableName.valueOf("t"),
-        HConstants.EMPTY_START_ROW, HConstants.EMPTY_START_ROW);
-    HRegionServer regionServer = 
TEST_UTIL.getHBaseCluster().getRegionServer(0);
-    TableDescriptors htd = Mockito.mock(TableDescriptors.class);
-    Object orizinalState = 
Whitebox.getInternalState(regionServer,"tableDescriptors");
-    Whitebox.setInternalState(regionServer, "tableDescriptors", htd);
-    Mockito.doThrow(new IOException()).when(htd).get((TableName) 
Mockito.any());
-    try {
-      ProtobufUtil.openRegion(regionServer.getRSRpcServices(),
-        regionServer.getServerName(), REGIONINFO);
-      fail("It should throw IOException ");
-    } catch (IOException e) {
-    }
-    Whitebox.setInternalState(regionServer, "tableDescriptors", orizinalState);
-    assertFalse("Region should not be in RIT",
-        
regionServer.getRegionsInTransitionInRS().containsKey(REGIONINFO.getEncodedNameAsBytes()));
-  }
-
-  private static void waitUntilAllRegionsAssigned()
-  throws IOException {
-    HTable meta = new HTable(TEST_UTIL.getConfiguration(), 
TableName.META_TABLE_NAME);
-    while (true) {
-      int rows = 0;
-      Scan scan = new Scan();
-      scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
-      ResultScanner s = meta.getScanner(scan);
-      for (Result r = null; (r = s.next()) != null;) {
-        byte [] b =
-          r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
-        if (b == null || b.length <= 0) {
-          break;
-        }
-        rows++;
-      }
-      s.close();
-      // If I get to here and all rows have a Server, then all have been 
assigned.
-      if (rows >= countOfRegions) {
-        break;
-      }
-      LOG.info("Found=" + rows);
-      Threads.sleep(1000);
-    }
-    meta.close();
-  }
-
-  /*
-   * Add to each of the regions in hbase:meta a value.  Key is the startrow of 
the
-   * region (except its 'aaa' for first region).  Actual value is the row name.
-   * @param expected
-   * @return
-   * @throws IOException
-   */
-  private static int addToEachStartKey(final int expected) throws IOException {
-    HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
-    HTable meta = new HTable(TEST_UTIL.getConfiguration(),
-        TableName.META_TABLE_NAME);
-    int rows = 0;
-    Scan scan = new Scan();
-    scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    ResultScanner s = meta.getScanner(scan);
-    for (Result r = null; (r = s.next()) != null;) {
-      HRegionInfo hri = HRegionInfo.getHRegionInfo(r);
-      if (hri == null) break;
-      if(!hri.getTable().equals(TABLENAME)) {
-        continue;
-      }
-      // If start key, add 'aaa'.
-      byte [] row = getStartKey(hri);
-      Put p = new Put(row);
-      p.setDurability(Durability.SKIP_WAL);
-      p.add(getTestFamily(), getTestQualifier(), row);
-      t.put(p);
-      rows++;
-    }
-    s.close();
-    Assert.assertEquals(expected, rows);
-    t.close();
-    meta.close();
-    return rows;
-  }
-
-  private static byte [] getStartKey(final HRegionInfo hri) {
-    return Bytes.equals(HConstants.EMPTY_START_ROW, hri.getStartKey())?
-        Bytes.toBytes("aaa"): hri.getStartKey();
-  }
-
-  private static byte [] getTestFamily() {
-    return FAMILIES[0];
-  }
-
-  private static byte [] getTestQualifier() {
-    return getTestFamily();
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKLessAMOnCluster.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKLessAMOnCluster.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKLessAMOnCluster.java
deleted file mode 100644
index 83d33c5..0000000
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKLessAMOnCluster.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.master;
-
-import org.apache.hadoop.hbase.MediumTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.experimental.categories.Category;
-
-/**
- * This tests AssignmentManager with a testing cluster.
- */
-@Category(MediumTests.class)
-public class TestZKLessAMOnCluster extends TestAssignmentManagerOnCluster {
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
-    // Don't use ZK for region assignment
-    conf.setBoolean("hbase.assignment.usezk", false);
-    setupOnce();
-  }
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-    TestAssignmentManagerOnCluster.tearDownAfterClass();
-  }
-}

Reply via email to