org.apache.hadoop.hbase.zookeeper
Class ZKTable

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

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 isEnabledTable(ZooKeeperWatcher, String) and isDisabledTable(ZooKeeperWatcher, String).

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


Nested Class Summary
static class ZKTable.TableState
          States a Table can be in.
 
Constructor Summary
ZKTable(ZooKeeperWatcher zkw)
           
 
Method Summary
static Set<String> getDisabledOrDisablingTables(ZooKeeperWatcher zkw)
          Gets a list of all the tables set as disabled in zookeeper.
 Set<String> getDisabledTables()
          Gets a list of all the tables set as disabled in zookeeper.
static Set<String> getDisabledTables(ZooKeeperWatcher zkw)
          Gets a list of all the tables set as disabled in zookeeper.
 boolean isDisabledOrEnablingTable(String tableName)
           
 boolean isDisabledTable(String tableName)
           
static boolean isDisabledTable(ZooKeeperWatcher zkw, String tableName)
          Go to zookeeper and see if state of table is ZKTable.TableState.DISABLED.
 boolean isDisablingOrDisabledTable(String tableName)
           
static boolean isDisablingOrDisabledTable(ZooKeeperWatcher zkw, String tableName)
          Go to zookeeper and see if state of table is ZKTable.TableState.DISABLING of ZKTable.TableState.DISABLED.
 boolean isDisablingTable(String tableName)
           
 boolean isEnabledOrDisablingTable(String tableName)
           
 boolean isEnabledTable(String tableName)
           
static boolean isEnabledTable(ZooKeeperWatcher zkw, String tableName)
          Go to zookeeper and see if state of table is ZKTable.TableState.ENABLED.
 boolean isEnablingTable(String tableName)
           
 void setDisabledTable(String tableName)
          Sets the specified table as DISABLED in zookeeper.
 void setDisablingTable(String tableName)
          Sets the specified table as DISABLING in zookeeper.
 void setEnabledTable(String tableName)
          Enables the table in zookeeper.
 void setEnablingTable(String 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(String 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(String 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(String 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

isDisabledTable

public boolean isDisabledTable(String tableName)

isDisabledTable

public static boolean isDisabledTable(ZooKeeperWatcher zkw,
                                      String tableName)
                               throws org.apache.zookeeper.KeeperException
Go to zookeeper and see if state of table is ZKTable.TableState.DISABLED. This method does not use cache as isDisabledTable(String) does. This method is for clients other than AssignmentManager

Parameters:
zkw -
tableName -
Returns:
True if table is enabled.
Throws:
org.apache.zookeeper.KeeperException

isDisablingTable

public boolean isDisablingTable(String tableName)

isEnablingTable

public boolean isEnablingTable(String tableName)

isEnabledTable

public boolean isEnabledTable(String tableName)

isEnabledTable

public static boolean isEnabledTable(ZooKeeperWatcher zkw,
                                     String tableName)
                              throws org.apache.zookeeper.KeeperException
Go to zookeeper and see if state of table is ZKTable.TableState.ENABLED. This method does not use cache as isEnabledTable(String) does. This method is for clients other than AssignmentManager

Parameters:
zkw -
tableName -
Returns:
True if table is enabled.
Throws:
org.apache.zookeeper.KeeperException

isDisablingOrDisabledTable

public boolean isDisablingOrDisabledTable(String tableName)

isDisablingOrDisabledTable

public static boolean isDisablingOrDisabledTable(ZooKeeperWatcher zkw,
                                                 String tableName)
                                          throws org.apache.zookeeper.KeeperException
Go to zookeeper and see if state of table is ZKTable.TableState.DISABLING of ZKTable.TableState.DISABLED. This method does not use cache as isEnabledTable(String) does. This method is for clients other than AssignmentManager.

Parameters:
zkw -
tableName -
Returns:
True if table is enabled.
Throws:
org.apache.zookeeper.KeeperException

isEnabledOrDisablingTable

public boolean isEnabledOrDisablingTable(String tableName)

isDisabledOrEnablingTable

public boolean isDisabledOrEnablingTable(String tableName)

setEnabledTable

public void setEnabledTable(String tableName)
                     throws org.apache.zookeeper.KeeperException
Enables 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

getDisabledTables

public Set<String> 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<String> 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

getDisabledOrDisablingTables

public static Set<String> 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


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