@InterfaceAudience.Private public class ZKTableStateManager extends Object implements TableStateManager
ZKTableStateClientSideReader instead.
To save on trips to the zookeeper ensemble, internally we cache table state.
| Modifier and Type | Field and Description |
|---|---|
private Map<TableName,org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State> |
cache
Cache of what we found in zookeeper so we don't have to go to zk ensemble
for every query.
|
private static org.apache.commons.logging.Log |
LOG |
private ZooKeeperWatcher |
watcher |
| Constructor and Description |
|---|
ZKTableStateManager(ZooKeeperWatcher zkw) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkAndRemoveTableState(TableName tableName,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State states,
boolean deletePermanentState)
If the table is found in the given state the in-memory state is removed.
|
(package private) Set<TableName> |
getAllTables(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
Gets a list of all the tables of specified states in zookeeper.
|
Set<TableName> |
getTablesInStates(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
Gets a list of all the tables set as disabling in zookeeper.
|
private org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State |
getTableState(ZooKeeperWatcher zkw,
TableName tableName)
Gets table state from ZK.
|
private boolean |
isTableInState(List<org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State> expectedStates,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State currentState) |
boolean |
isTablePresent(TableName tableName)
check if table is present.
|
boolean |
isTableState(TableName tableName,
boolean checkSource,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
Checks if table is marked in specified state in ZK.
|
boolean |
isTableState(TableName tableName,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
Checks if table is marked in specified state in ZK (using cache only).
|
private void |
populateTableStates()
Gets a list of all the tables set as disabled in zookeeper.
|
void |
setDeletedTable(TableName tableName)
Deletes the table in zookeeper.
|
void |
setTableState(TableName tableName,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State state)
Sets table state in ZK.
|
boolean |
setTableStateIfInStates(TableName tableName,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State newState,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
Checks and sets table state in ZK.
|
boolean |
setTableStateIfNotInStates(TableName tableName,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State newState,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
Checks and sets table state in ZK.
|
private void |
setTableStateInZK(TableName tableName,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State state) |
private static final org.apache.commons.logging.Log LOG
private final ZooKeeperWatcher watcher
private final Map<TableName,org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State> cache
public ZKTableStateManager(ZooKeeperWatcher zkw) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperExceptionInterruptedExceptionprivate void populateTableStates()
throws org.apache.zookeeper.KeeperException,
InterruptedException
KeeperException, - InterruptedExceptionorg.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic void setTableState(TableName tableName, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State state) throws CoordinatedStateException
setTableState in interface TableStateManagertableName - table to processstate - new state of this tableCoordinatedStateException - if error happened when trying to set table statepublic boolean setTableStateIfInStates(TableName tableName, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State newState, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states) throws CoordinatedStateException
setTableStateIfInStates in interface TableStateManagertableName - table to processnewState - new state for the tablestates - table should be in one of these states for the operation
to be performedCoordinatedStateException - if error happened while performing operationpublic boolean setTableStateIfNotInStates(TableName tableName, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State newState, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states) throws CoordinatedStateException
setTableStateIfNotInStates in interface TableStateManagertableName - table to processnewState - new state for the tablestates - table should NOT be in one of these states for the operation
to be performedCoordinatedStateException - if error happened while performing operationprivate void setTableStateInZK(TableName tableName, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State state) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperExceptionpublic boolean isTableState(TableName tableName, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
isTableState in interface TableStateManagerpublic boolean isTableState(TableName tableName, boolean checkSource, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states)
isTableState in interface TableStateManagerpublic void setDeletedTable(TableName tableName) throws CoordinatedStateException
setDeletedTable in interface TableStateManagertableName - table to be deletedCoordinatedStateException - if error happened while performing operationpublic boolean isTablePresent(TableName tableName)
isTablePresent in interface TableStateManagertableName - table we're working onpublic Set<TableName> getTablesInStates(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states) throws InterruptedIOException, CoordinatedStateException
getTablesInStates in interface TableStateManagerCoordinatedStateException - if error happened in underlying coordination engineInterruptedIOExceptionpublic void checkAndRemoveTableState(TableName tableName, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State states, boolean deletePermanentState) throws CoordinatedStateException
checkAndRemoveTableState in interface TableStateManagertableName - table we're working onstates - if table isn't in any one of these states, operation abortsdeletePermanentState - if true, reset the permanent flagCoordinatedStateException - if error happened in underlying coordination engineSet<TableName> getAllTables(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State... states) throws org.apache.zookeeper.KeeperException, InterruptedIOException
org.apache.zookeeper.KeeperExceptionInterruptedIOExceptionprivate org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State getTableState(ZooKeeperWatcher zkw, TableName tableName) throws org.apache.zookeeper.KeeperException, InterruptedException
zkw - ZooKeeperWatcher instance to usetableName - table we're checkingZooKeeperProtos.Table.State found in znode.org.apache.zookeeper.KeeperExceptionInterruptedExceptionprivate boolean isTableInState(List<org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State> expectedStates, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State currentState)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.