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


Java ZooKeeperWatcher.sync方法代码示例

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


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

示例1: disable

import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; //导入方法依赖的package包/类
/**
 * Disable all archiving of files for a given table
 * <p>
 * Inherently an <b>asynchronous operation</b>.
 * @param zooKeeper watcher for the ZK cluster
 * @param table name of the table to disable
 * @throws KeeperException if an unexpected ZK connection issues occurs
 */
private void disable(ZooKeeperWatcher zooKeeper, byte[] table) throws KeeperException {
  // ensure the latest state of the archive node is found
  zooKeeper.sync(archiveZnode);

  // if the top-level archive node is gone, then we are done
  if (ZKUtil.checkExists(zooKeeper, archiveZnode) < 0) {
    return;
  }
  // delete the table node, from the archive
  String tableNode = this.getTableNode(table);
  // make sure the table is the latest version so the delete takes
  zooKeeper.sync(tableNode);

  LOG.debug("Attempting to delete table node:" + tableNode);
  ZKUtil.deleteNodeRecursively(zooKeeper, tableNode);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:HFileArchiveManager.java

示例2: verifyRegionState

import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; //导入方法依赖的package包/类
/**
 * Verifies that the specified region is in the specified state in ZooKeeper.
 * <p>
 * Returns true if region is in transition and in the specified state in
 * ZooKeeper.  Returns false if the region does not exist in ZK or is in
 * a different state.
 * <p>
 * Method synchronizes() with ZK so will yield an up-to-date result but is
 * a slow read.
 * @param zkw
 * @param region
 * @param expectedState
 * @return true if region exists and is in expected state
 * @throws DeserializationException
 */
static boolean verifyRegionState(ZooKeeperWatcher zkw, HRegionInfo region, EventType expectedState)
throws KeeperException, DeserializationException {
  String encoded = region.getEncodedName();

  String node = ZKAssign.getNodeName(zkw, encoded);
  zkw.sync(node);

  // Read existing data of the node
  byte [] existingBytes = null;
  try {
    existingBytes = ZKUtil.getDataAndWatch(zkw, node);
  } catch (KeeperException.NoNodeException nne) {
    return false;
  } catch (KeeperException e) {
    throw e;
  }
  if (existingBytes == null) return false;
  RegionTransition rt = RegionTransition.parseFrom(existingBytes);
  return rt.getEventType().equals(expectedState);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:Mocking.java


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