Class TableHFileArchiveTracker
java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKListener
org.apache.hadoop.hbase.backup.example.TableHFileArchiveTracker
Track HFile archiving state changes in ZooKeeper. Keeps track of the tables whose HFiles should
be kept in the archive.
start() needs to be called to start monitoring for tables to
archive.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringstatic final Stringprivate static final org.slf4j.Loggerprivate HFileArchiveTableMonitorprivate booleanFields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTableHFileArchiveTracker(ZKWatcher watcher, HFileArchiveTableMonitor monitor) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddAndReWatchTable(String tableZnode) Add this table to the tracker and then read a watch on that node.private voidSets the watch on the top-level archive znode, and then updates the monitor with the current tables that should be archived (and ensures that those nodes are watched as well).private voidRemove the currently archived tables.static TableHFileArchiveTrackercreate(org.apache.hadoop.conf.Configuration conf) Create an archive tracker for the passed in serverprivate static TableHFileArchiveTrackercreate(ZKWatcher zkw, HFileArchiveTableMonitor monitor) Create an archive tracker with the special passed in table monitor.final HFileArchiveTableMonitorReturns the tracker for which tables should be archived.booleankeepHFiles(String tableName) Determine if the given table should or should not allow its hfiles to be deletedvoidnodeChildrenChanged(String path) Called when an existing node has a child node added or removed.voidnodeCreated(String path) Called when a new node has been created.voidnodeDeleted(String path) Called when a node has been deletedprivate voidsafeStopTrackingTable(String tableZnode) Stop tracking a table.voidstart()Start monitoring for archive updatesvoidstop()Stop this tracker and the passed zookeeperprivate voidRead the list of children under the archive znode as table names and then sets those tables to the list of tables that we should archiveMethods inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
getWatcher, nodeDataChanged
-
Field Details
-
LOG
-
HFILE_ARCHIVE_ZNODE_PARENT
- See Also:
-
monitor
-
archiveHFileZNode
-
stopped
-
-
Constructor Details
-
TableHFileArchiveTracker
-
-
Method Details
-
start
Start monitoring for archive updates- Throws:
org.apache.zookeeper.KeeperException- on failure to find/create nodes
-
nodeCreated
Description copied from class:ZKListenerCalled when a new node has been created.- Overrides:
nodeCreatedin classZKListener- Parameters:
path- full path of the new node
-
nodeChildrenChanged
Description copied from class:ZKListenerCalled when an existing node has a child node added or removed.- Overrides:
nodeChildrenChangedin classZKListener- Parameters:
path- full path of the node whose children have changed
-
addAndReWatchTable
Add this table to the tracker and then read a watch on that node.Handles situation where table is deleted in the time between the update and resetting the watch by deleting the table via
safeStopTrackingTable(String)- Parameters:
tableZnode- full zookeeper path to the table to be added- Throws:
org.apache.zookeeper.KeeperException- if an unexpected zk exception occurs
-
safeStopTrackingTable
Stop tracking a table. Ensures that the table doesn't exist, but if it does, it attempts to add the table back viaaddAndReWatchTable(String)- its a 'safe' removal.- Parameters:
tableZnode- full zookeeper path to the table to be added- Throws:
org.apache.zookeeper.KeeperException- if an unexpected zk exception occurs
-
nodeDeleted
Description copied from class:ZKListenerCalled when a node has been deleted- Overrides:
nodeDeletedin classZKListener- Parameters:
path- full path of the deleted node
-
checkEnabledAndUpdate
Sets the watch on the top-level archive znode, and then updates the monitor with the current tables that should be archived (and ensures that those nodes are watched as well). -
updateWatchedTables
Read the list of children under the archive znode as table names and then sets those tables to the list of tables that we should archive- Throws:
org.apache.zookeeper.KeeperException- if there is an unexpected zk exception
-
clearTables
Remove the currently archived tables.Does some intelligent checking to make sure we don't prematurely create an archive tracker.
-
keepHFiles
Determine if the given table should or should not allow its hfiles to be deleted- Parameters:
tableName- name of the table to check- Returns:
- true if its store files should be retained, false otherwise
-
getMonitor
Returns the tracker for which tables should be archived. -
create
public static TableHFileArchiveTracker create(org.apache.hadoop.conf.Configuration conf) throws ZooKeeperConnectionException, IOException Create an archive tracker for the passed in server- Parameters:
conf- to read for zookeeper connection information- Returns:
- ZooKeeper tracker to monitor for this server if this server should archive hfiles for a given table
- Throws:
IOException- If a unexpected exception occursZooKeeperConnectionException- if we can't reach zookeeper
-
create
Create an archive tracker with the special passed in table monitor. Should only be used in special cases (e.g. testing)- Parameters:
zkw- Watcher for the ZooKeeper cluster that we should trackmonitor- Monitor for which tables need hfile archiving- Returns:
- ZooKeeper tracker to monitor for this server if this server should archive hfiles for a given table
-
getZooKeeperWatcher
-
stop
Stop this tracker and the passed zookeeper
-