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


Java EventHandlerListener类代码示例

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


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

示例1: testCloseRegion

import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener; //导入依赖的package包/类
@Test (timeout=300000) public void testCloseRegion()
throws Exception {
  LOG.info("Running testCloseRegion");
  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);
  EventHandlerListener listener =
    new CloseRegionEventListener(hri.getRegionNameAsString(),
        closeEventProcessed);
  cluster.getMaster().executorService.registerListener(EventType.RS_ZK_REGION_CLOSED, listener);

  cluster.getMaster().assignmentManager.unassign(hri);

  while (!closeEventProcessed.get()) {
    Threads.sleep(100);
  }
  LOG.info("Done with testCloseRegion");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:25,代码来源:TestZKBasedOpenCloseRegion.java

示例2: testCloseRegion

import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener; //导入依赖的package包/类
@Test (timeout=300000) public void testCloseRegion()
throws Exception {
  LOG.info("Running testCloseRegion");
  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));
  LOG.debug("Asking RS to close region " + hri.getRegionNameAsString());

  AtomicBoolean closeEventProcessed = new AtomicBoolean(false);
  EventHandlerListener listener =
    new CloseRegionEventListener(hri.getRegionNameAsString(),
        closeEventProcessed);
  cluster.getMaster().executorService.registerListener(EventType.RS_ZK_REGION_CLOSED, listener);

  cluster.getMaster().assignmentManager.unassign(hri);

  while (!closeEventProcessed.get()) {
    Threads.sleep(100);
  }
  LOG.info("Done with testCloseRegion");
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:25,代码来源:TestZKBasedOpenCloseRegion.java

示例3: Executor

import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener; //导入依赖的package包/类
protected Executor(String name, int maxThreads,
    final Map<EventType, EventHandlerListener> eventHandlerListeners) {
  this.id = seqids.incrementAndGet();
  this.name = name;
  this.eventHandlerListeners = eventHandlerListeners;
  // create the thread pool executor
  this.threadPoolExecutor = new TrackingThreadPoolExecutor(
      maxThreads, maxThreads,
      keepAliveTimeInMillis, TimeUnit.MILLISECONDS, q);
  // name the threads for this threadpool
  ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
  tfb.setNameFormat(this.name + "-%d");
  this.threadPoolExecutor.setThreadFactory(tfb.build());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ExecutorService.java

示例4: submit

import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener; //导入依赖的package包/类
/**
 * Submit the event to the queue for handling.
 * @param event
 */
void submit(final EventHandler event) {
  // If there is a listener for this type, make sure we call the before
  // and after process methods.
  EventHandlerListener listener =
    this.eventHandlerListeners.get(event.getEventType());
  if (listener != null) {
    event.setListener(listener);
  }
  this.threadPoolExecutor.execute(event);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ExecutorService.java

示例5: Executor

import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener; //导入依赖的package包/类
protected Executor(String name, int maxThreads,
    final Map<EventHandler.EventType, EventHandlerListener> eventHandlerListeners) {
  this.id = seqids.incrementAndGet();
  this.name = name;
  this.eventHandlerListeners = eventHandlerListeners;
  // create the thread pool executor
  this.threadPoolExecutor = new TrackingThreadPoolExecutor(
      maxThreads, maxThreads,
      keepAliveTimeInMillis, TimeUnit.MILLISECONDS, q);
  // name the threads for this threadpool
  ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
  tfb.setNameFormat(this.name + "-%d");
  this.threadPoolExecutor.setThreadFactory(tfb.build());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:15,代码来源:ExecutorService.java

示例6: testReOpenRegion

import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener; //导入依赖的package包/类
/**
 * 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,代码行数:45,代码来源:TestZKBasedOpenCloseRegion.java

示例7: testRSAlreadyProcessingRegion

import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener; //导入依赖的package包/类
/**
 * 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,代码行数:61,代码来源:TestZKBasedOpenCloseRegion.java


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