Class HFileArchiveManager

java.lang.Object
org.apache.hadoop.hbase.backup.example.HFileArchiveManager

@Private class HFileArchiveManager extends Object
Client-side manager for which table's hfiles should be preserved for long-term archive.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • enableHFileBackup

      public HFileArchiveManager enableHFileBackup(byte[] table) throws org.apache.zookeeper.KeeperException
      Turn on auto-backups of HFiles on the specified table.

      When HFiles would be deleted from the hfile archive, they are instead preserved.

      Parameters:
      table - name of the table for which to preserve hfiles.
      Returns:
      this for chaining.
      Throws:
      org.apache.zookeeper.KeeperException - if we can't reach zookeeper to update the hfile cleaner.
    • disableHFileBackup

      public HFileArchiveManager disableHFileBackup(byte[] table) throws org.apache.zookeeper.KeeperException
      Stop retaining HFiles for the given table in the archive. HFiles will be cleaned up on the next pass of the HFileCleaner, if the HFiles are retained by another cleaner.
      Parameters:
      table - name of the table for which to disable hfile retention.
      Returns:
      this for chaining.
      Throws:
      org.apache.zookeeper.KeeperException - if if we can't reach zookeeper to update the hfile cleaner.
    • disableHFileBackup

      Disable long-term archival of all hfiles for all tables in the cluster.
      Returns:
      this for chaining.
      Throws:
      IOException - if the number of attempts is exceeded
    • enable

      private void enable(ZKWatcher zooKeeper, byte[] table) throws org.apache.zookeeper.KeeperException
      Perform a best effort enable of hfile retention, which relies on zookeeper communicating the change back to the hfile cleaner.

      No attempt is made to make sure that backups are successfully created - it is inherently an asynchronous operation.

      Parameters:
      zooKeeper - watcher connection to zk cluster
      table - table name on which to enable archiving
      Throws:
      org.apache.zookeeper.KeeperException - if a ZooKeeper operation fails
    • disable

      private void disable(ZKWatcher zooKeeper, byte[] table) throws org.apache.zookeeper.KeeperException
      Disable all archiving of files for a given table

      Inherently an asynchronous operation.

      Parameters:
      zooKeeper - watcher for the ZK cluster
      table - name of the table to disable
      Throws:
      org.apache.zookeeper.KeeperException - if an unexpected ZK connection issues occurs
    • stop

      public void stop()
    • isArchivingEnabled

      public boolean isArchivingEnabled(byte[] table) throws org.apache.zookeeper.KeeperException
      Check to see if the table is currently marked for archiving
      Parameters:
      table - name of the table to check
      Returns:
      true if the archive znode for that table exists, false if not
      Throws:
      org.apache.zookeeper.KeeperException - if an unexpected zookeeper error occurs
    • getTableNode

      private String getTableNode(byte[] table)
      Get the zookeeper node associated with archiving the given table
      Parameters:
      table - name of the table to check
      Returns:
      znode for the table's archive status