/** * 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)); }
return createEphemeralNodeAndWatch(zkw, znode, data);
while (!candidate.isStopped()) { try { if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
do { try { hbckZodeCreated = ZKUtil.createEphemeralNodeAndWatch(zkw, hbckEphemeralNodePath, null); if (hbckZodeCreated) { break;
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); }
private void createMyEphemeralNode() throws Exception { createAliveParentNode(); ZKUtil.createEphemeralNodeAndWatch(this.watcher, aliveClientPath, Bytes.toBytes(clientNameStr)); }
private void createMyEphemeralNode() throws KeeperException { ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper, getMyEphemeralNodePath(), HConstants.EMPTY_BYTE_ARRAY); }
/** * 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)); }
/** * 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)); }
if(!watchAndCheckExists(zkw, znode)) { return createEphemeralNodeAndWatch(zkw, znode, data);
return createEphemeralNodeAndWatch(zkw, znode, data);
while (!candidate.isStopped()) { try { if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
while (!candidate.isStopped()) { try { if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
return createEphemeralNodeAndWatch(zkw, znode, data);
/** * 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); } }
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());
/** * 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); } }
while (!candidate.isStopped()) { try { if (ZKUtil.createEphemeralNodeAndWatch(watcher, leaderZNode, nodeId)) {
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); }
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);