Java Code Examples for org.apache.hadoop.hbase.zookeeper.ZKUtil#deleteNodeRecursively()

The following examples show how to use org.apache.hadoop.hbase.zookeeper.ZKUtil#deleteNodeRecursively() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HFileArchiveManager.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * 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.syncOrTimeout(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.syncOrTimeout(tableNode);

  LOG.debug("Attempting to delete table node:" + tableNode);
  ZKUtil.deleteNodeRecursively(zooKeeper, tableNode);
}
 
Example 2
Source File: TestZooKeeper.java    From hbase with Apache License 2.0 6 votes vote down vote up
@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(CommonFSUtils.getRootDir(TEST_UTIL.getConfiguration()),
      true);
    ZKUtil.deleteNodeRecursively(TEST_UTIL.getZooKeeperWatcher(), "/hbase");
  }
}
 
Example 3
Source File: TestMasterNoCluster.java    From hbase with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 4
Source File: ZKReplicationQueueStorage.java    From hbase with Apache License 2.0 5 votes vote down vote up
@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);
  }
}
 
Example 5
Source File: ZKReplicationQueueStorage.java    From hbase with Apache License 2.0 5 votes vote down vote up
@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);
  }
}
 
Example 6
Source File: ZKReplicationPeerStorage.java    From hbase with Apache License 2.0 5 votes vote down vote up
@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);
  }
}
 
Example 7
Source File: HFileArchiveManager.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 8
Source File: AbstractTestDLS.java    From hbase with Apache License 2.0 5 votes vote down vote up
@After
public void after() throws Exception {
  TEST_UTIL.shutdownMiniHBaseCluster();
  TEST_UTIL.getTestFileSystem().delete(CommonFSUtils.getRootDir(TEST_UTIL.getConfiguration()),
    true);
  ZKUtil.deleteNodeRecursively(TEST_UTIL.getZooKeeperWatcher(), "/hbase");
}
 
Example 9
Source File: TestReplicationStateZKImpl.java    From hbase with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() throws KeeperException, IOException {
  ZKUtil.deleteNodeRecursively(zkw, replicationZNode);
}