• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ZKTable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AssignmentManager

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Constructs a new assignment manager.
 *
 * @param master
 * @param serverManager
 * @param catalogTracker
 * @param service
 * @throws KeeperException
 * @throws IOException 
 */
public AssignmentManager(Server master, ServerManager serverManager,
    CatalogTracker catalogTracker, final LoadBalancer balancer,
    final ExecutorService service) throws KeeperException, IOException {
  super(master.getZooKeeper());
  this.master = master;
  this.serverManager = serverManager;
  this.catalogTracker = catalogTracker;
  this.executorService = service;
  this.regionsToReopen = Collections.synchronizedMap
                         (new HashMap<String, HRegionInfo> ());
  Configuration conf = master.getConfiguration();
  this.timeoutMonitor = new TimeoutMonitor(
    conf.getInt("hbase.master.assignment.timeoutmonitor.period", 10000),
    master, serverManager,
    conf.getInt("hbase.master.assignment.timeoutmonitor.timeout", 1800000));
  this.timerUpdater = new TimerUpdater(conf.getInt(
      "hbase.master.assignment.timerupdater.period", 10000), master);
  Threads.setDaemonThreadRunning(timerUpdater.getThread(),
      master.getServerName() + ".timerUpdater");
  this.zkTable = new ZKTable(this.master.getZooKeeper());
  this.maximumAssignmentAttempts =
    this.master.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10);
  this.balancer = balancer;
  this.threadPoolExecutorService = Executors.newCachedThreadPool();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:36,代码来源:AssignmentManager.java


示例2: recoverTableInEnablingState

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws org.apache.hadoop.hbase.TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<TableName> enablingTables = ZKTable.getEnablingTables(watcher);
  if (enablingTables.size() != 0) {
    for (TableName tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      EnableTableHandler eth = new EnableTableHandler(this.server, tableName,
        catalogTracker, this, tableLockManager, true);
      try {
        eth.prepare();
      } catch (TableNotFoundException e) {
        LOG.warn("Table " + tableName + " not found in hbase:meta to recover.");
        continue;
      }
      eth.process();
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:32,代码来源:AssignmentManager.java


示例3: waitUntilTableDisabled

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
private boolean waitUntilTableDisabled(long timeout, TableName tableName, ZKTable zk) {
  long startTime = System.currentTimeMillis();
  long remaining = timeout;
  boolean disabled = false;
  while (!(disabled = zk.isDisabledTable(tableName)) && remaining > 0) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while waiting for table" + tableName + " set to DISABLED.");
      }
    }
    remaining = timeout - (System.currentTimeMillis() - startTime);
  }
  if (remaining <= 0) {
    return disabled;
  } else {
    return true;
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:21,代码来源:IndexMasterObserver.java


示例4: waitUntilTableEnabled

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
private boolean waitUntilTableEnabled(long timeout, TableName tableName, ZKTable zk) {
  long startTime = System.currentTimeMillis();
  long remaining = timeout;
  boolean enabled = false;
  while (!(enabled = zk.isEnabledTable(tableName)) && remaining > 0) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while waiting for table " + tableName + "state set to ENABLED.");
      }
    }
    remaining = timeout - (System.currentTimeMillis() - startTime);
  }
  if (remaining <= 0) {
    return enabled;
  } else {
    return true;
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:21,代码来源:IndexMasterObserver.java


示例5: testTableOnlineState

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
private boolean testTableOnlineState(byte [] tableName, boolean online)
throws IOException {
  if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
    // The root region is always enabled
    return online;
  }
  String tableNameStr = Bytes.toString(tableName);
  try {
    if (online) {
      return ZKTable.isEnabledTable(this.zooKeeper, tableNameStr);
    }
    return ZKTable.isDisabledTable(this.zooKeeper, tableNameStr);
  } catch (KeeperException e) {
    throw new IOException("Enable/Disable failed", e);
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:17,代码来源:HConnectionManager.java


示例6: AssignmentManager

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Constructs a new assignment manager.
 *
 * @param master
 * @param serverManager
 * @param catalogTracker
 * @param service
 * @throws KeeperException
 * @throws IOException 
 */
public AssignmentManager(Server master, ServerManager serverManager,
    CatalogTracker catalogTracker, final ExecutorService service)
throws KeeperException, IOException {
  super(master.getZooKeeper());
  this.master = master;
  this.serverManager = serverManager;
  this.catalogTracker = catalogTracker;
  this.executorService = service;
  this.regionsToReopen = Collections.synchronizedMap
                         (new HashMap<String, HRegionInfo> ());
  Configuration conf = master.getConfiguration();
  this.timeoutMonitor = new TimeoutMonitor(
    conf.getInt("hbase.master.assignment.timeoutmonitor.period", 10000),
    master, serverManager,
    conf.getInt("hbase.master.assignment.timeoutmonitor.timeout", 1800000));
  Threads.setDaemonThreadRunning(timeoutMonitor.getThread(),
    master.getServerName() + ".timeoutMonitor");
  this.zkTable = new ZKTable(this.master.getZooKeeper());
  this.maximumAssignmentAttempts =
    this.master.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10);
  this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
  this.threadPoolExecutorService = Executors.newCachedThreadPool();
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:34,代码来源:AssignmentManager.java


示例7: loadDisabledTables

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Load the list of disabled tables in ZK into local set.
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
private void loadDisabledTables()
throws ZooKeeperConnectionException, IOException {
  HConnectionManager.execute(new HConnectable<Void>(conf) {
    @Override
    public Void connect(HConnection connection) throws IOException {
      ZooKeeperWatcher zkw = connection.getZooKeeperWatcher();
      try {
        for (String tableName : ZKTable.getDisabledOrDisablingTables(zkw)) {
          disabledTables.add(Bytes.toBytes(tableName));
        }
      } catch (KeeperException ke) {
        throw new IOException(ke);
      }
      return null;
    }
  });
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:23,代码来源:HBaseFsck.java


示例8: recoverTableInEnablingState

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws org.apache.hadoop.hbase.TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<TableName> enablingTables = ZKTable.getEnablingTables(watcher);
  if (enablingTables.size() != 0) {
    for (TableName tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.server, tableName,
          catalogTracker, this, tableLockManager, true).prepare().process();
    }
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:25,代码来源:AssignmentManager.java


示例9: recoverTableInEnablingState

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<String> enablingTables = ZKTable.getEnablingTables(watcher);
  if (enablingTables.size() != 0) {
    for (String tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.server, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:25,代码来源:AssignmentManager.java


示例10: waitUntilTableDisabled

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
private boolean waitUntilTableDisabled(long timeout, String tableName, ZKTable zk) {
  long startTime = System.currentTimeMillis();
  long remaining = timeout;
  boolean disabled = false;
  while (!(disabled = zk.isDisabledTable(tableName)) && remaining > 0) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while waiting for table" + tableName + " set to DISABLED.");
      }
    }
    remaining = timeout - (System.currentTimeMillis() - startTime);
  }
  if (remaining <= 0) {
    return disabled;
  } else {
    return true;
  }
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:21,代码来源:IndexMasterObserver.java


示例11: waitUntilTableEnabled

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
private boolean waitUntilTableEnabled(long timeout, String tableName, ZKTable zk) {
  long startTime = System.currentTimeMillis();
  long remaining = timeout;
  boolean enabled = false;
  while (!(enabled = zk.isEnabledTable(tableName)) && remaining > 0) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while waiting for table " + tableName + "state set to ENABLED.");
      }
    }
    remaining = timeout - (System.currentTimeMillis() - startTime);
  }
  if (remaining <= 0) {
    return enabled;
  } else {
    return true;
  }

}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:22,代码来源:IndexMasterObserver.java


示例12: assignAllUserRegions

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Assigns all user regions, if any exist.  Used during cluster startup.
 * <p>
 * This is a synchronous call and will return once every region has been
 * assigned.  If anything fails, an exception is thrown and the cluster
 * should be shutdown.
 * @throws InterruptedException
 * @throws IOException
 * @throws KeeperException
 */
private void assignAllUserRegions()
    throws IOException, InterruptedException, KeeperException {
  // Cleanup any existing ZK nodes and start watching
  ZKAssign.deleteAllNodes(watcher);
  ZKUtil.listChildrenAndWatchForNewChildren(this.watcher,
    this.watcher.assignmentZNode);
  failoverCleanupDone();

  // Skip assignment for regions of tables in DISABLING state because during clean cluster startup
  // no RS is alive and regions map also doesn't have any information about the regions.
  // See HBASE-6281.
  Set<TableName> disabledOrDisablingOrEnabling = ZKTable.getDisabledOrDisablingTables(watcher);
  disabledOrDisablingOrEnabling.addAll(ZKTable.getEnablingTables(watcher));
  // Scan hbase:meta for all user regions, skipping any disabled tables
  Map<HRegionInfo, ServerName> allRegions;
  SnapshotOfRegionAssignmentFromMeta snapshotOfRegionAssignment =
     new SnapshotOfRegionAssignmentFromMeta(catalogTracker, disabledOrDisablingOrEnabling, true);
  snapshotOfRegionAssignment.initialize();
  allRegions = snapshotOfRegionAssignment.getRegionToRegionServerMap();
  if (allRegions == null || allRegions.isEmpty()) return;

  // Determine what type of assignment to do on startup
  boolean retainAssignment = server.getConfiguration().
    getBoolean("hbase.master.startup.retainassign", true);

  if (retainAssignment) {
    assign(allRegions);
  } else {
    List<HRegionInfo> regions = new ArrayList<HRegionInfo>(allRegions.keySet());
    assign(regions);
  }

  for (HRegionInfo hri : allRegions.keySet()) {
    TableName tableName = hri.getTable();
    if (!zkTable.isEnabledTable(tableName)) {
      setEnabledTable(tableName);
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:50,代码来源:AssignmentManager.java


示例13: recoverTableInDisablingState

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<TableName> disablingTables = ZKTable.getDisablingTables(watcher);
  if (disablingTables.size() != 0) {
    for (TableName tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName, catalogTracker,
          this, tableLockManager, true).prepare().process();
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:23,代码来源:AssignmentManager.java


示例14: setTablesInZK

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
private void setTablesInZK() throws IOException, KeeperException {
  if (tablesToBeSetInZK != null && !tablesToBeSetInZK.isEmpty()) {
    ZKTable zkTable = new ZKTable(this.watcher);
    for (Pair<String, State> p : tablesToBeSetInZK) {
      setStateInZK(zkTable, p.getFirst(), p.getSecond());
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:9,代码来源:SecondaryIndexColocator.java


示例15: setStateInZK

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
private void setStateInZK(ZKTable zkTable, String tableName, State state) throws IOException,
    KeeperException {
  if (state == State.ENABLED) {
    zkTable.setEnabledTable(TableName.valueOf(tableName));
  }
  if (state == State.DISABLED) {
    zkTable.setDisabledTable(TableName.valueOf(tableName));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:10,代码来源:SecondaryIndexColocator.java


示例16: AssignmentManager

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Constructs a new assignment manager.
 *
 * @param server
 * @param serverManager
 * @param catalogTracker
 * @param service
 * @throws KeeperException
 * @throws IOException
 */
public AssignmentManager(Server server, ServerManager serverManager,
    CatalogTracker catalogTracker, final LoadBalancer balancer,
    final ExecutorService service, MetricsMaster metricsMaster) throws KeeperException, IOException {
  super(server.getZooKeeper());
  this.server = server;
  this.serverManager = serverManager;
  this.catalogTracker = catalogTracker;
  this.executorService = service;
  this.regionsToReopen = Collections.synchronizedMap
                         (new HashMap<String, HRegionInfo> ());
  Configuration conf = server.getConfiguration();
  this.timeoutMonitor = new TimeoutMonitor(
    conf.getInt("hbase.master.assignment.timeoutmonitor.period", 30000),
    server, serverManager,
    conf.getInt("hbase.master.assignment.timeoutmonitor.timeout", 600000));
  this.timerUpdater = new TimerUpdater(conf.getInt(
    "hbase.master.assignment.timerupdater.period", 10000), server);
  Threads.setDaemonThreadRunning(timerUpdater.getThread(),
    server.getServerName() + ".timerUpdater");
  this.zkTable = new ZKTable(this.watcher);
  this.maximumAttempts =
    this.server.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10);
  this.balancer = balancer;
  int maxThreads = conf.getInt("hbase.assignment.threads.max", 30);
  this.threadPoolExecutorService = Threads.getBoundedCachedThreadPool(
    maxThreads, 60L, TimeUnit.SECONDS, Threads.newDaemonThreadFactory("hbase-am"));
  this.metricsMaster = metricsMaster;// can be null only with tests.
  this.regionStates = new RegionStates(server, serverManager);

  int workers = conf.getInt("hbase.assignment.zkevent.workers", 20);
  ThreadFactory threadFactory = Threads.newDaemonThreadFactory("hbase-am-zkevent-worker");
  zkEventWorkers = Threads.getBoundedCachedThreadPool(workers, 60L,
          TimeUnit.SECONDS, threadFactory);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:45,代码来源:AssignmentManager.java


示例17: assignAllUserRegions

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Assigns all user regions, if any exist.  Used during cluster startup.
 * <p>
 * This is a synchronous call and will return once every region has been
 * assigned.  If anything fails, an exception is thrown and the cluster
 * should be shutdown.
 * @throws InterruptedException
 * @throws IOException
 * @throws KeeperException
 */
private void assignAllUserRegions()
    throws IOException, InterruptedException, KeeperException {
  // Cleanup any existing ZK nodes and start watching
  ZKAssign.deleteAllNodes(watcher);
  ZKUtil.listChildrenAndWatchForNewChildren(this.watcher,
    this.watcher.assignmentZNode);
  failoverCleanupDone();

  // Skip assignment for regions of tables in DISABLING state because during clean cluster startup
  // no RS is alive and regions map also doesn't have any information about the regions.
  // See HBASE-6281.
  Set<String> disabledOrDisablingOrEnabling = ZKTable.getDisabledOrDisablingTables(watcher);
  disabledOrDisablingOrEnabling.addAll(ZKTable.getEnablingTables(watcher));
  // Scan META for all user regions, skipping any disabled tables
  Map<HRegionInfo, ServerName> allRegions = MetaReader.fullScan(
    catalogTracker, disabledOrDisablingOrEnabling, true);
  if (allRegions == null || allRegions.isEmpty()) return;

  // Determine what type of assignment to do on startup
  boolean retainAssignment = server.getConfiguration().
    getBoolean("hbase.master.startup.retainassign", true);

  if (retainAssignment) {
    assign(allRegions);
  } else {
    List<HRegionInfo> regions = new ArrayList<HRegionInfo>(allRegions.keySet());
    assign(regions);
  }

  for (HRegionInfo hri : allRegions.keySet()) {
    String tableName = hri.getTableNameAsString();
    if (!zkTable.isEnabledTable(tableName)) {
      setEnabledTable(tableName);
    }
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:47,代码来源:AssignmentManager.java


示例18: recoverTableInDisablingState

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<String> disablingTables = ZKTable.getDisablingTables(watcher);
  if (disablingTables.size() != 0) {
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:23,代码来源:AssignmentManager.java


示例19: getZKTable

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
/**
 * @return Instance of ZKTable.
 */
public ZKTable getZKTable() {
  // These are 'expensive' to make involving trip to zk ensemble so allow
  // sharing.
  return this.zkTable;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:9,代码来源:AssignmentManager.java


示例20: testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches

import org.apache.hadoop.hbase.zookeeper.ZKTable; //导入依赖的package包/类
@Test
public void testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches()
    throws Exception {
  HRegion region = null;
  try {
    int testIndex = 0;
    TEST_UTIL.startMiniZKCluster();
    final Server server = new MockServer(TEST_UTIL);
    HTableDescriptor htd = new HTableDescriptor(
        "testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches");
    HRegionInfo hri = new HRegionInfo(htd.getName(),
        Bytes.toBytes(testIndex), Bytes.toBytes(testIndex + 1));
    region = HRegion.createHRegion(hri, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd);
    assertNotNull(region);
    AssignmentManager am = Mockito.mock(AssignmentManager.class);
    when(am.isRegionInTransition(hri)).thenReturn(
        new RegionState(region.getRegionInfo(), RegionState.State.OPEN,
            System.currentTimeMillis(), server.getServerName()));
    // create a node with OPENED state
    zkw = HBaseTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
        region, server.getServerName());
    when(am.getZKTable()).thenReturn(new ZKTable(zkw));
    Stat stat = new Stat();
    String nodeName = ZKAssign.getNodeName(zkw, region.getRegionInfo()
        .getEncodedName());
    ZKUtil.getDataAndWatch(zkw, nodeName, stat);

    // use the version for the OpenedRegionHandler
    OpenedRegionHandler handler = new OpenedRegionHandler(server, am, region
        .getRegionInfo(), server.getServerName(), stat.getVersion());
    // Once again overwrite the same znode so that the version changes.
    ZKAssign.transitionNode(zkw, region.getRegionInfo(), server
        .getServerName(), EventType.RS_ZK_REGION_OPENED,
        EventType.RS_ZK_REGION_OPENED, stat.getVersion());

    // Should not invoke assignmentmanager.regionOnline. If it is 
    // invoked as per current mocking it will throw null pointer exception.
    boolean expectedException = false;
    try {
      handler.process();
    } catch (Exception e) {
      expectedException = true;
    }
    assertFalse("The process method should not throw any exception.",
        expectedException);
    List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
        zkw.assignmentZNode);
    String regionName = znodes.get(0);
    assertEquals("The region should not be opened successfully.", regionName,
        region.getRegionInfo().getEncodedName());
  } finally {
    region.close();
    region.getLog().closeAndDelete();
    TEST_UTIL.shutdownMiniZKCluster();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:57,代码来源:TestOpenedRegionHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NBTPrimitive类代码示例发布时间:2022-05-22
下一篇:
Java RowQuery类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap