org.apache.hadoop.hbase.zookeeper
Class ZKTable

java.lang.Object
  extended by org.apache.hadoop.hbase.zookeeper.ZKTable

@InterfaceAudience.Private
public class ZKTable
extends Object

Helper class for table state tracking for use by AssignmentManager. Reads, caches and sets state up in zookeeper. If multiple read/write clients, will make for confusion. Read-only clients other than AssignmentManager interested in learning table state can use the read-only utility methods in ZKTableReadOnly.

To save on trips to the zookeeper ensemble, internally we cache table state.


Constructor Summary
ZKTable(ZooKeeperWatcher zkw)
           
 
Method Summary
 boolean checkAndSetEnablingTable(TableName tableName)
          Sets the specified table as ENABLING in zookeeper atomically If the table is already in ENABLING state, no operation is performed
 boolean checkDisabledAndSetEnablingTable(TableName tableName)
          Sets the specified table as ENABLING in zookeeper atomically If the table isn't in DISABLED state, no operation is performed
 boolean checkEnabledAndSetDisablingTable(TableName tableName)
          Sets the specified table as DISABLING in zookeeper atomically If the table isn't in ENABLED state, no operation is performed
static Set<TableName> getDisabledOrDisablingTables(ZooKeeperWatcher zkw)
          Gets a list of all the tables set as disabled in zookeeper.
 Set<TableName> getDisabledTables()
          Gets a list of all the tables set as disabled in zookeeper.
static Set<TableName> getDisabledTables(ZooKeeperWatcher zkw)
          Gets a list of all the tables set as disabled in zookeeper.
static Set<TableName> getDisablingTables(ZooKeeperWatcher zkw)
          Gets a list of all the tables set as disabling in zookeeper.
static Set<TableName> getEnablingTables(ZooKeeperWatcher zkw)
          Gets a list of all the tables set as enabling in zookeeper.
 boolean isDisabledOrEnablingTable(TableName tableName)
           
 boolean isDisabledTable(TableName tableName)
           
 boolean isDisablingOrDisabledTable(TableName tableName)
           
 boolean isDisablingTable(TableName tableName)
           
 boolean isEnabledOrDisablingTable(TableName tableName)
           
 boolean isEnabledTable(TableName tableName)
           
 boolean isEnablingTable(TableName tableName)
           
 boolean isTablePresent(TableName tableName)
          check if table is present .
 void removeEnablingTable(TableName tableName, boolean deleteZNode)
          If the table is found in ENABLING state the inmemory state is removed.
 void setDeletedTable(TableName tableName)
          Deletes the table in zookeeper.
 void setDisabledTable(TableName tableName)
          Sets the specified table as DISABLED in zookeeper.
 void setDisablingTable(TableName tableName)
          Sets the specified table as DISABLING in zookeeper.
 void setEnabledTable(TableName tableName)
          Sets the ENABLED state in the cache and creates or force updates a node to ENABLED state for the specified table
 void setEnablingTable(TableName tableName)
          Sets the specified table as ENABLING in zookeeper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZKTable

public ZKTable(ZooKeeperWatcher zkw)
        throws org.apache.zookeeper.KeeperException
Throws:
org.apache.zookeeper.KeeperException
Method Detail

setDisabledTable

public void setDisabledTable(TableName tableName)
                      throws org.apache.zookeeper.KeeperException
Sets the specified table as DISABLED in zookeeper. Fails silently if the table is already disabled in zookeeper. Sets no watches.

Parameters:
tableName -
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

setDisablingTable

public void setDisablingTable(TableName tableName)
                       throws org.apache.zookeeper.KeeperException
Sets the specified table as DISABLING in zookeeper. Fails silently if the table is already disabled in zookeeper. Sets no watches.

Parameters:
tableName -
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

setEnablingTable

public void setEnablingTable(TableName tableName)
                      throws org.apache.zookeeper.KeeperException
Sets the specified table as ENABLING in zookeeper. Fails silently if the table is already disabled in zookeeper. Sets no watches.

Parameters:
tableName -
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

checkAndSetEnablingTable

public boolean checkAndSetEnablingTable(TableName tableName)
                                 throws org.apache.zookeeper.KeeperException
Sets the specified table as ENABLING in zookeeper atomically If the table is already in ENABLING state, no operation is performed

Parameters:
tableName -
Returns:
if the operation succeeds or not
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

checkDisabledAndSetEnablingTable

public boolean checkDisabledAndSetEnablingTable(TableName tableName)
                                         throws org.apache.zookeeper.KeeperException
Sets the specified table as ENABLING in zookeeper atomically If the table isn't in DISABLED state, no operation is performed

Parameters:
tableName -
Returns:
if the operation succeeds or not
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

checkEnabledAndSetDisablingTable

public boolean checkEnabledAndSetDisablingTable(TableName tableName)
                                         throws org.apache.zookeeper.KeeperException
Sets the specified table as DISABLING in zookeeper atomically If the table isn't in ENABLED state, no operation is performed

Parameters:
tableName -
Returns:
if the operation succeeds or not
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

isDisabledTable

public boolean isDisabledTable(TableName tableName)

isDisablingTable

public boolean isDisablingTable(TableName tableName)

isEnablingTable

public boolean isEnablingTable(TableName tableName)

isEnabledTable

public boolean isEnabledTable(TableName tableName)

isDisablingOrDisabledTable

public boolean isDisablingOrDisabledTable(TableName tableName)

isEnabledOrDisablingTable

public boolean isEnabledOrDisablingTable(TableName tableName)

isDisabledOrEnablingTable

public boolean isDisabledOrEnablingTable(TableName tableName)

setDeletedTable

public void setDeletedTable(TableName tableName)
                     throws org.apache.zookeeper.KeeperException
Deletes the table in zookeeper. Fails silently if the table is not currently disabled in zookeeper. Sets no watches.

Parameters:
tableName -
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

setEnabledTable

public void setEnabledTable(TableName tableName)
                     throws org.apache.zookeeper.KeeperException
Sets the ENABLED state in the cache and creates or force updates a node to ENABLED state for the specified table

Parameters:
tableName -
Throws:
org.apache.zookeeper.KeeperException

isTablePresent

public boolean isTablePresent(TableName tableName)
check if table is present .

Parameters:
tableName -
Returns:
true if the table is present

getDisabledTables

public Set<TableName> getDisabledTables()
Gets a list of all the tables set as disabled in zookeeper.

Returns:
Set of disabled tables, empty Set if none

getDisabledTables

public static Set<TableName> getDisabledTables(ZooKeeperWatcher zkw)
                                        throws org.apache.zookeeper.KeeperException
Gets a list of all the tables set as disabled in zookeeper.

Returns:
Set of disabled tables, empty Set if none
Throws:
org.apache.zookeeper.KeeperException

getDisablingTables

public static Set<TableName> getDisablingTables(ZooKeeperWatcher zkw)
                                         throws org.apache.zookeeper.KeeperException
Gets a list of all the tables set as disabling in zookeeper.

Returns:
Set of disabling tables, empty Set if none
Throws:
org.apache.zookeeper.KeeperException

getEnablingTables

public static Set<TableName> getEnablingTables(ZooKeeperWatcher zkw)
                                        throws org.apache.zookeeper.KeeperException
Gets a list of all the tables set as enabling in zookeeper.

Returns:
Set of enabling tables, empty Set if none
Throws:
org.apache.zookeeper.KeeperException

getDisabledOrDisablingTables

public static Set<TableName> getDisabledOrDisablingTables(ZooKeeperWatcher zkw)
                                                   throws org.apache.zookeeper.KeeperException
Gets a list of all the tables set as disabled in zookeeper.

Returns:
Set of disabled tables, empty Set if none
Throws:
org.apache.zookeeper.KeeperException

removeEnablingTable

public void removeEnablingTable(TableName tableName,
                                boolean deleteZNode)
                         throws org.apache.zookeeper.KeeperException
If the table is found in ENABLING state the inmemory state is removed. This helps in cases where CreateTable is to be retried by the client incase of failures. If deleteZNode is true - the znode is also deleted

Parameters:
tableName -
deleteZNode -
Throws:
org.apache.zookeeper.KeeperException


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.