org.apache.hadoop.hbase.backup.example
Class ZKTableArchiveClient

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

@InterfaceAudience.Private
public class ZKTableArchiveClient
extends org.apache.hadoop.conf.Configured

Example class for how to use the table archiving coordinated via zookeeper


Constructor Summary
ZKTableArchiveClient(org.apache.hadoop.conf.Configuration conf, HConnection connection)
           
 
Method Summary
 void disableHFileBackup()
          Disable hfile backups for all tables.
 void disableHFileBackup(byte[] table)
          Disable hfile backups for the given table.
 void disableHFileBackup(String table)
          Disable hfile backups for the given table.
 void enableHFileBackupAsync(byte[] table)
          Turn on backups for all HFiles for the given table.
static String getArchiveZNode(org.apache.hadoop.conf.Configuration conf, ZooKeeperWatcher zooKeeper)
           
 boolean getArchivingEnabled(byte[] table)
          Determine if archiving is enabled (but not necessarily fully propagated) for a table
 boolean getArchivingEnabled(String table)
          Determine if archiving is enabled (but not necessarily fully propagated) for a table
 
Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZKTableArchiveClient

public ZKTableArchiveClient(org.apache.hadoop.conf.Configuration conf,
                            HConnection connection)
Method Detail

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

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

getArchiveZNode

public static String getArchiveZNode(org.apache.hadoop.conf.Configuration conf,
                                     ZooKeeperWatcher 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


Copyright © 2015 The Apache Software Foundation. All rights reserved.