org.apache.hadoop.hbase.master
Class TableLockManager

java.lang.Object
  extended by org.apache.hadoop.hbase.master.TableLockManager
Direct Known Subclasses:
TableLockManager.NullTableLockManager

@InterfaceAudience.Private
public abstract class TableLockManager
extends Object

A manager for distributed table level locks.


Nested Class Summary
static class TableLockManager.NullTableLockManager
          A null implementation
static interface TableLockManager.TableLock
          A distributed lock for a table.
 
Field Summary
protected static int DEFAULT_TABLE_READ_LOCK_TIMEOUT_MS
           
protected static int DEFAULT_TABLE_WRITE_LOCK_TIMEOUT_MS
           
static String TABLE_LOCK_ENABLE
          Configuration key for enabling table-level locks for schema changes
protected static String TABLE_READ_LOCK_TIMEOUT_MS
          Configuration key for time out for trying to acquire table locks
protected static String TABLE_WRITE_LOCK_TIMEOUT_MS
          Configuration key for time out for trying to acquire table locks
 
Constructor Summary
TableLockManager()
           
 
Method Summary
static TableLockManager createTableLockManager(org.apache.hadoop.conf.Configuration conf, ZooKeeperWatcher zkWatcher, ServerName serverName)
          Creates and returns a TableLockManager according to the configuration
abstract  TableLockManager.TableLock readLock(byte[] tableName, String purpose)
          Returns a TableLock for locking the table for shared access among read-lock holders
abstract  void reapAllTableWriteLocks()
          Force releases all table write locks and lock attempts even if this thread does not own the lock.
abstract  void tableDeleted(byte[] tableName)
          Called after a table has been deleted, and after the table lock is released.
abstract  TableLockManager.TableLock writeLock(byte[] tableName, String purpose)
          Returns a TableLock for locking the table for exclusive access
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_LOCK_ENABLE

public static final String TABLE_LOCK_ENABLE
Configuration key for enabling table-level locks for schema changes

See Also:
Constant Field Values

TABLE_WRITE_LOCK_TIMEOUT_MS

protected static final String TABLE_WRITE_LOCK_TIMEOUT_MS
Configuration key for time out for trying to acquire table locks

See Also:
Constant Field Values

TABLE_READ_LOCK_TIMEOUT_MS

protected static final String TABLE_READ_LOCK_TIMEOUT_MS
Configuration key for time out for trying to acquire table locks

See Also:
Constant Field Values

DEFAULT_TABLE_WRITE_LOCK_TIMEOUT_MS

protected static final int DEFAULT_TABLE_WRITE_LOCK_TIMEOUT_MS
See Also:
Constant Field Values

DEFAULT_TABLE_READ_LOCK_TIMEOUT_MS

protected static final int DEFAULT_TABLE_READ_LOCK_TIMEOUT_MS
See Also:
Constant Field Values
Constructor Detail

TableLockManager

public TableLockManager()
Method Detail

writeLock

public abstract TableLockManager.TableLock writeLock(byte[] tableName,
                                                     String purpose)
Returns a TableLock for locking the table for exclusive access

Parameters:
tableName - Table to lock
purpose - Human readable reason for locking the table
Returns:
A new TableLock object for acquiring a write lock

readLock

public abstract TableLockManager.TableLock readLock(byte[] tableName,
                                                    String purpose)
Returns a TableLock for locking the table for shared access among read-lock holders

Parameters:
tableName - Table to lock
purpose - Human readable reason for locking the table
Returns:
A new TableLock object for acquiring a read lock

reapAllTableWriteLocks

public abstract void reapAllTableWriteLocks()
                                     throws IOException
Force releases all table write locks and lock attempts even if this thread does not own the lock. The behavior of the lock holders still thinking that they have the lock is undefined. This should be used carefully and only when we can ensure that all write-lock holders have died. For example if only the master can hold write locks, then we can reap it's locks when the backup master starts.

Throws:
IOException

tableDeleted

public abstract void tableDeleted(byte[] tableName)
                           throws IOException
Called after a table has been deleted, and after the table lock is released. TableLockManager should do cleanup for the table state.

Parameters:
tableName - name of the table
Throws:
IOException - If there is an unrecoverable error releasing the lock

createTableLockManager

public static TableLockManager createTableLockManager(org.apache.hadoop.conf.Configuration conf,
                                                      ZooKeeperWatcher zkWatcher,
                                                      ServerName serverName)
Creates and returns a TableLockManager according to the configuration



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