/** * Disable long-term archival of all hfiles for all tables in the cluster. * @return <tt>this</tt> for chaining. * @throws IOException if the number of attempts is exceeded */ public HFileArchiveManager disableHFileBackup() throws IOException { LOG.debug("Disabling backups on all tables."); try { ZKUtil.deleteNodeRecursively(this.zooKeeper, archiveZnode); return this; } catch (KeeperException e) { throw new IOException("Unexpected ZK exception!", e); } }
@Override public void removeQueue(ServerName serverName, String queueId) throws ReplicationException { try { ZKUtil.deleteNodeRecursively(zookeeper, getQueueNode(serverName, queueId)); } catch (KeeperException e) { throw new ReplicationException( "Failed to delete queue (serverName=" + serverName + ", queueId=" + queueId + ")", e); } }
@Override public void removePeer(String peerId) throws ReplicationException { try { ZKUtil.deleteNodeRecursively(zookeeper, getPeerNode(peerId)); } catch (KeeperException e) { throw new ReplicationException("Could not remove peer with id=" + peerId, e); } }
@Override public void removePeerFromHFileRefs(String peerId) throws ReplicationException { String peerNode = getHFileRefsPeerNode(peerId); try { if (ZKUtil.checkExists(zookeeper, peerNode) == -1) { LOG.debug("Peer {} not found in hfile reference queue.", peerNode); } else { LOG.info("Removing peer {} from hfile reference queue.", peerNode); ZKUtil.deleteNodeRecursively(zookeeper, peerNode); } } catch (KeeperException e) { throw new ReplicationException( "Failed to remove peer " + peerId + " from hfile reference queue.", e); } }
@After public void tearDown() throws KeeperException, IOException { ZKUtil.deleteNodeRecursively(zkw, replicationZNode); }
/** * 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(ZKWatcher 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); }
/** * Verifies that for the given root node, it should delete all the nodes recursively using * multi-update api. */ @Test public void testDeleteNodeRecursivelyMulti() throws Exception { String parentZNode = "/testdeleteNodeRecursivelyMulti"; createZNodeTree(parentZNode); ZKUtil.deleteNodeRecursively(zkw, parentZNode); assertTrue("Parent znode should be deleted.", ZKUtil.checkExists(zkw, parentZNode) == -1); }
@After public void after() throws Exception { TEST_UTIL.shutdownMiniHBaseCluster(); TEST_UTIL.getTestFileSystem().delete(FSUtils.getRootDir(TEST_UTIL.getConfiguration()), true); ZKUtil.deleteNodeRecursively(TEST_UTIL.getZooKeeperWatcher(), "/hbase"); }
/** * Create a znode with data */ @Test public void testCreateWithParents() throws KeeperException, InterruptedException { byte[] expectedData = new byte[] { 1, 2, 3 }; ZKUtil.createWithParents(ZKW, "/l1/l2/l3/l4/testCreateWithParents", expectedData); byte[] data = ZKUtil.getData(ZKW, "/l1/l2/l3/l4/testCreateWithParents"); assertTrue(Bytes.equals(expectedData, data)); ZKUtil.deleteNodeRecursively(ZKW, "/l1"); ZKUtil.createWithParents(ZKW, "/testCreateWithParents", expectedData); data = ZKUtil.getData(ZKW, "/testCreateWithParents"); assertTrue(Bytes.equals(expectedData, data)); ZKUtil.deleteNodeRecursively(ZKW, "/testCreateWithParents"); }
@After public void tearDown() throws KeeperException, ZooKeeperConnectionException, IOException { // Make sure zk is clean before we run the next test. ZKWatcher zkw = new ZKWatcher(TESTUTIL.getConfiguration(), "@Before", new Abortable() { @Override public void abort(String why, Throwable e) { throw new RuntimeException(why, e); } @Override public boolean isAborted() { return false; } }); ZKUtil.deleteNodeRecursively(zkw, zkw.getZNodePaths().baseZNode); zkw.close(); }
ZKUtil.deleteNodeRecursively(watcher, controller.getZkController().getBaseZnode()); assertEquals("Didn't delete prepare node", -1, ZKUtil.checkExists(watcher, prepare)); assertEquals("Didn't delete commit node", -1, ZKUtil.checkExists(watcher, commit));
/** * Create a bunch of znodes in a hierarchy, try deleting one that has childs (it will fail), then * delete it recursively, then delete the last znode */ @Test public void testZNodeDeletes() throws Exception { ZKUtil.createWithParents(ZKW, "/l1/l2/l3/l4"); try { ZKUtil.deleteNode(ZKW, "/l1/l2"); fail("We should not be able to delete if znode has childs"); } catch (KeeperException ex) { assertNotNull(ZKUtil.getDataNoWatch(ZKW, "/l1/l2/l3/l4", null)); } ZKUtil.deleteNodeRecursively(ZKW, "/l1/l2"); // make sure it really is deleted assertNull(ZKUtil.getDataNoWatch(ZKW, "/l1/l2/l3/l4", null)); // do the same delete again and make sure it doesn't crash ZKUtil.deleteNodeRecursively(ZKW, "/l1/l2"); ZKUtil.deleteNode(ZKW, "/l1"); assertNull(ZKUtil.getDataNoWatch(ZKW, "/l1/l2", null)); }
@After public void after() throws Exception { try { TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(10000); // Some regionserver could fail to delete its znode. // So shutdown could hang. Let's kill them all instead. TEST_UTIL.getHBaseCluster().killAll(); // Still need to clean things up TEST_UTIL.shutdownMiniHBaseCluster(); } finally { TEST_UTIL.getTestFileSystem().delete(FSUtils.getRootDir(TEST_UTIL.getConfiguration()), true); ZKUtil.deleteNodeRecursively(TEST_UTIL.getZooKeeperWatcher(), "/hbase"); } }
public void clearZNodes(String procedureName) throws KeeperException { // TODO This is potentially racy since not atomic. update when we support zk that has multi LOG.info("Clearing all znodes for procedure " + procedureName + "including nodes " + acquiredZnode + " " + reachedZnode + " " + abortZnode); ZKUtil.deleteNodeRecursively(watcher, getAcquiredBarrierNode(procedureName)); ZKUtil.deleteNodeRecursively(watcher, getReachedBarrierNode(procedureName)); ZKUtil.deleteNodeRecursively(watcher, getAbortZNode(procedureName)); } }
@Override public void removeQueue(ServerName serverName, String queueId) throws ReplicationException { try { ZKUtil.deleteNodeRecursively(zookeeper, getQueueNode(serverName, queueId)); } catch (KeeperException e) { throw new ReplicationException( "Failed to delete queue (serverName=" + serverName + ", queueId=" + queueId + ")", e); } }
@Override public void removePeer(String peerId) throws ReplicationException { try { ZKUtil.deleteNodeRecursively(zookeeper, getPeerNode(peerId)); } catch (KeeperException e) { throw new ReplicationException("Could not remove peer with id=" + peerId, e); } }
@After public void tearUp() throws IOException { try { ZKUtil.deleteNodeRecursively(zkw, ZookeeperWorkerRegister.THEMIS_ROOT_NODE); } catch (Exception e) { throw new IOException(e); } zkw.close(); super.tearUp(); }
/** * Verifies that for the given root node, it should delete all the nodes recursively using * multi-update api. */ @Test public void testDeleteNodeRecursivelyMulti() throws Exception { String parentZNode = "/testdeleteNodeRecursivelyMulti"; createZNodeTree(parentZNode); ZKUtil.deleteNodeRecursively(zkw, parentZNode); assertTrue("Parent znode should be deleted.", ZKUtil.checkExists(zkw, parentZNode) == -1); }
/** * Verifies that for the given root node, it should delete all the nodes recursively using * multi-update api. */ @Test public void testDeleteNodeRecursivelyMulti() throws Exception { String parentZNode = "/testdeleteNodeRecursivelyMulti"; createZNodeTree(parentZNode); ZKUtil.deleteNodeRecursively(zkw, parentZNode); assertTrue("Parent znode should be deleted.", ZKUtil.checkExists(zkw, parentZNode) == -1); }
@After public void after() throws Exception { TEST_UTIL.shutdownMiniHBaseCluster(); TEST_UTIL.getTestFileSystem().delete(FSUtils.getRootDir(TEST_UTIL.getConfiguration()), true); ZKUtil.deleteNodeRecursively(TEST_UTIL.getZooKeeperWatcher(), "/hbase"); }