本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.createEphemeralNodeAndWatch()
方法的一些代码示例,展示了ZKUtil.createEphemeralNodeAndWatch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.createEphemeralNodeAndWatch()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:createEphemeralNodeAndWatch
[英]Set the specified znode to be an ephemeral node carrying the specified data. If the node is created successfully, a watcher is also set on the node. If the node is not created successfully because it already exists, this method will also set a watcher on the node. If there is another problem, a KeeperException will be thrown.
[中]将指定的znode设置为携带指定数据的临时节点。如果节点创建成功,也会在节点上设置观察者。如果由于节点已存在而未能成功创建该节点,则此方法还将在该节点上设置观察者。如果还有其他问题,将抛出KeeperException。
代码示例来源:origin: apache/hbase
/**
* Set master address into the <code>master</code> znode or into the backup
* subdirectory of backup masters; switch off the passed in <code>znode</code>
* path.
* @param zkw The ZKWatcher to use.
* @param znode Where to create the znode; could be at the top level or it
* could be under backup masters
* @param master ServerName of the current master must not be null.
* @return true if node created, false if not; a watch is set in both cases
* @throws KeeperException if a ZooKeeper operation fails
*/
public static boolean setMasterAddress(final ZKWatcher zkw,
final String znode, final ServerName master, int infoPort)
throws KeeperException {
return ZKUtil.createEphemeralNodeAndWatch(zkw, znode, toByteArray(master, infoPort));
}
代码示例来源:origin: apache/hbase
return createEphemeralNodeAndWatch(zkw, znode, data);
代码示例来源:origin: apache/hbase
while (!candidate.isStopped()) {
try {
if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
代码示例来源:origin: apache/hbase
do {
try {
hbckZodeCreated = ZKUtil.createEphemeralNodeAndWatch(zkw, hbckEphemeralNodePath, null);
if (hbckZodeCreated) {
break;
代码示例来源:origin: apache/hbase
private void createMyEphemeralNode() throws KeeperException, IOException {
RegionServerInfo.Builder rsInfo = RegionServerInfo.newBuilder();
rsInfo.setInfoPort(infoServer != null ? infoServer.getPort() : -1);
rsInfo.setVersionInfo(ProtobufUtil.getVersionInfo());
byte[] data = ProtobufUtil.prependPBMagic(rsInfo.build().toByteArray());
ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper, getMyEphemeralNodePath(), data);
}
代码示例来源:origin: XiaoMi/themis
private void createMyEphemeralNode() throws Exception {
createAliveParentNode();
ZKUtil.createEphemeralNodeAndWatch(this.watcher, aliveClientPath, Bytes.toBytes(clientNameStr));
}
代码示例来源:origin: co.cask.hbase/hbase
private void createMyEphemeralNode() throws KeeperException {
ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper, getMyEphemeralNodePath(),
HConstants.EMPTY_BYTE_ARRAY);
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
/**
* Set master address into the <code>master</code> znode or into the backup
* subdirectory of backup masters; switch off the passed in <code>znode</code>
* path.
* @param zkw The ZKWatcher to use.
* @param znode Where to create the znode; could be at the top level or it
* could be under backup masters
* @param master ServerName of the current master must not be null.
* @return true if node created, false if not; a watch is set in both cases
* @throws KeeperException if a ZooKeeper operation fails
*/
public static boolean setMasterAddress(final ZKWatcher zkw,
final String znode, final ServerName master, int infoPort)
throws KeeperException {
return ZKUtil.createEphemeralNodeAndWatch(zkw, znode, toByteArray(master, infoPort));
}
代码示例来源:origin: harbby/presto-connectors
/**
* Set master address into the <code>master</code> znode or into the backup
* subdirectory of backup masters; switch off the passed in <code>znode</code>
* path.
* @param zkw The ZooKeeperWatcher to use.
* @param znode Where to create the znode; could be at the top level or it
* could be under backup masters
* @param master ServerName of the current master must not be null.
* @return true if node created, false if not; a watch is set in both cases
* @throws KeeperException
*/
public static boolean setMasterAddress(final ZooKeeperWatcher zkw,
final String znode, final ServerName master, int infoPort)
throws KeeperException {
return ZKUtil.createEphemeralNodeAndWatch(zkw, znode, toByteArray(master, infoPort));
}
代码示例来源:origin: co.cask.hbase/hbase
if(!watchAndCheckExists(zkw, znode)) {
return createEphemeralNodeAndWatch(zkw, znode, data);
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
return createEphemeralNodeAndWatch(zkw, znode, data);
代码示例来源:origin: co.cask.hbase/hbase
while (!candidate.isStopped()) {
try {
if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
while (!candidate.isStopped()) {
try {
if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
代码示例来源:origin: harbby/presto-connectors
return createEphemeralNodeAndWatch(zkw, znode, data);
代码示例来源:origin: co.cask.hbase/hbase
/**
* Creates a new ephemeral node in the SPLITTING state for the specified region.
* Create it ephemeral in case regionserver dies mid-split.
*
* <p>Does not transition nodes from other states. If a node already exists
* for this region, a {@link NodeExistsException} will be thrown.
*
* @param zkw zk reference
* @param region region to be created as offline
* @param serverName server event originates from
* @return Version of znode created.
* @throws KeeperException
* @throws IOException
*/
void createNodeSplitting(final ZooKeeperWatcher zkw, final HRegionInfo region,
final ServerName serverName) throws KeeperException, IOException {
LOG.debug(zkw.prefix("Creating ephemeral node for " +
region.getEncodedName() + " in SPLITTING state"));
RegionTransitionData data =
new RegionTransitionData(EventType.RS_ZK_REGION_SPLITTING,
region.getRegionName(), serverName);
String node = ZKAssign.getNodeName(zkw, region.getEncodedName());
if (!ZKUtil.createEphemeralNodeAndWatch(zkw, node, data.getBytes())) {
throw new IOException("Failed create of ephemeral " + node);
}
}
代码示例来源:origin: co.cask.hbase/hbase
String backupZNode = ZKUtil.joinZNode(
this.watcher.backupMasterAddressesZNode, this.sn.toString());
if (ZKUtil.createEphemeralNodeAndWatch(this.watcher,
this.watcher.masterAddressZNode, this.sn.getVersionedBytes())) {
ZKUtil.createEphemeralNodeAndWatch(this.watcher, backupZNode,
this.sn.getVersionedBytes());
代码示例来源:origin: harbby/presto-connectors
/**
* Creates a new ephemeral node in the PENDING_MERGE state for the merged region.
* Create it ephemeral in case regionserver dies mid-merge.
*
* <p>
* Does not transition nodes from other states. If a node already exists for
* this region, a {@link org.apache.zookeeper.KeeperException.NodeExistsException} will be thrown.
*
* @param region region to be created as offline
* @param serverName server event originates from
* @throws IOException
*/
@Override
public void startRegionMergeTransaction(final HRegionInfo region, final ServerName serverName,
final HRegionInfo a, final HRegionInfo b) throws IOException {
LOG.debug(watcher.prefix("Creating ephemeral node for " + region.getEncodedName()
+ " in PENDING_MERGE state"));
byte[] payload = HRegionInfo.toDelimitedByteArray(region, a, b);
RegionTransition rt =
RegionTransition.createRegionTransition(RS_ZK_REQUEST_REGION_MERGE, region.getRegionName(),
serverName, payload);
String node = ZKAssign.getNodeName(watcher, region.getEncodedName());
try {
if (!ZKUtil.createEphemeralNodeAndWatch(watcher, node, rt.toByteArray())) {
throw new IOException("Failed create of ephemeral " + node);
}
} catch (KeeperException e) {
throw new IOException(e);
}
}
代码示例来源:origin: harbby/presto-connectors
while (!candidate.isStopped()) {
try {
if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
代码示例来源:origin: harbby/presto-connectors
private void createMyEphemeralNode() throws KeeperException, IOException {
RegionServerInfo.Builder rsInfo = RegionServerInfo.newBuilder();
rsInfo.setInfoPort(infoServer != null ? infoServer.getPort() : -1);
rsInfo.setVersionInfo(ProtobufUtil.getVersionInfo());
byte[] data = ProtobufUtil.prependPBMagic(rsInfo.build().toByteArray());
ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper,
getMyEphemeralNodePath(), data);
}
代码示例来源:origin: harbby/presto-connectors
region.getRegionName(), serverName, payload);
String node = ZKAssign.getNodeName(watcher, region.getEncodedName());
if (!ZKUtil.createEphemeralNodeAndWatch(watcher, node, rt.toByteArray())) {
throw new IOException("Failed create of ephemeral " + node);
内容来源于网络,如有侵权,请联系作者删除!