@InterfaceAudience.Private public final class TableHFileArchiveTracker extends ZKListener
start()
needs to be called to start monitoring for tables to
archive.
Modifier and Type | Field and Description |
---|---|
private String |
archiveHFileZNode |
static String |
HFILE_ARCHIVE_ZNODE_PARENT |
private static org.slf4j.Logger |
LOG |
private HFileArchiveTableMonitor |
monitor |
private boolean |
stopped |
watcher
Modifier | Constructor and Description |
---|---|
private |
TableHFileArchiveTracker(ZKWatcher watcher,
HFileArchiveTableMonitor monitor) |
Modifier and Type | Method and Description |
---|---|
private void |
addAndReWatchTable(String tableZnode)
Add this table to the tracker and then read a watch on that node.
|
private void |
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).
|
private void |
clearTables()
Remove the currently archived tables.
|
static TableHFileArchiveTracker |
create(org.apache.hadoop.conf.Configuration conf)
Create an archive tracker for the passed in server
|
private static TableHFileArchiveTracker |
create(ZKWatcher zkw,
HFileArchiveTableMonitor monitor)
Create an archive tracker with the special passed in table monitor.
|
HFileArchiveTableMonitor |
getMonitor() |
ZKWatcher |
getZooKeeperWatcher() |
boolean |
keepHFiles(String tableName)
Determine if the given table should or should not allow its hfiles to be deleted
|
void |
nodeChildrenChanged(String path)
Called when an existing node has a child node added or removed.
|
void |
nodeCreated(String path)
Called when a new node has been created.
|
void |
nodeDeleted(String path)
Called when a node has been deleted
|
private void |
safeStopTrackingTable(String tableZnode)
Stop tracking a table.
|
void |
start()
Start monitoring for archive updates
|
void |
stop()
Stop this tracker and the passed zookeeper
|
private void |
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
|
getWatcher, nodeDataChanged
private static final org.slf4j.Logger LOG
public static final String HFILE_ARCHIVE_ZNODE_PARENT
private HFileArchiveTableMonitor monitor
private String archiveHFileZNode
private boolean stopped
private TableHFileArchiveTracker(ZKWatcher watcher, HFileArchiveTableMonitor monitor)
public void start() throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
- on failure to find/create nodespublic void nodeCreated(String path)
ZKListener
nodeCreated
in class ZKListener
path
- full path of the new nodepublic void nodeChildrenChanged(String path)
ZKListener
nodeChildrenChanged
in class ZKListener
path
- full path of the node whose children have changedprivate void addAndReWatchTable(String tableZnode) throws org.apache.zookeeper.KeeperException
Handles situation where table is deleted in the time between the update and resetting the watch
by deleting the table via safeStopTrackingTable(String)
tableZnode
- full zookeeper path to the table to be addedorg.apache.zookeeper.KeeperException
- if an unexpected zk exception occursprivate void safeStopTrackingTable(String tableZnode) throws org.apache.zookeeper.KeeperException
addAndReWatchTable(String)
- its a 'safe' removal.tableZnode
- full zookeeper path to the table to be addedorg.apache.zookeeper.KeeperException
- if an unexpected zk exception occurspublic void nodeDeleted(String path)
ZKListener
nodeDeleted
in class ZKListener
path
- full path of the deleted nodeprivate void checkEnabledAndUpdate()
private void updateWatchedTables() throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
- if there is an unexpected zk exceptionprivate void clearTables()
Does some intelligent checking to make sure we don't prematurely create an archive tracker.
public boolean keepHFiles(String tableName)
tableName
- name of the table to checkpublic final HFileArchiveTableMonitor getMonitor()
public static TableHFileArchiveTracker create(org.apache.hadoop.conf.Configuration conf) throws ZooKeeperConnectionException, IOException
conf
- to read for zookeeper connection informationIOException
- If a unexpected exception occursZooKeeperConnectionException
- if we can't reach zookeeperprivate static TableHFileArchiveTracker create(ZKWatcher zkw, HFileArchiveTableMonitor monitor)
zkw
- Watcher for the ZooKeeper cluster that we should trackmonitor
- Monitor for which tables need hfile archivingpublic ZKWatcher getZooKeeperWatcher()
public void stop()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.