public class DbTxnManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DbTxnManager.Heartbeater
Heartbeater thread
|
static class |
DbTxnManager.HeartbeaterThread |
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
destruct() |
protected void |
finalize() |
protected HiveLockManager |
getAndCheckLockManager()
Gets the lock manager and verifies if the explicit lock is supported
|
boolean |
getAutoCommit()
This behaves exactly as
https://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#getAutoCommit()
|
long |
getCurrentTxnId()
if
isTxnOpen() , returns the currently active transaction ID |
HiveLockManager |
getLockManager()
Get the lock manager.
|
int |
getStatementId()
0..N Id of current statement within currently opened transaction
|
String |
getTxnManagerName()
Get the name for currently installed transaction 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.
|
boolean |
isTxnOpen() |
int |
lockDatabase(Hive hiveDB,
LockDatabaseDesc lockDb)
This function is called to lock the database when explicit lock command is
issued on a database.
|
int |
lockTable(Hive db,
LockTableDesc lockTbl)
This function is called to lock the table when explicit lock command is
issued on a table.
|
long |
openTxn(String user)
Open a new transaction.
|
void |
releaseLocks(List<HiveLock> hiveLocks)
Release specified locks.
|
void |
rollbackTxn()
Abort the current transaction.
|
void |
setAutoCommit(boolean autoCommit)
This behaves exactly as
https://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#setAutoCommit(boolean)
|
boolean |
supportsAcid()
Indicate whether this transaction manager supports ACID operations
|
boolean |
supportsExplicitLock()
Indicate whether this lock manager supports the use of
lock
database or lock table . |
int |
unlockDatabase(Hive hiveDB,
UnlockDatabaseDesc unlockDb)
This function is called to unlock the database when explicit unlock command
is issued on a database.
|
int |
unlockTable(Hive hiveDB,
UnlockTableDesc unlockTbl)
This function is called to unlock the table when explicit unlock command is
issued on a table.
|
boolean |
useNewShowLocksFormat()
Indicate whether this transaction manager returns information about locks in the new format
for show locks or the old one.
|
protected HiveConf conf
public long openTxn(String user) throws LockException
HiveTxnManager
user
- Hive user who is opening this transaction.LockException
- if a transaction is already open.public HiveLockManager getLockManager() throws LockException
HiveTxnManager
LockException
- if there is an issue obtaining the lock manager.public void acquireLocks(QueryPlan plan, Context ctx, String username) throws LockException
HiveTxnManager
HiveTxnManager.openTxn(String)
.
A list of acquired locks will be stored in the
Context
object and can be retrieved
via Context.getHiveLocks()
.plan
- query planctx
- Context for this queryusername
- name of the user for this queryLockException
- if there is an error getting the locks. Use HiveException.getCanonicalErrorMsg()
to get more info on how to handle the exception.public void releaseLocks(List<HiveLock> hiveLocks) throws LockException
HiveTxnManager
supportsAcid() == true
,
will track locks internally and ignore this parameterhiveLocks
- The list of locks to be released.LockException
public void commitTxn() throws LockException
HiveTxnManager
HiveTxnManager.acquireLocks(org.apache.hadoop.hive.ql.QueryPlan,
org.apache.hadoop.hive.ql.Context, java.lang.String)
.LockException
- if there is no current transaction or the
transaction has already been committed or aborted.public void rollbackTxn() throws LockException
HiveTxnManager
HiveTxnManager.acquireLocks(org.apache.hadoop.hive.ql.QueryPlan,
org.apache.hadoop.hive.ql.Context, java.lang.String)
.LockException
- if there is no current transaction or the
transaction has already been committed or aborted.public void heartbeat() throws LockException
HiveTxnManager
LockException
- If current transaction exists or the transaction
has already been committed or aborted.public ValidTxnList getValidTxns() throws LockException
HiveTxnManager
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.LockException
public String getTxnManagerName()
HiveTxnManager
public boolean supportsExplicitLock()
HiveTxnManager
lock
database
or lock table
.public boolean useNewShowLocksFormat()
HiveTxnManager
public boolean supportsAcid()
HiveTxnManager
protected void destruct()
public boolean isTxnOpen()
public long getCurrentTxnId()
HiveTxnManager
isTxnOpen()
, returns the currently active transaction IDpublic int getStatementId()
HiveTxnManager
public void closeTxnManager()
HiveTxnManager
closeTxnManager
in interface HiveTxnManager
protected void finalize() throws Throwable
public void setAutoCommit(boolean autoCommit) throws LockException
HiveTxnManager
setAutoCommit
in interface HiveTxnManager
LockException
public boolean getAutoCommit()
HiveTxnManager
getAutoCommit
in interface HiveTxnManager
public int lockTable(Hive db, LockTableDesc lockTbl) throws HiveException
HiveTxnManager
lockTable
in interface HiveTxnManager
db
- an object to communicate with the metastorelockTbl
- table locking info, such as table name, locking modeHiveException
public int unlockTable(Hive hiveDB, UnlockTableDesc unlockTbl) throws HiveException
HiveTxnManager
unlockTable
in interface HiveTxnManager
hiveDB
- an object to communicate with the metastoreunlockTbl
- table unlocking info, such as table nameHiveException
public int lockDatabase(Hive hiveDB, LockDatabaseDesc lockDb) throws HiveException
HiveTxnManager
lockDatabase
in interface HiveTxnManager
hiveDB
- an object to communicate with the metastorelockDb
- database locking info, such as database name, locking modeHiveException
public int unlockDatabase(Hive hiveDB, UnlockDatabaseDesc unlockDb) throws HiveException
HiveTxnManager
unlockDatabase
in interface HiveTxnManager
hiveDB
- an object to communicate with the metastoreunlockDb
- database unlocking info, such as database nameHiveException
protected HiveLockManager getAndCheckLockManager() throws HiveException
HiveException
Copyright © 2016 The Apache Software Foundation. All rights reserved.