/** * Gets the full path node name for the log file being split. * This method will url encode the filename. * @param zkw zk reference * @param filename log file name (only the basename) */ public static String getEncodedNodeName(ZKWatcher zkw, String filename) { return ZNodePaths.joinZNode(zkw.getZNodePaths().splitLogZNode, encode(filename)); }
/** * Starts the tracking of whether master is in Maintenance Mode. */ public void start() { watcher.registerListener(this); update(); }
/** * Sets the cluster as up. * @throws KeeperException unexpected zk exception */ public void setClusterUp() throws KeeperException { byte [] upData = toByteArray(); try { ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } catch(KeeperException.NodeExistsException nee) { ZKUtil.setData(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } }
private static String initPeerClusterState(String baseZKNode) throws IOException, KeeperException { // Add a dummy region server and set up the cluster id Configuration testConf = new Configuration(conf); testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode); ZKWatcher zkw1 = new ZKWatcher(testConf, "test1", null); String fakeRs = ZNodePaths.joinZNode(zkw1.getZNodePaths().rsZNode, "hostname1.example.org:1234"); ZKUtil.createWithParents(zkw1, fakeRs); ZKClusterId.setClusterId(zkw1, new ClusterId()); return ZKConfig.getZooKeeperClusterKey(testConf); }
/** * Set the znode perms recursively. This will do post-order recursion, so that baseZnode ACLs * will be set last in case the master fails in between. * @param znode the ZNode to set the permissions for */ private void setZnodeAclsRecursive(String znode) throws KeeperException, InterruptedException { List<String> children = recoverableZooKeeper.getChildren(znode, false); for (String child : children) { setZnodeAclsRecursive(ZNodePaths.joinZNode(znode, child)); } List<ACL> acls = ZKUtil.createACL(this, znode, true); LOG.info("Setting ACLs for znode:" + znode + " , acl:" + acls); recoverableZooKeeper.setAcl(znode, acls, -1); }
/** * Set region normalizer on/off * @param normalizerOn whether normalizer should be on or off * @throws KeeperException if a ZooKeeper operation fails */ public void setNormalizerOn(boolean normalizerOn) throws KeeperException { byte [] upData = toByteArray(normalizerOn); try { ZKUtil.setData(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData); } catch(KeeperException.NoNodeException nne) { ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData); } super.nodeDataChanged(watcher.getZNodePaths().regionNormalizerZNode); }
/** * Set the balancer on/off. * * @param balancerOn true if the balancher should be on, false otherwise * @throws KeeperException if a ZooKeeper operation fails */ public void setBalancerOn(boolean balancerOn) throws KeeperException { byte [] upData = toByteArray(balancerOn); try { ZKUtil.setData(watcher, watcher.getZNodePaths().balancerZNode, upData); } catch(KeeperException.NoNodeException nne) { ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().balancerZNode, upData); } super.nodeDataChanged(watcher.getZNodePaths().balancerZNode); }
private List<String> getRegionServersInZK(final ZKWatcher zkw) throws KeeperException { return ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode); }
/** * Deletes the specified node. Fails silent if the node does not exist. * * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation * @param node the node to delete * @throws KeeperException if a ZooKeeper operation fails */ public static void deleteNodeFailSilent(ZKWatcher zkw, String node) throws KeeperException { deleteNodeFailSilent(zkw, (DeleteNodeFailSilent)ZKUtilOp.deleteNodeFailSilent(node)); }
@Override boolean validate(String path) { return watcher.getZNodePaths().isAnyMetaReplicaZNode(path); }
private static ArrayList<ACL> createACL(ZKWatcher zkw, String node) { return createACL(zkw, node, isSecureZooKeeper(zkw.getConfiguration())); }
/** * Stop this tracker and the passed zookeeper */ public void stop() { if (this.stopped) return; this.stopped = true; this.watcher.close(); } }
ZKAsyncRegistry(Configuration conf) { this.znodePaths = new ZNodePaths(conf); this.zk = new ReadOnlyZKClient(conf); }
public WaitToGetDataThread(ZKWatcher zk, String node) { tracker = new TestTracker(zk, node, null); tracker.start(); zk.registerListener(tracker); hasData = false; }
void doWaiting() throws InterruptedException { try { for (;;) { if (MetaTableLocator.waitMetaRegionLocation(watcher, 10000) != null) { break; } } } catch (NotAllMetaRegionsOnlineException e) { // Ignore } } }
/** * @param zkw ZooKeeper watcher to be used * @return meta table regions and their locations. */ public static List<Pair<RegionInfo, ServerName>> getMetaRegionsAndLocations(ZKWatcher zkw) { return getMetaRegionsAndLocations(zkw, RegionInfo.DEFAULT_REPLICA_ID); }
@Override public String getWALFile() { return ZKSplitLog.getFileName(taskNode); } }
/** * Return the ZK Quorum servers string given the specified configuration. * @return Quorum servers */ public static String getZKQuorumServersString(Configuration conf) { return getZKQuorumServersStringFromHbaseConfig(conf); }
@Override public final void exec(ZooKeeper zk) { pendingRequests++; doExec(zk); }
@Override public void nodeChildrenChanged(String path) { update(path); } }