org.apache.hadoop.hive.ql.lockmgr
Class DbTxnManager

java.lang.Object
  extended by org.apache.hadoop.hive.ql.lockmgr.DbTxnManager
All Implemented Interfaces:
HiveTxnManager

public class DbTxnManager
extends Object

An implementation of HiveTxnManager that stores the transactions in the metastore database.


Method Summary
 void acquireLocks(QueryPlan plan, Context ctx, String username)
          Acquire all of the locks needed by a query.
 void closeTxnManager()
          This call closes down the transaction manager.
 void commitTxn()
          Commit the current transaction.
 HiveLockManager getLockManager()
          Get the lock manager.
 ValidTxnList getValidTxns()
          Get the transactions that are currently valid.
 void heartbeat()
          Send a heartbeat to the transaction management storage so other Hive clients know that the transaction and locks held by this client are still valid.
 void openTxn(String user)
          Open a new transaction.
 void rollbackTxn()
          Abort the current transaction.
 boolean supportsExplicitLock()
          Indicate whether this lock manager supports the use of lock database or lock table.
 boolean useNewShowLocksFormat()
          Indicate whether this transaction manager returns information about locks in the new format for show locks or the old one.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

openTxn

public void openTxn(String user)
             throws LockException
Description copied from interface: HiveTxnManager
Open a new transaction.

Parameters:
user - Hive user who is opening this transaction.
Throws:
LockException - if a transaction is already open.

getLockManager

public HiveLockManager getLockManager()
                               throws LockException
Description copied from interface: HiveTxnManager
Get the lock manager. This must be used rather than instantiating an instance of the lock manager directly as the transaction manager will choose which lock manager to instantiate.

Returns:
the instance of the lock manager
Throws:
LockException - if there is an issue obtaining the lock manager.

acquireLocks

public void acquireLocks(QueryPlan plan,
                         Context ctx,
                         String username)
                  throws LockException
Description copied from interface: HiveTxnManager
Acquire all of the locks needed by a query. If used with a query that requires transactions, this should be called after HiveTxnManager.openTxn(String). A list of acquired locks will be stored in the Context object and can be retrieved via Context.getHiveLocks().

Parameters:
plan - query plan
ctx - Context for this query
username - name of the user for this query
Throws:
LockException - if there is an error getting the locks

commitTxn

public void commitTxn()
               throws LockException
Description copied from interface: HiveTxnManager
Commit the current transaction. This will release all locks obtained in HiveTxnManager.acquireLocks(org.apache.hadoop.hive.ql.QueryPlan, org.apache.hadoop.hive.ql.Context, java.lang.String).

Throws:
LockException - if there is no current transaction or the transaction has already been committed or aborted.

rollbackTxn

public void rollbackTxn()
                 throws LockException
Description copied from interface: HiveTxnManager
Abort the current transaction. This will release all locks obtained in HiveTxnManager.acquireLocks(org.apache.hadoop.hive.ql.QueryPlan, org.apache.hadoop.hive.ql.Context, java.lang.String).

Throws:
LockException - if there is no current transaction or the transaction has already been committed or aborted.

heartbeat

public void heartbeat()
               throws LockException
Description copied from interface: HiveTxnManager
Send a heartbeat to the transaction management storage so other Hive clients know that the transaction and locks held by this client are still valid. For implementations that do not require heartbeats this can be a no-op.

Throws:
LockException - If current transaction exists or the transaction has already been committed or aborted.

getValidTxns

public ValidTxnList getValidTxns()
                          throws LockException
Description copied from interface: HiveTxnManager
Get the transactions that are currently valid. The resulting ValidTxnList object is a thrift object and can be passed to the processing tasks for use in the reading the data. This call should be made once up front by the planner and should never be called on the backend, as this will violate the isolation level semantics.

Returns:
list of valid transactions.
Throws:
LockException

supportsExplicitLock

public boolean supportsExplicitLock()
Description copied from interface: HiveTxnManager
Indicate whether this lock manager supports the use of lock database or lock table.

Returns:

useNewShowLocksFormat

public boolean useNewShowLocksFormat()
Description copied from interface: HiveTxnManager
Indicate whether this transaction manager returns information about locks in the new format for show locks or the old one.

Returns:
true if the new format should be used.

closeTxnManager

public void closeTxnManager()
Description copied from interface: HiveTxnManager
This call closes down the transaction manager. All open transactions are aborted. If no transactions are open but locks are held those locks are released. This method should be called if processing of a session is being halted in an abnormal way. It avoids locks and transactions timing out.

Specified by:
closeTxnManager in interface HiveTxnManager


Copyright © 2014 The Apache Software Foundation. All rights reserved.