Class ZKTableArchiveClient

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.hbase.backup.example.ZKTableArchiveClient
All Implemented Interfaces:
org.apache.hadoop.conf.Configurable

@Private public class ZKTableArchiveClient extends org.apache.hadoop.conf.Configured
Example class for how to use the table archiving coordinated via zookeeper
  • Field Details

  • Constructor Details

  • Method Details

    • enableHFileBackupAsync

      public void enableHFileBackupAsync(byte[] table) throws IOException, org.apache.zookeeper.KeeperException
      Turn on backups for all HFiles for the given table.

      All deleted hfiles are moved to the archive directory under the table directory, rather than being deleted.

      If backups are already enabled for this table, does nothing.

      If the table does not exist, the archiving the table's hfiles is still enabled as a future table with that name may be created shortly.

      Parameters:
      table - name of the table to start backing up
      Throws:
      IOException - if an unexpected exception occurs
      org.apache.zookeeper.KeeperException - if zookeeper can't be reached
    • disableHFileBackup

      public void disableHFileBackup(String table) throws IOException, org.apache.zookeeper.KeeperException
      Disable hfile backups for the given table.

      Previously backed up files are still retained (if present).

      Asynchronous operation - some extra HFiles may be retained, in the archive directory after disable is called, dependent on the latency in zookeeper to the servers.

      Parameters:
      table - name of the table stop backing up
      Throws:
      IOException - if an unexpected exception occurs
      org.apache.zookeeper.KeeperException - if zookeeper can't be reached
    • disableHFileBackup

      public void disableHFileBackup(byte[] table) throws IOException, org.apache.zookeeper.KeeperException
      Disable hfile backups for the given table.

      Previously backed up files are still retained (if present).

      Asynchronous operation - some extra HFiles may be retained, in the archive directory after disable is called, dependent on the latency in zookeeper to the servers.

      Parameters:
      table - name of the table stop backing up
      Throws:
      IOException - if an unexpected exception occurs
      org.apache.zookeeper.KeeperException - if zookeeper can't be reached
    • disableHFileBackup

      public void disableHFileBackup() throws IOException, org.apache.zookeeper.KeeperException
      Disable hfile backups for all tables.

      Previously backed up files are still retained (if present).

      Asynchronous operation - some extra HFiles may be retained, in the archive directory after disable is called, dependent on the latency in zookeeper to the servers.

      Throws:
      IOException - if an unexpected exception occurs
      org.apache.zookeeper.KeeperException - if zookeeper can't be reached
    • getArchivingEnabled

      public boolean getArchivingEnabled(byte[] table) throws IOException, org.apache.zookeeper.KeeperException
      Determine if archiving is enabled (but not necessarily fully propagated) for a table
      Parameters:
      table - name of the table to check
      Returns:
      true if it is, false otherwise
      Throws:
      IOException - if a connection to ZooKeeper cannot be established
      org.apache.zookeeper.KeeperException - if a ZooKeeper operation fails
    • getArchivingEnabled

      public boolean getArchivingEnabled(String table) throws IOException, org.apache.zookeeper.KeeperException
      Determine if archiving is enabled (but not necessarily fully propagated) for a table
      Parameters:
      table - name of the table to check
      Returns:
      true if it is, false otherwise
      Throws:
      IOException - if an unexpected network issue occurs
      org.apache.zookeeper.KeeperException - if zookeeper can't be reached
    • createHFileArchiveManager

      private HFileArchiveManager createHFileArchiveManager() throws org.apache.zookeeper.KeeperException, IOException
      Returns:
      A new HFileArchiveManager to manage which tables' hfiles should be archived rather than deleted.
      Throws:
      org.apache.zookeeper.KeeperException - if we can't reach zookeeper
      IOException - if an unexpected network issue occurs
    • getArchiveZNode

      public static String getArchiveZNode(org.apache.hadoop.conf.Configuration conf, ZKWatcher zooKeeper)
      Parameters:
      conf - conf to read for the base archive node
      zooKeeper - zookeeper to used for building the full path
      Returns:
      get the znode for long-term archival of a table for