@InterfaceAudience.Private public class ZKTableStateManager extends Object implements TableStateManager
ZKTableStateClientSideReader
instead.
To save on trips to the zookeeper ensemble, internally we cache table state.
Constructor and Description |
---|
ZKTableStateManager(ZooKeeperWatcher zkw) |
Modifier and Type | Method and Description |
---|---|
void |
checkAndRemoveTableState(TableName tableName,
ZooKeeperProtos.Table.State states,
boolean deletePermanentState)
If the table is found in the given state the in-memory state is removed.
|
Set<TableName> |
getTablesInStates(ZooKeeperProtos.Table.State... states)
Gets a list of all the tables set as disabling in zookeeper.
|
boolean |
isTablePresent(TableName tableName)
check if table is present.
|
boolean |
isTableState(TableName tableName,
boolean checkSource,
ZooKeeperProtos.Table.State... states)
Checks if table is marked in specified state in ZK.
|
boolean |
isTableState(TableName tableName,
ZooKeeperProtos.Table.State... states)
Checks if table is marked in specified state in ZK (using cache only).
|
void |
setDeletedTable(TableName tableName)
Deletes the table in zookeeper.
|
void |
setTableState(TableName tableName,
ZooKeeperProtos.Table.State state)
Sets table state in ZK.
|
boolean |
setTableStateIfInStates(TableName tableName,
ZooKeeperProtos.Table.State newState,
ZooKeeperProtos.Table.State... states)
Checks and sets table state in ZK.
|
boolean |
setTableStateIfNotInStates(TableName tableName,
ZooKeeperProtos.Table.State newState,
ZooKeeperProtos.Table.State... states)
Checks and sets table state in ZK.
|
public ZKTableStateManager(ZooKeeperWatcher zkw) throws KeeperException, InterruptedException
KeeperException
InterruptedException
public void setTableState(TableName tableName, ZooKeeperProtos.Table.State state) throws CoordinatedStateException
setTableState
in interface TableStateManager
tableName
- table to processstate
- new state of this tableCoordinatedStateException
- if error happened when trying to set table statepublic boolean setTableStateIfInStates(TableName tableName, ZooKeeperProtos.Table.State newState, ZooKeeperProtos.Table.State... states) throws CoordinatedStateException
setTableStateIfInStates
in interface TableStateManager
tableName
- 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, ZooKeeperProtos.Table.State newState, ZooKeeperProtos.Table.State... states) throws CoordinatedStateException
setTableStateIfNotInStates
in interface TableStateManager
tableName
- 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 operationpublic boolean isTableState(TableName tableName, ZooKeeperProtos.Table.State... states)
isTableState
in interface TableStateManager
public boolean isTableState(TableName tableName, boolean checkSource, ZooKeeperProtos.Table.State... states)
isTableState
in interface TableStateManager
public void setDeletedTable(TableName tableName) throws CoordinatedStateException
setDeletedTable
in interface TableStateManager
tableName
- table to be deletedCoordinatedStateException
- if error happened while performing operationpublic boolean isTablePresent(TableName tableName)
isTablePresent
in interface TableStateManager
tableName
- table we're working onpublic Set<TableName> getTablesInStates(ZooKeeperProtos.Table.State... states) throws InterruptedIOException, CoordinatedStateException
getTablesInStates
in interface TableStateManager
CoordinatedStateException
- if error happened in underlying coordination engineInterruptedIOException
public void checkAndRemoveTableState(TableName tableName, ZooKeeperProtos.Table.State states, boolean deletePermanentState) throws CoordinatedStateException
checkAndRemoveTableState
in interface TableStateManager
tableName
- 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 engine