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
static long DEFAULT_TABLE_LOCK_EXPIRE_TIMEOUT_MS
           
protected static long DEFAULT_TABLE_READ_LOCK_TIMEOUT_MS
           
protected static long DEFAULT_TABLE_WRITE_LOCK_TIMEOUT_MS
           
static String TABLE_LOCK_ENABLE
          Configuration key for enabling table-level locks for schema changes
static String TABLE_LOCK_EXPIRE_TIMEOUT
           
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
static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.TableLock fromBytes(byte[] bytes)
          Public for hbck
abstract  TableLockManager.TableLock readLock(TableName tableName, String purpose)
          Returns a TableLock for locking the table for shared access among read-lock holders
abstract  void reapAllExpiredLocks()
          Force releases all table locks(read and write) that have been held longer than "hbase.table.lock.expire.ms".
abstract  void reapWriteLocks()
          Force releases table write locks and lock attempts even if this thread does not own the lock.
abstract  void tableDeleted(TableName tableName)
          Called after a table has been deleted, and after the table lock is released.
abstract  void visitAllLocks(InterProcessLock.MetadataHandler handler)
          Visits all table locks(read and write), and lock attempts with the given callback MetadataHandler.
abstract  TableLockManager.TableLock writeLock(TableName 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 long DEFAULT_TABLE_WRITE_LOCK_TIMEOUT_MS
See Also:
Constant Field Values

DEFAULT_TABLE_READ_LOCK_TIMEOUT_MS

protected static final long DEFAULT_TABLE_READ_LOCK_TIMEOUT_MS
See Also:
Constant Field Values

TABLE_LOCK_EXPIRE_TIMEOUT

public static final String TABLE_LOCK_EXPIRE_TIMEOUT
See Also:
Constant Field Values

DEFAULT_TABLE_LOCK_EXPIRE_TIMEOUT_MS

public static final long DEFAULT_TABLE_LOCK_EXPIRE_TIMEOUT_MS
See Also:
Constant Field Values
Constructor Detail

TableLockManager

public TableLockManager()
Method Detail

writeLock

public abstract TableLockManager.TableLock writeLock(TableName 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(TableName 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

visitAllLocks

public abstract void visitAllLocks(InterProcessLock.MetadataHandler handler)
                            throws IOException
Visits all table locks(read and write), and lock attempts with the given callback MetadataHandler.

Parameters:
handler - the metadata handler to call
Throws:
IOException - If there is an unrecoverable error

reapAllExpiredLocks

public abstract void reapAllExpiredLocks()
                                  throws IOException
Force releases all table locks(read and write) that have been held longer than "hbase.table.lock.expire.ms". Assumption is that the clock skew between zookeeper and this servers is negligible. The behavior of the lock holders still thinking that they have the lock is undefined.

Throws:
IOException - If there is an unrecoverable error

reapWriteLocks

public abstract void reapWriteLocks()
                             throws IOException
Force releases 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 - If there is an unrecoverable error

tableDeleted

public abstract void tableDeleted(TableName 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


fromBytes

public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.TableLock fromBytes(byte[] bytes)
Public for hbck



Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.