Repository: hbase
Updated Branches:
  refs/heads/master e17a3ca09 -> 17dff6818


http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java
deleted file mode 100644
index 2990014..0000000
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java
+++ /dev/null
@@ -1,255 +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.regionserver.handler;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.hbase.RegionTransition;
-import org.apache.hadoop.hbase.Server;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.coordination.OpenRegionCoordination;
-import org.apache.hadoop.hbase.coordination.ZkCoordinatedStateManager;
-import org.apache.hadoop.hbase.exceptions.DeserializationException;
-import org.apache.hadoop.hbase.executor.EventType;
-import org.apache.hadoop.hbase.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.RegionServerServices;
-import org.apache.hadoop.hbase.coordination.ZkCloseRegionCoordination;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.MockServer;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.NodeExistsException;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-
-/**
- * Test of the {@link CloseRegionHandler}.
- */
-@Category(MediumTests.class)
-public class TestCloseRegionHandler {
-  static final Log LOG = LogFactory.getLog(TestCloseRegionHandler.class);
-  private final static HBaseTestingUtility HTU = 
HBaseTestingUtility.createLocalHTU();
-  private static final HTableDescriptor TEST_HTD =
-    new HTableDescriptor(TableName.valueOf("TestCloseRegionHandler"));
-  private HRegionInfo TEST_HRI;
-  private int testIndex = 0;
-
-  @BeforeClass public static void before() throws Exception {
-    HTU.getConfiguration().setBoolean("hbase.assignment.usezk", true);
-    HTU.startMiniZKCluster();
-  }
-
-  @AfterClass public static void after() throws IOException {
-    HTU.shutdownMiniZKCluster();
-  }
-
-  /**
-   * Before each test, use a different HRI, so the different tests
-   * don't interfere with each other. This allows us to use just
-   * a single ZK cluster for the whole suite.
-   */
-  @Before
-  public void setupHRI() {
-    TEST_HRI = new HRegionInfo(TEST_HTD.getTableName(),
-      Bytes.toBytes(testIndex),
-      Bytes.toBytes(testIndex + 1));
-    testIndex++;
-  }
-
-  /**
-   * Test that if we fail a flush, abort gets set on close.
-   * @see <a 
href="https://issues.apache.org/jira/browse/HBASE-4270";>HBASE-4270</a>
-   * @throws IOException
-   * @throws NodeExistsException
-   * @throws KeeperException
-   */
-  @Test public void testFailedFlushAborts()
-  throws IOException, NodeExistsException, KeeperException {
-    final Server server = new MockServer(HTU, false);
-    final RegionServerServices rss = HTU.createMockRegionServerService();
-    HTableDescriptor htd = TEST_HTD;
-    final HRegionInfo hri =
-      new HRegionInfo(htd.getTableName(), HConstants.EMPTY_END_ROW,
-        HConstants.EMPTY_END_ROW);
-    HRegion region = HTU.createLocalHRegion(hri,  htd);
-    try {
-      assertNotNull(region);
-      // Spy on the region so can throw exception when close is called.
-      HRegion spy = Mockito.spy(region);
-      final boolean abort = false;
-      Mockito.when(spy.close(abort)).
-      thenThrow(new IOException("Mocked failed close!"));
-      // The CloseRegionHandler will try to get an HRegion that corresponds
-      // to the passed hri -- so insert the region into the online region Set.
-      rss.addToOnlineRegions(spy);
-      // Assert the Server is NOT stopped before we call close region.
-      assertFalse(server.isStopped());
-
-      ZkCoordinatedStateManager consensusProvider = new 
ZkCoordinatedStateManager();
-      consensusProvider.initialize(server);
-      consensusProvider.start();
-
-      ZkCloseRegionCoordination.ZkCloseRegionDetails zkCrd =
-        new ZkCloseRegionCoordination.ZkCloseRegionDetails();
-      zkCrd.setPublishStatusInZk(false);
-      zkCrd.setExpectedVersion(-1);
-
-      CloseRegionHandler handler = new CloseRegionHandler(server, rss, hri, 
false,
-            consensusProvider.getCloseRegionCoordination(), zkCrd);
-      boolean throwable = false;
-      try {
-        handler.process();
-      } catch (Throwable t) {
-        throwable = true;
-      } finally {
-        assertTrue(throwable);
-        // Abort calls stop so stopped flag should be set.
-        assertTrue(server.isStopped());
-      }
-    } finally {
-      HRegion.closeHRegion(region);
-    }
-  }
-
-     /**
-      * Test if close region can handle ZK closing node version mismatch
-      * @throws IOException
-      * @throws NodeExistsException
-      * @throws KeeperException
-     * @throws DeserializationException
-      */
-     @Test public void testZKClosingNodeVersionMismatch()
-     throws IOException, NodeExistsException, KeeperException, 
DeserializationException {
-       final Server server = new MockServer(HTU);
-       final RegionServerServices rss = HTU.createMockRegionServerService();
-
-       HTableDescriptor htd = TEST_HTD;
-       final HRegionInfo hri = TEST_HRI;
-
-       ZkCoordinatedStateManager coordinationProvider = new 
ZkCoordinatedStateManager();
-       coordinationProvider.initialize(server);
-       coordinationProvider.start();
-
-       // open a region first so that it can be closed later
-       OpenRegion(server, rss, htd, hri, 
coordinationProvider.getOpenRegionCoordination());
-
-       // close the region
-       // Create it CLOSING, which is what Master set before sending CLOSE RPC
-       int versionOfClosingNode = 
ZKAssign.createNodeClosing(server.getZooKeeper(),
-         hri, server.getServerName());
-
-       // The CloseRegionHandler will validate the expected version
-       // Given it is set to invalid versionOfClosingNode+1,
-       // CloseRegionHandler should be M_ZK_REGION_CLOSING
-
-       ZkCloseRegionCoordination.ZkCloseRegionDetails zkCrd =
-         new ZkCloseRegionCoordination.ZkCloseRegionDetails();
-       zkCrd.setPublishStatusInZk(true);
-       zkCrd.setExpectedVersion(versionOfClosingNode+1);
-
-       CloseRegionHandler handler = new CloseRegionHandler(server, rss, hri, 
false,
-         coordinationProvider.getCloseRegionCoordination(), zkCrd);
-       handler.process();
-
-       // Handler should remain in M_ZK_REGION_CLOSING
-       RegionTransition rt =
-         RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(), 
hri.getEncodedName()));
-       assertTrue(rt.getEventType().equals(EventType.M_ZK_REGION_CLOSING ));
-     }
-
-     /**
-      * Test if the region can be closed properly
-      * @throws IOException
-      * @throws NodeExistsException
-      * @throws KeeperException
-     * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
-      */
-     @Test public void testCloseRegion()
-     throws IOException, NodeExistsException, KeeperException, 
DeserializationException {
-       final Server server = new MockServer(HTU);
-       final RegionServerServices rss = HTU.createMockRegionServerService();
-
-       HTableDescriptor htd = TEST_HTD;
-       HRegionInfo hri = TEST_HRI;
-
-       ZkCoordinatedStateManager coordinationProvider = new 
ZkCoordinatedStateManager();
-       coordinationProvider.initialize(server);
-       coordinationProvider.start();
-
-       // open a region first so that it can be closed later
-       OpenRegion(server, rss, htd, hri, 
coordinationProvider.getOpenRegionCoordination());
-
-       // close the region
-       // Create it CLOSING, which is what Master set before sending CLOSE RPC
-       int versionOfClosingNode = 
ZKAssign.createNodeClosing(server.getZooKeeper(),
-         hri, server.getServerName());
-
-       // The CloseRegionHandler will validate the expected version
-       // Given it is set to correct versionOfClosingNode,
-       // CloseRegionHandlerit should be RS_ZK_REGION_CLOSED
-
-       ZkCloseRegionCoordination.ZkCloseRegionDetails zkCrd =
-         new ZkCloseRegionCoordination.ZkCloseRegionDetails();
-       zkCrd.setPublishStatusInZk(true);
-       zkCrd.setExpectedVersion(versionOfClosingNode);
-
-       CloseRegionHandler handler = new CloseRegionHandler(server, rss, hri, 
false,
-         coordinationProvider.getCloseRegionCoordination(), zkCrd);
-       handler.process();
-       // Handler should have transitioned it to RS_ZK_REGION_CLOSED
-       RegionTransition rt = RegionTransition.parseFrom(
-         ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName()));
-       assertTrue(rt.getEventType().equals(EventType.RS_ZK_REGION_CLOSED));
-     }
-
-     private void OpenRegion(Server server, RegionServerServices rss,
-         HTableDescriptor htd, HRegionInfo hri, OpenRegionCoordination 
coordination)
-     throws IOException, NodeExistsException, KeeperException, 
DeserializationException {
-       // Create it OFFLINE node, which is what Master set before sending OPEN 
RPC
-       ZKAssign.createNodeOffline(server.getZooKeeper(), hri, 
server.getServerName());
-
-       OpenRegionCoordination.OpenRegionDetails ord =
-         coordination.getDetailsForNonCoordinatedOpening();
-       OpenRegionHandler openHandler =
-         new OpenRegionHandler(server, rss, hri, htd, coordination, ord);
-       rss.getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), 
Boolean.TRUE);
-       openHandler.process();
-       // This parse is not used?
-       RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(), 
hri.getEncodedName()));
-       // delete the node, which is what Master do after the region is opened
-       ZKAssign.deleteNode(server.getZooKeeper(), hri.getEncodedName(),
-         EventType.RS_ZK_REGION_OPENED, server.getServerName());
-     }
-
-}
-

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
deleted file mode 100644
index d472d57..0000000
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
+++ /dev/null
@@ -1,360 +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.regionserver.handler;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.*;
-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.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.RegionServerServices;
-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.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.NodeExistsException;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * Test of the {@link OpenRegionHandler}.
- */
-@Category(MediumTests.class)
-public class TestOpenRegionHandler {
-  static final Log LOG = LogFactory.getLog(TestOpenRegionHandler.class);
-  private final static HBaseTestingUtility HTU = 
HBaseTestingUtility.createLocalHTU();
-  private static HTableDescriptor TEST_HTD;
-  private HRegionInfo TEST_HRI;
-
-  private int testIndex = 0;
-
-  @BeforeClass public static void before() throws Exception {
-    HTU.getConfiguration().setBoolean("hbase.assignment.usezk", true);
-    HTU.startMiniZKCluster();
-    TEST_HTD = new 
HTableDescriptor(TableName.valueOf("TestOpenRegionHandler.java"));
-  }
-
-  @AfterClass public static void after() throws IOException {
-    TEST_HTD = null;
-    HTU.shutdownMiniZKCluster();
-  }
-
-  /**
-   * Before each test, use a different HRI, so the different tests
-   * don't interfere with each other. This allows us to use just
-   * a single ZK cluster for the whole suite.
-   */
-  @Before
-  public void setupHRI() {
-    TEST_HRI = new HRegionInfo(TEST_HTD.getTableName(),
-      Bytes.toBytes(testIndex),
-      Bytes.toBytes(testIndex + 1));
-    testIndex++;
-  }
-
-  /**
-   * Test the openregionhandler can deal with its znode being yanked out from
-   * under it.
-   * @see <a 
href="https://issues.apache.org/jira/browse/HBASE-3627";>HBASE-3627</a>
-   * @throws IOException
-   * @throws NodeExistsException
-   * @throws KeeperException
-   */
-  @Test public void testYankingRegionFromUnderIt()
-  throws IOException, NodeExistsException, KeeperException {
-    final Server server = new MockServer(HTU);
-    final RegionServerServices rss = HTU.createMockRegionServerService();
-
-    HTableDescriptor htd = TEST_HTD;
-    final HRegionInfo hri = TEST_HRI;
-    HRegion region =
-         HRegion.createHRegion(hri, HTU.getDataTestDir(), HTU
-            .getConfiguration(), htd);
-    assertNotNull(region);
-    try {
-      ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
-      csm.initialize(server);
-      csm.start();
-
-      ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
-        new ZkOpenRegionCoordination.ZkOpenRegionDetails();
-      zkCrd.setServerName(server.getServerName());
-
-      OpenRegionHandler handler = new OpenRegionHandler(server, rss, hri,
-        htd, csm.getOpenRegionCoordination(), zkCrd) {
-        HRegion openRegion() {
-          // Open region first, then remove znode as though it'd been hijacked.
-          HRegion region = super.openRegion();
-
-          // Don't actually open region BUT remove the znode as though it'd
-          // been hijacked on us.
-          ZooKeeperWatcher zkw = this.server.getZooKeeper();
-          String node = ZKAssign.getNodeName(zkw, hri.getEncodedName());
-          try {
-            ZKUtil.deleteNodeFailSilent(zkw, node);
-          } catch (KeeperException e) {
-            throw new RuntimeException("Ugh failed delete of " + node, e);
-          }
-          return region;
-        }
-      };
-      rss.getRegionsInTransitionInRS().put(
-        hri.getEncodedNameAsBytes(), Boolean.TRUE);
-      // Call process without first creating OFFLINE region in zk, see if
-      // exception or just quiet return (expected).
-      handler.process();
-      rss.getRegionsInTransitionInRS().put(
-        hri.getEncodedNameAsBytes(), Boolean.TRUE);
-      ZKAssign.createNodeOffline(server.getZooKeeper(), hri, 
server.getServerName());
-      // Call process again but this time yank the zk znode out from under it
-      // post OPENING; again will expect it to come back w/o NPE or exception.
-      handler.process();
-    } finally {
-      HRegion.closeHRegion(region);
-    }
-  }
-  
-  /**
-   * Test the openregionhandler can deal with perceived failure of 
transitioning to OPENED state
-   * due to intermittent zookeeper malfunctioning.
-   * @see <a 
href="https://issues.apache.org/jira/browse/HBASE-9387";>HBASE-9387</a>
-   * @throws IOException
-   * @throws NodeExistsException
-   * @throws KeeperException
-   */
-  @Test
-  public void testRegionServerAbortionDueToFailureTransitioningToOpened()
-      throws IOException, NodeExistsException, KeeperException {
-    final Server server = new MockServer(HTU);
-    final RegionServerServices rss = HTU.createMockRegionServerService();
-
-    HTableDescriptor htd = TEST_HTD;
-    final HRegionInfo hri = TEST_HRI;
-    HRegion region =
-         HRegion.createHRegion(hri, HTU.getDataTestDir(), HTU
-            .getConfiguration(), htd);
-    assertNotNull(region);
-    try {
-
-      ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
-      csm.initialize(server);
-      csm.start();
-
-      ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
-        new ZkOpenRegionCoordination.ZkOpenRegionDetails();
-      zkCrd.setServerName(server.getServerName());
-
-      ZkOpenRegionCoordination openRegionCoordination =
-        new ZkOpenRegionCoordination(csm, server.getZooKeeper()) {
-        @Override
-        public boolean transitionToOpened(final HRegion r, OpenRegionDetails 
ord)
-            throws IOException {
-          // remove znode simulating intermittent zookeeper connection issue
-          ZooKeeperWatcher zkw = server.getZooKeeper();
-          String node = ZKAssign.getNodeName(zkw, hri.getEncodedName());
-          try {
-            ZKUtil.deleteNodeFailSilent(zkw, node);
-          } catch (KeeperException e) {
-            throw new RuntimeException("Ugh failed delete of " + node, e);
-          }
-          // then try to transition to OPENED
-          return super.transitionToOpened(r, ord);
-        }
-      };
-
-      OpenRegionHandler handler = new OpenRegionHandler(server, rss, hri, htd,
-        openRegionCoordination, zkCrd);
-      rss.getRegionsInTransitionInRS().put(
-        hri.getEncodedNameAsBytes(), Boolean.TRUE);
-      // Call process without first creating OFFLINE region in zk, see if
-      // exception or just quiet return (expected).
-      handler.process();
-      rss.getRegionsInTransitionInRS().put(
-        hri.getEncodedNameAsBytes(), Boolean.TRUE);
-      ZKAssign.createNodeOffline(server.getZooKeeper(), hri, 
server.getServerName());
-      // Call process again but this time yank the zk znode out from under it
-      // post OPENING; again will expect it to come back w/o NPE or exception.
-      handler.process();
-    } catch (IOException ioe) {
-    } finally {
-      HRegion.closeHRegion(region);
-    }
-    // Region server is expected to abort due to OpenRegionHandler perceiving 
transitioning
-    // to OPENED as failed
-    // This was corresponding to the second handler.process() call above.
-    assertTrue("region server should have aborted", server.isAborted());
-  }
-  
-  @Test
-  public void testFailedOpenRegion() throws Exception {
-    Server server = new MockServer(HTU);
-    RegionServerServices rsServices = HTU.createMockRegionServerService();
-
-    // Create it OFFLINE, which is what it expects
-    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, 
server.getServerName());
-
-    ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
-    csm.initialize(server);
-    csm.start();
-
-    ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
-      new ZkOpenRegionCoordination.ZkOpenRegionDetails();
-    zkCrd.setServerName(server.getServerName());
-
-    // Create the handler
-    OpenRegionHandler handler =
-      new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD,
-        csm.getOpenRegionCoordination(), zkCrd) {
-        @Override
-        HRegion openRegion() {
-          // Fake failure of opening a region due to an IOE, which is caught
-          return null;
-        }
-    };
-    rsServices.getRegionsInTransitionInRS().put(
-      TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);
-    handler.process();
-
-    // Handler should have transitioned it to FAILED_OPEN
-    RegionTransition rt = RegionTransition.parseFrom(
-      ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName()));
-    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
-  }
-  
-  @Test
-  public void testFailedUpdateMeta() throws Exception {
-    Server server = new MockServer(HTU);
-    RegionServerServices rsServices = HTU.createMockRegionServerService();
-
-    // Create it OFFLINE, which is what it expects
-    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, 
server.getServerName());
-
-    // Create the handler
-    ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
-    csm.initialize(server);
-    csm.start();
-
-    ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
-      new ZkOpenRegionCoordination.ZkOpenRegionDetails();
-    zkCrd.setServerName(server.getServerName());
-
-    OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, 
TEST_HRI, TEST_HTD,
-      csm.getOpenRegionCoordination(), zkCrd) {
-        @Override
-        boolean updateMeta(final HRegion r) {
-          // Fake failure of updating META
-          return false;
-        }
-    };
-    rsServices.getRegionsInTransitionInRS().put(
-      TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);
-    handler.process();
-
-    // Handler should have transitioned it to FAILED_OPEN
-    RegionTransition rt = RegionTransition.parseFrom(
-      ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName()));
-    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
-  }
-  
-  @Test
-  public void testTransitionToFailedOpenEvenIfCleanupFails() throws Exception {
-    Server server = new MockServer(HTU);
-    RegionServerServices rsServices = HTU.createMockRegionServerService();
-    // Create it OFFLINE, which is what it expects
-    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, 
server.getServerName());
-    // Create the handler
-    ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
-    csm.initialize(server);
-    csm.start();
-
-    ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
-      new ZkOpenRegionCoordination.ZkOpenRegionDetails();
-    zkCrd.setServerName(server.getServerName());
-
-    OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, 
TEST_HRI, TEST_HTD,
-      csm.getOpenRegionCoordination(), zkCrd) {
-      @Override
-      boolean updateMeta(HRegion r) {
-        return false;
-      };
-
-      @Override
-      void cleanupFailedOpen(HRegion region) throws IOException {
-        throw new IOException("FileSystem got closed.");
-      }
-    };
-    
rsServices.getRegionsInTransitionInRS().put(TEST_HRI.getEncodedNameAsBytes(), 
Boolean.TRUE);
-    try {
-      handler.process();
-    } catch (Exception e) {
-      // Ignore the IOException that we have thrown from cleanupFailedOpen
-    }
-    RegionTransition rt = 
RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(),
-        TEST_HRI.getEncodedName()));
-    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
-  }
-
-  @Test
-  public void testTransitionToFailedOpenFromOffline() throws Exception {
-    Server server = new MockServer(HTU);
-    RegionServerServices rsServices = 
HTU.createMockRegionServerService(server.getServerName());
-    // Create it OFFLINE, which is what it expects
-    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, 
server.getServerName());
-    // Create the handler
-    ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
-    csm.initialize(server);
-    csm.start();
-
-    ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
-      new ZkOpenRegionCoordination.ZkOpenRegionDetails();
-    zkCrd.setServerName(server.getServerName());
-
-    ZkOpenRegionCoordination openRegionCoordination =
-      new ZkOpenRegionCoordination(csm, server.getZooKeeper()) {
-      @Override
-      public boolean transitionFromOfflineToOpening(HRegionInfo regionInfo,
-                                                    OpenRegionDetails ord) {
-        return false;
-      }
-    };
-
-    OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, 
TEST_HRI, TEST_HTD,
-      openRegionCoordination, zkCrd);
-    
rsServices.getRegionsInTransitionInRS().put(TEST_HRI.getEncodedNameAsBytes(), 
Boolean.TRUE);
-
-    handler.process();
-
-    RegionTransition rt = 
RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(),
-        TEST_HRI.getEncodedName()));
-    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
-  }
-
-}
-

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildBase.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildBase.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildBase.java
index 7a075a6..409b618 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildBase.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildBase.java
@@ -29,17 +29,15 @@ import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.client.HConnectionManager;
 import org.apache.hadoop.hbase.util.HBaseFsck;
 import org.apache.hadoop.hbase.util.HBaseFsck.ErrorReporter.ERROR_CODE;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
 /**
  * This builds a table, removes info from meta, and then rebuilds meta.
  */
 @Category(MediumTests.class)
 public class TestOfflineMetaRebuildBase extends OfflineMetaRebuildTestCore {
 
+  @SuppressWarnings("deprecation")
   @Test(timeout = 120000)
   public void testMetaRebuild() throws Exception {
     wipeOutMeta();
@@ -68,10 +66,9 @@ public class TestOfflineMetaRebuildBase extends 
OfflineMetaRebuildTestCore {
     TEST_UTIL.startMiniZKCluster();
     TEST_UTIL.restartHBaseCluster(3);
     TEST_UTIL.getHBaseAdmin().enableTable(table);
-    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
-    
+
     LOG.info("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     LOG.info("No more RIT in ZK, now doing final test verification");
 
     // everything is good again.

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildHole.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildHole.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildHole.java
index a3225bd..6ebfcd7 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildHole.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildHole.java
@@ -24,13 +24,10 @@ import static org.junit.Assert.assertFalse;
 
 import java.util.Arrays;
 
-import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.util.HBaseFsck;
 import org.apache.hadoop.hbase.util.HBaseFsck.ErrorReporter.ERROR_CODE;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -71,10 +68,8 @@ public class TestOfflineMetaRebuildHole extends 
OfflineMetaRebuildTestCore {
     TEST_UTIL.startMiniZKCluster(); // tables seem enabled by default
     TEST_UTIL.restartHBaseCluster(3);
 
-    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
-
     LOG.info("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     LOG.info("No more RIT in ZK, now doing final test verification");
     int tries = 60;
     while(TEST_UTIL.getHBaseCluster()

http://git-wip-us.apache.org/repos/asf/hbase/blob/17dff681/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildOverlap.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildOverlap.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildOverlap.java
index 9a17948..b7114d1 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildOverlap.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/TestOfflineMetaRebuildOverlap.java
@@ -24,14 +24,11 @@ import static org.junit.Assert.assertFalse;
 
 import java.util.Arrays;
 
-import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.util.HBaseFsck;
 import org.apache.hadoop.hbase.util.HBaseFsck.ErrorReporter.ERROR_CODE;
 import org.apache.hadoop.hbase.util.HBaseFsck.HbckInfo;
-import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -80,10 +77,8 @@ public class TestOfflineMetaRebuildOverlap extends 
OfflineMetaRebuildTestCore {
     TEST_UTIL.startMiniZKCluster(); // tables seem enabled by default
     TEST_UTIL.restartHBaseCluster(3);
 
-    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
-
     LOG.info("Waiting for no more RIT");
-    ZKAssign.blockUntilNoRIT(zkw);
+    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
     LOG.info("No more RIT in ZK, now doing final test verification");
     int tries = 60;
     while(TEST_UTIL.getHBaseCluster()

Reply via email to