当前位置: 首页>>代码示例>>Java>>正文


Java OpenRegionHandler类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler的典型用法代码示例。如果您正苦于以下问题:Java OpenRegionHandler类的具体用法?Java OpenRegionHandler怎么用?Java OpenRegionHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OpenRegionHandler类属于org.apache.hadoop.hbase.regionserver.handler包,在下文中一共展示了OpenRegionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCancelOpeningWithoutZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test that if we do a close while opening it stops the opening.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithoutZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
  }

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());
  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // The open handler should have updated the value in ZK.
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeperWatcher(), hri.getEncodedName(),
      EventType.RS_ZK_REGION_FAILED_OPEN, 1)
  );

  reopenRegion();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:42,代码来源:TestRegionServerNoMaster.java

示例2: testCancelOpeningWithoutZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test that if we do a close while opening it stops the opening.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithoutZK() throws Exception {
  // We close
  closeRegionNoZK();
  checkRegionIsClosed(HTU, getRS(), hri);

  // Let do the initial steps, without having a handler
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  AdminProtos.CloseRegionRequest crr =
      ProtobufUtil.buildCloseRegionRequest(getRS().getServerName(), regionName);
  try {
    getRS().rpcServices.closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException expected) {
  }

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  TableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());

  getRS().executorService.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, -1));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed(HTU, getRS(), hri);

  openRegion(HTU, getRS(), hri);
}
 
开发者ID:apache,项目名称:hbase,代码行数:36,代码来源:TestRegionServerNoMaster.java

示例3: openRegion

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
@Override
@QosPriority(priority = HIGH_QOS)
public RegionOpeningState openRegion(HRegionInfo region, int versionOfOfflineNode)
    throws IOException {
  checkOpen();
  checkIfRegionInTransition(region, OPEN);
  HRegion onlineRegion = this.getFromOnlineRegions(region.getEncodedName());
  if (null != onlineRegion) {
    // See HBASE-5094. Cross check with META if still this RS is owning the
    // region.
    Pair<HRegionInfo, ServerName> p = MetaReader.getRegion(
        this.catalogTracker, region.getRegionName());
    if (this.getServerName().equals(p.getSecond())) {
      LOG.warn("Attempted open of " + region.getEncodedName()
          + " but already online on this server");
      return RegionOpeningState.ALREADY_OPENED;
    } else {
      LOG.warn("The region " + region.getEncodedName()
          + " is online on this server but META does not have this server.");
      this.removeFromOnlineRegions(region.getEncodedName());
    }
  }
  LOG.info("Received request to open region: " +
    region.getRegionNameAsString());
  this.regionsInTransitionInRS.putIfAbsent(region.getEncodedNameAsBytes(),
      true);
  HTableDescriptor htd = this.tableDescriptors.get(region.getTableName());
  // Need to pass the expected version in the constructor.
  if (region.isRootRegion()) {
    this.service.submit(new OpenRootHandler(this, this, region, htd,
        versionOfOfflineNode));
  } else if (region.isMetaRegion()) {
    this.service.submit(new OpenMetaHandler(this, this, region, htd,
        versionOfOfflineNode));
  } else {
    this.service.submit(new OpenRegionHandler(this, this, region, htd,
        versionOfOfflineNode));
  }
  return RegionOpeningState.OPENED;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:41,代码来源:HRegionServer.java

示例4: testCancelOpeningWithoutZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test that if we do a close while opening it stops the opening.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithoutZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().rpcServices.closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
  }

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());
  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // The open handler should have updated the value in ZK.
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeper(), hri.getEncodedName(),
      EventType.RS_ZK_REGION_FAILED_OPEN, 1)
  );

  reopenRegion();
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:42,代码来源:TestRegionServerNoMaster.java

示例5: testCancelOpeningWithoutZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test that if we do a close while opening it stops the opening.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithoutZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(regionName, false);
  try {
    getRS().closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
  }

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());
  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // The open handler should have updated the value in ZK.
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeperWatcher(), hri.getEncodedName(),
      EventType.RS_ZK_REGION_FAILED_OPEN, 1)
  );

  reopenRegion();
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:42,代码来源:TestRegionServerNoMaster.java

示例6: testCancelOpeningWithoutZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test that if we do a close while opening it stops the opening.
 */
@Test(timeout = 20000)
public void testCancelOpeningWithoutZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(regionName, false);
  try {
    getRS().closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
  }

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTableName());
  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // The open handler should have updated the value in ZK.
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeperWatcher(), hri.getEncodedName(),
      EventHandler.EventType.RS_ZK_REGION_FAILED_OPEN, 1)
  );

  reopenRegion();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:42,代码来源:TestRegionServerNoMaster.java

示例7: testCancelOpeningWithoutZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test that if we do a close while opening it stops the opening.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithoutZK() throws Exception {
  // We close
  closeRegionNoZK();
  checkRegionIsClosed(HTU, getRS(), hri);

  // Let do the initial steps, without having a handler
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().rpcServices.closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
  }

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());

  BaseCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(getRS());
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(getRS().getServerName());
  zkCrd.setVersionOfOfflineNode(0);

  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd,
    -1, csm.getOpenRegionCoordination(), zkCrd));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed(HTU, getRS(), hri);

  // The open handler should have updated the value in ZK.
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeper(), hri.getEncodedName(),
      EventType.RS_ZK_REGION_FAILED_OPEN, 1)
  );

  openRegion(HTU, getRS(), hri);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:TestRegionServerNoMaster.java

示例8: testCancelOpeningWithZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test an open then a close with ZK. This is going to mess-up the ZK states, so
 * the opening will fail as well because it doesn't find what it expects in ZK.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithZK() throws Exception {
  // We close
  closeRegionNoZK();
  checkRegionIsClosed(HTU, getRS(), hri);

  // Let do the initial steps, without having a handler
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  ZKAssign.createNodeClosing(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().rpcServices.closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
    Assert.assertTrue(expected.getCause() instanceof RegionAlreadyInTransitionException);
  }

  // The close should have left the ZK state as it is: it's the job the AM to delete it
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeper(), hri.getEncodedName(),
      EventType.M_ZK_REGION_CLOSING, 0)
  );

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  // It should not succeed for two reasons:
  //  1) There is no ZK node
  //  2) The region in RIT was changed.
  // The order is more or less implementation dependant.
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());

  BaseCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(getRS());
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(getRS().getServerName());
  zkCrd.setVersionOfOfflineNode(0);

  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd,
    -1, csm.getOpenRegionCoordination(), zkCrd));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed(HTU, getRS(), hri);

  // We should not find any znode here.
  Assert.assertEquals(-1, ZKAssign.getVersion(HTU.getZooKeeperWatcher(), hri));

  openRegion(HTU, getRS(), hri);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:62,代码来源:TestRegionServerNoMaster.java

示例9: openRegion

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
private RegionOpeningState openRegion(HRegionInfo region, int versionOfOfflineNode,
    Map<String, HTableDescriptor> htds) throws IOException {
  checkOpen();
  HRegion onlineRegion = this.getFromOnlineRegions(region.getEncodedName());
  if (null != onlineRegion) {
    // See HBASE-5094. Cross check with META if still this RS is owning the
    // region.
    Pair<HRegionInfo, ServerName> p =
        MetaReader.getRegion(this.catalogTracker, region.getRegionName());
    if (this.getServerName().equals(p.getSecond())) {
      LOG.warn("Attempted open of " + region.getEncodedName()
          + " but already online on this server");
      return RegionOpeningState.ALREADY_OPENED;
    } else {
      LOG.warn("The region " + region.getEncodedName()
          + " is online on this server but META does not have this server.");
      this.removeFromOnlineRegions(region.getEncodedName());
    }
  }
  // Added to in-memory RS RIT that we are trying to open this region.
  // Clear it if we fail queuing an open executor.
  boolean isNewRit = addRegionsInTransition(region, OPEN);
  if (!isNewRit) {
    // An open is in progress. This is supported, but let's log this.
    LOG.info("Receiving OPEN for the region:" + region.getRegionNameAsString()
        + " , which we are already trying to OPEN"
        + " - ignoring this new request for this region.");
    return RegionOpeningState.OPENED;
  }
  try {
    LOG.info("Received request to open region: " + region.getRegionNameAsString());
    HTableDescriptor htd = null;
    if (htds == null) {
      htd = this.tableDescriptors.get(region.getTableName());
    } else {
      htd = htds.get(region.getTableNameAsString());
      if (htd == null) {
        htd = this.tableDescriptors.get(region.getTableName());
        htds.put(region.getTableNameAsString(), htd);
      }
    }

    // Mark the region as OPENING up in zk. This is how we tell the master control of the
    // region has passed to this regionserver.
    int version = transitionZookeeperOfflineToOpening(region, versionOfOfflineNode);
    // Need to pass the expected version in the constructor.
    if (region.isRootRegion()) {
      this.service.submit(new OpenRootHandler(this, this, region, htd, version));
    } else if (region.isMetaRegion()) {
      this.service.submit(new OpenMetaHandler(this, this, region, htd, version));
    } else {
      this.service.submit(new OpenRegionHandler(this, this, region, htd, version));
    }
  } catch (IOException ie) {
    // Clear from this server's RIT list else will stick around for ever.
    removeFromRegionsInTransition(region);
    throw ie;
  }
  return RegionOpeningState.OPENED;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:61,代码来源:HRegionServer.java

示例10: testCancelOpeningWithoutZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test that if we do a close while opening it stops the opening.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithoutZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().rpcServices.closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
  }

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());

  BaseCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(getRS());
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(getRS().getServerName());
  zkCrd.setVersionOfOfflineNode(0);

  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd,
    csm.getOpenRegionCoordination(), zkCrd));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // The open handler should have updated the value in ZK.
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeper(), hri.getEncodedName(),
      EventType.RS_ZK_REGION_FAILED_OPEN, 1)
  );

  reopenRegion();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:53,代码来源:TestRegionServerNoMaster.java

示例11: testCancelOpeningWithZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test an open then a close with ZK. This is going to mess-up the ZK states, so
 * the opening will fail as well because it doesn't find what it expects in ZK.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  ZKAssign.createNodeClosing(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().rpcServices.closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
    Assert.assertTrue(expected.getCause() instanceof RegionAlreadyInTransitionException);
  }

  // The close should have left the ZK state as it is: it's the job the AM to delete it
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeper(), hri.getEncodedName(),
      EventType.M_ZK_REGION_CLOSING, 0)
  );

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  // It should not succeed for two reasons:
  //  1) There is no ZK node
  //  2) The region in RIT was changed.
  // The order is more or less implementation dependant.
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());

  BaseCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(getRS());
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(getRS().getServerName());
  zkCrd.setVersionOfOfflineNode(0);

  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd,
    csm.getOpenRegionCoordination(), zkCrd));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // We should not find any znode here.
  Assert.assertEquals(-1, ZKAssign.getVersion(HTU.getZooKeeperWatcher(), hri));

  reopenRegion();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:62,代码来源:TestRegionServerNoMaster.java

示例12: testCancelOpeningWithZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test an open then a close with ZK. This is going to mess-up the ZK states, so
 * the opening will fail as well because it doesn't find what it expects in ZK.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  ZKAssign.createNodeClosing(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
    Assert.assertTrue(expected.getCause() instanceof NotServingRegionException);
  }

  // The close should have left the ZK state as it is: it's the job the AM to delete it
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeperWatcher(), hri.getEncodedName(),
      EventType.M_ZK_REGION_CLOSING, 0)
  );

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  // It should not succeed for two reasons:
  //  1) There is no ZK node
  //  2) The region in RIT was changed.
  // The order is more or less implementation dependant.
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());
  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // We should not find any znode here.
  Assert.assertEquals(-1, ZKAssign.getVersion(HTU.getZooKeeperWatcher(), hri));

  reopenRegion();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:51,代码来源:TestRegionServerNoMaster.java

示例13: openRegion

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
private RegionOpeningState openRegion(HRegionInfo region, int versionOfOfflineNode,
    Map<String, HTableDescriptor> htds) throws IOException {
  checkOpen();
  HRegion onlineRegion = this.getFromOnlineRegions(region.getEncodedName());
  if (null != onlineRegion) {
    // See HBASE-5094. Cross check with META if still this RS is owning the
    // region.
    Pair<HRegionInfo, ServerName> p = MetaReader.getRegion(
        this.catalogTracker, region.getRegionName());
    if (this.getServerName().equals(p.getSecond())) {
      LOG.warn("Attempted open of " + region.getEncodedName()
          + " but already online on this server");
      return RegionOpeningState.ALREADY_OPENED;
    } else {
      LOG.warn("The region " + region.getEncodedName()
          + " is online on this server but META does not have this server.");
      this.removeFromOnlineRegions(region.getEncodedName());
    }
  }
  // Added to in-memory RS RIT that we are trying to open this region.
  // Clear it if we fail queuing an open executor.
  boolean isNewRit = addRegionsInTransition(region, OPEN);
  if (!isNewRit) {
    // An open is in progress. This is supported, but let's log this.
    LOG.info("Receiving OPEN for the region:" +
        region.getRegionNameAsString() + " , which we are already trying to OPEN" +
        " - ignoring this new request for this region.");
    return RegionOpeningState.OPENED;
  }
  try {
    LOG.info("Received request to open region: " +
      region.getRegionNameAsString());
    HTableDescriptor htd = null;
    if (htds == null) {
      htd = this.tableDescriptors.get(region.getTableName());
    } else {
      htd = htds.get(region.getTableNameAsString());
      if (htd == null) {
        htd = this.tableDescriptors.get(region.getTableName());
        htds.put(region.getTableNameAsString(), htd);
      }
    }

    // Mark the region as OPENING up in zk.  This is how we tell the master control of the
    // region has passed to this regionserver.
    int version = transitionZookeeperOfflineToOpening(region, versionOfOfflineNode);
    // Need to pass the expected version in the constructor.
    if (region.isRootRegion()) {
      this.service.submit(new OpenRootHandler(this, this, region, htd, version));
    } else if (region.isMetaRegion()) {
      this.service.submit(new OpenMetaHandler(this, this, region, htd, version));
    } else {
      this.service.submit(new OpenRegionHandler(this, this, region, htd, version));
    }
  } catch (IOException ie) {
    // Clear from this server's RIT list else will stick around for ever.
    removeFromRegionsInTransition(region);
    throw ie;
  }
  return RegionOpeningState.OPENED;
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:62,代码来源:HRegionServer.java

示例14: testCancelOpeningWithZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test an open then a close with ZK. This is going to mess-up the ZK states, so
 * the opening will fail as well because it doesn't find what it expects in ZK.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  ZKAssign.createNodeClosing(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(getRS().getServerName(), regionName, false);
  try {
    getRS().rpcServices.closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
    Assert.assertTrue(expected.getCause() instanceof NotServingRegionException);
  }

  // The close should have left the ZK state as it is: it's the job the AM to delete it
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeper(), hri.getEncodedName(),
      EventType.M_ZK_REGION_CLOSING, 0)
  );

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  // It should not succeed for two reasons:
  //  1) There is no ZK node
  //  2) The region in RIT was changed.
  // The order is more or less implementation dependant.
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());
  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // We should not find any znode here.
  Assert.assertEquals(-1, ZKAssign.getVersion(HTU.getZooKeeperWatcher(), hri));

  reopenRegion();
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:51,代码来源:TestRegionServerNoMaster.java

示例15: testCancelOpeningWithZK

import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; //导入依赖的package包/类
/**
 * Test an open then a close with ZK. This is going to mess-up the ZK states, so
 * the opening will fail as well because it doesn't find what it expects in ZK.
 */
@Test(timeout = 60000)
public void testCancelOpeningWithZK() throws Exception {
  // We close
  closeNoZK();
  checkRegionIsClosed();

  // Let do the initial steps, without having a handler
  getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);

  // That's a close without ZK.
  ZKAssign.createNodeClosing(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  AdminProtos.CloseRegionRequest crr =
      RequestConverter.buildCloseRegionRequest(regionName, false);
  try {
    getRS().closeRegion(null, crr);
    Assert.assertTrue(false);
  } catch (ServiceException expected) {
    Assert.assertTrue(expected.getCause() instanceof NotServingRegionException);
  }

  // The close should have left the ZK state as it is: it's the job the AM to delete it
  Assert.assertTrue(ZKAssign.deleteNode(
      getRS().getZooKeeperWatcher(), hri.getEncodedName(),
      EventType.M_ZK_REGION_CLOSING, 0)
  );

  // The state in RIT should have changed to close
  Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
      hri.getEncodedNameAsBytes()));

  // Let's start the open handler
  // It should not succeed for two reasons:
  //  1) There is no ZK node
  //  2) The region in RIT was changed.
  // The order is more or less implementation dependant.
  HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());
  getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));

  // The open handler should have removed the region from RIT but kept the region closed
  checkRegionIsClosed();

  // We should not find any znode here.
  Assert.assertEquals(-1, ZKAssign.getVersion(HTU.getZooKeeperWatcher(), hri));

  reopenRegion();
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:51,代码来源:TestRegionServerNoMaster.java


注:本文中的org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。