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


Java EventType.RS_ZK_REGION_OPENED属性代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.executor.EventHandler.EventType.RS_ZK_REGION_OPENED属性的典型用法代码示例。如果您正苦于以下问题:Java EventType.RS_ZK_REGION_OPENED属性的具体用法?Java EventType.RS_ZK_REGION_OPENED怎么用?Java EventType.RS_ZK_REGION_OPENED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.hbase.executor.EventHandler.EventType的用法示例。


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

示例1: processOpeningState

private void processOpeningState(HRegionInfo regionInfo) {
  LOG.info("Region has been OPENING for too " + "long, reassigning region="
      + regionInfo.getRegionNameAsString());
  // Should have a ZK node in OPENING state
  try {
    String node = ZKAssign.getNodeName(watcher, regionInfo.getEncodedName());
    Stat stat = new Stat();
    RegionTransitionData dataInZNode = ZKAssign.getDataNoWatch(watcher, node,
        stat);
    if (dataInZNode == null) {
      LOG.warn("Data is null, node " + node + " no longer exists");
      return;
    }
    if (dataInZNode.getEventType() == EventType.RS_ZK_REGION_OPENED) {
      LOG.debug("Region has transitioned to OPENED, allowing "
          + "watched event handlers to process");
      return;
    } else if (dataInZNode.getEventType() != EventType.RS_ZK_REGION_OPENING &&
        dataInZNode.getEventType() != EventType.RS_ZK_REGION_FAILED_OPEN ) {
      LOG.warn("While timing out a region in state OPENING, "
          + "found ZK node in unexpected state: "
          + dataInZNode.getEventType());
      return;
    }
    invokeAssign(regionInfo);
  } catch (KeeperException ke) {
    LOG.error("Unexpected ZK exception timing out CLOSING region", ke);
    return;
  }
  return;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:31,代码来源:AssignmentManager.java

示例2: testReOpenRegion

/**
 * 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(regionServer.getOnlineRegions());
  LOG.debug("Asking RS to close region " + hri.getRegionNameAsString());

  AtomicBoolean closeEventProcessed = new AtomicBoolean(false);
  AtomicBoolean reopenEventProcessed = new AtomicBoolean(false);

  EventHandlerListener closeListener =
    new ReopenEventListener(hri.getRegionNameAsString(),
        closeEventProcessed, EventType.RS_ZK_REGION_CLOSED);
  cluster.getMaster().executorService.
    registerListener(EventType.RS_ZK_REGION_CLOSED, closeListener);

  EventHandlerListener openListener =
    new ReopenEventListener(hri.getRegionNameAsString(),
        reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);
  cluster.getMaster().executorService.
    registerListener(EventType.RS_ZK_REGION_OPENED, openListener);

  LOG.info("Unassign " + hri.getRegionNameAsString());
  cluster.getMaster().assignmentManager.unassign(hri);

  while (!closeEventProcessed.get()) {
    Threads.sleep(100);
  }

  while (!reopenEventProcessed.get()) {
    Threads.sleep(100);
  }

  LOG.info("Done with testReOpenRegion");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:44,代码来源:TestZKBasedOpenCloseRegion.java

示例3: testRSAlreadyProcessingRegion

/**
 * 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(hr0.getOnlineRegions());

  // Fake that hr1 is processing the region. At top of this test we made a
  // regionserver that gave access addRegionsInTransition. Need to cast as
  // TestZKBasedOpenCloseRegionRegionServer.
  ((TestZKBasedOpenCloseRegionRegionServer) hr1).addRegionsInTransition(hri, "OPEN");

  AtomicBoolean reopenEventProcessed = new AtomicBoolean(false);
  EventHandlerListener openListener =
    new ReopenEventListener(hri.getRegionNameAsString(),
        reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);
  cluster.getMaster().executorService.
    registerListener(EventType.RS_ZK_REGION_OPENED, openListener);

  // 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.removeFromRegionsInTransition(hri);
  reopenEventProcessed.set(false);
  
  // now try moving a region when there is no region in transition.
  hri = getNonMetaRegion(hr1.getOnlineRegions());

  openListener =
    new ReopenEventListener(hri.getRegionNameAsString(),
        reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);

  cluster.getMaster().executorService.
    registerListener(EventType.RS_ZK_REGION_OPENED, openListener);
  
  TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
      Bytes.toBytes(hr0.getServerName().toString()));

  while (!reopenEventProcessed.get()) {
    Threads.sleep(100);
  }

  // make sure the region has moved from the original RS
  assertTrue(hr1.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);

}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:60,代码来源:TestZKBasedOpenCloseRegion.java

示例4: testRegionShouldNotBeDeployed

/**
 * the region is not deployed when the table is disabled.
 */
@Test
public void testRegionShouldNotBeDeployed() throws Exception {
  String table = "tableRegionShouldNotBeDeployed";
  try {
    LOG.info("Starting testRegionShouldNotBeDeployed.");
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    assertTrue(cluster.waitForActiveAndReadyMaster());

    // Create a ZKW to use in the test
    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);

    FileSystem filesystem = FileSystem.get(conf);
    Path rootdir = filesystem.makeQualified(new Path(conf
        .get(HConstants.HBASE_DIR)));

    byte[][] SPLIT_KEYS = new byte[][] { new byte[0], Bytes.toBytes("aaa"),
        Bytes.toBytes("bbb"), Bytes.toBytes("ccc"), Bytes.toBytes("ddd") };
    HTableDescriptor htdDisabled = new HTableDescriptor(Bytes.toBytes(table));
    htdDisabled.addFamily(new HColumnDescriptor(FAM));

    // Write the .tableinfo
    FSTableDescriptors
        .createTableDescriptor(filesystem, rootdir, htdDisabled);
    List<HRegionInfo> disabledRegions = TEST_UTIL.createMultiRegionsInMeta(
        TEST_UTIL.getConfiguration(), htdDisabled, SPLIT_KEYS);

    // Let's just assign everything to first RS
    HRegionServer hrs = cluster.getRegionServer(0);
    ServerName serverName = hrs.getServerName();

    // create region files.
    TEST_UTIL.getHBaseAdmin().disableTable(table);
    TEST_UTIL.getHBaseAdmin().enableTable(table);

    // Region of disable table was opened on RS
    TEST_UTIL.getHBaseAdmin().disableTable(table);
    HRegionInfo region = disabledRegions.remove(0);
    ZKAssign.createNodeOffline(zkw, region, serverName);
    hrs.openRegion(region);

    int iTimes = 0;
    while (true) {
      RegionTransitionData rtd = ZKAssign.getData(zkw,
          region.getEncodedName());
      if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
        break;
      }
      Thread.sleep(100);
      iTimes++;
      if (iTimes >= REGION_ONLINE_TIMEOUT) {
        break;
      }
    }
    assertTrue(iTimes < REGION_ONLINE_TIMEOUT);

    HBaseFsck hbck = doFsck(conf, false);
    assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.SHOULD_NOT_BE_DEPLOYED });

    // fix this fault
    doFsck(conf, true);

    // check result
    assertNoErrors(doFsck(conf, false));
  } finally {
    TEST_UTIL.getHBaseAdmin().enableTable(table);
    deleteTable(table);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:71,代码来源:TestHBaseFsck.java


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