Package org.apache.hadoop.hbase.regionserver

Examples of org.apache.hadoop.hbase.regionserver.RegionServerServices


   */
  @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 {
      OpenRegionHandler handler = new OpenRegionHandler(server, rss, hri, htd) {
        boolean transitionToOpened(final HRegion r) throws IOException {
          // remove znode simulating intermittent zookeeper connection issue
          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);
          }
          // then try to transition to OPENED
          return super.transitionToOpened(r);
        }
      };
      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", rss.isAborted());
  }
View Full Code Here


  }
 
  @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());

    // Create the handler
    OpenRegionHandler handler =
      new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {
        @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(
View Full Code Here

  }
 
  @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
    OpenRegionHandler handler =
      new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {
        @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(
View Full Code Here

  }
 
  @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
    OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {
      @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
    }
View Full Code Here

  }

  @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
    OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {

      @Override
      boolean transitionZookeeperOfflineToOpening(String encodedName, int versionOfOfflineNode) {
        return false;
      }
    };
    rsServices.getRegionsInTransitionInRS().put(TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);

    handler.process();

    RegionTransition rt = RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(),
        TEST_HRI.getEncodedName()));
View Full Code Here

    region3.getLog().closeAndDelete();
    // Write countPerFamily edits into the three families. Do a flush on one
    // of the families during the load of edits so its seqid is not same as
    // others to test we do right thing when different seqids.
    HLog wal = createWAL(this.conf);
    RegionServerServices rsServices = Mockito.mock(RegionServerServices.class);
    Mockito.doReturn(false).when(rsServices).isAborted();
    Configuration customConf = new Configuration(this.conf);
    customConf.set(DefaultStoreEngine.DEFAULT_STORE_FLUSHER_CLASS_KEY,
        CustomStoreFlusher.class.getName());
    HRegion region = new HRegion(basedir, wal, this.fs, customConf, hri, htd, rsServices);
View Full Code Here

      throws IOException {
    HConnection connection = HConnectionManager.createConnection(env.getConfiguration());
    // this bit is a little hacky - just trying to get it going for the moment
    if (env instanceof RegionCoprocessorEnvironment) {
      RegionCoprocessorEnvironment e = (RegionCoprocessorEnvironment) env;
      RegionServerServices services = e.getRegionServerServices();
      if (services instanceof HRegionServer) {
        return new CoprocessorHConnection(connection, (HRegionServer) services);
      }
    }
    return connection;
View Full Code Here

   * @throws KeeperException
   */
  @Test public void testYankingRegionFromUnderIt()
  throws IOException, NodeExistsException, KeeperException {
    final Server server = new MockServer(HTU);
    final RegionServerServices rss = new MockRegionServerServices();

    HTableDescriptor htd = TEST_HTD;
    final HRegionInfo hri = TEST_HRI;
    HRegion region =
         HRegion.createHRegion(hri, HTU.getDataTestDir(), HTU
View Full Code Here

  }
 
  @Test
  public void testFailedOpenRegion() throws Exception {
    Server server = new MockServer(HTU);
    RegionServerServices rsServices = new MockRegionServerServices();

    // Create it OFFLINE, which is what it expects
    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());

    // Create the handler
View Full Code Here

  }
 
  @Test
  public void testFailedUpdateMeta() throws Exception {
    Server server = new MockServer(HTU);
    RegionServerServices rsServices = new MockRegionServerServices();

    // Create it OFFLINE, which is what it expects
    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());

    // Create the handler
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.RegionServerServices

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.