public class TxnHandler extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
TxnHandler.DatabaseProduct |
protected class |
TxnHandler.RetryException |
Modifier and Type | Field and Description |
---|---|
static String |
CLEANING_RESPONSE |
protected HiveConf |
conf |
protected TxnHandler.DatabaseProduct |
dbProduct |
protected int |
deadlockCnt
Number of consecutive deadlocks we have seen
|
static String |
INITIATED_RESPONSE |
protected static char |
INITIATED_STATE |
protected static char |
LOCK_ACQUIRED |
protected static char |
LOCK_EXCLUSIVE |
protected static char |
LOCK_SEMI_SHARED |
protected static char |
LOCK_SHARED |
protected static char |
LOCK_WAITING |
protected static char |
MAJOR_TYPE |
protected static char |
MINOR_TYPE |
protected static char |
READY_FOR_CLEANING |
protected static char |
TXN_ABORTED |
protected static char |
TXN_OPEN |
static String |
WORKING_RESPONSE |
protected static char |
WORKING_STATE |
Constructor and Description |
---|
TxnHandler(HiveConf conf) |
public static final String INITIATED_RESPONSE
public static final String WORKING_RESPONSE
public static final String CLEANING_RESPONSE
protected static final char INITIATED_STATE
protected static final char WORKING_STATE
protected static final char READY_FOR_CLEANING
protected static final char MAJOR_TYPE
protected static final char MINOR_TYPE
protected static final char TXN_ABORTED
protected static final char TXN_OPEN
protected static final char LOCK_ACQUIRED
protected static final char LOCK_WAITING
protected static final char LOCK_EXCLUSIVE
protected static final char LOCK_SHARED
protected static final char LOCK_SEMI_SHARED
protected int deadlockCnt
protected HiveConf conf
protected TxnHandler.DatabaseProduct dbProduct
public TxnHandler(HiveConf conf)
public GetOpenTxnsInfoResponse getOpenTxnsInfo() throws MetaException
MetaException
public GetOpenTxnsResponse getOpenTxns() throws MetaException
MetaException
public static ValidTxnList createValidReadTxnList(GetOpenTxnsResponse txns, long currentTxn)
GetOpenTxnsResponse
to a
ValidTxnList
. This assumes that the caller intends to
read the files, and thus treats both open and aborted transactions as invalid.txns
- txn list from the metastorecurrentTxn
- Current transaction that the user has open. If this is greater than 0 it
will be removed from the exceptions list so that the user sees his own
transaction as valid.public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException
MetaException
public void abortTxn(AbortTxnRequest rqst) throws NoSuchTxnException, MetaException
NoSuchTxnException
MetaException
public void commitTxn(CommitTxnRequest rqst) throws NoSuchTxnException, TxnAbortedException, MetaException
public LockResponse lock(LockRequest rqst) throws NoSuchTxnException, TxnAbortedException, MetaException
public LockResponse lockNoWait(LockRequest rqst) throws NoSuchTxnException, TxnAbortedException, MetaException
public LockResponse checkLock(CheckLockRequest rqst) throws NoSuchTxnException, NoSuchLockException, TxnAbortedException, MetaException
public void unlock(UnlockRequest rqst) throws NoSuchLockException, TxnOpenException, MetaException
public ShowLocksResponse showLocks(ShowLocksRequest rqst) throws MetaException
MetaException
public void heartbeat(HeartbeatRequest ids) throws NoSuchTxnException, NoSuchLockException, TxnAbortedException, MetaException
public HeartbeatTxnRangeResponse heartbeatTxnRange(HeartbeatTxnRangeRequest rqst) throws MetaException
MetaException
public void compact(CompactionRequest rqst) throws MetaException
MetaException
public ShowCompactResponse showCompact(ShowCompactRequest rqst) throws MetaException
MetaException
public void addDynamicPartitions(AddDynamicPartitions rqst) throws NoSuchTxnException, TxnAbortedException, MetaException
protected Connection getDbConn(int isolationLevel) throws SQLException
isolationLevel
- desired isolation level. If you are doing _any_ data modifications
you should request serializable, else read committed should be fine.MetaException
- if the connection cannot be obtainedSQLException
protected void closeDbConn(Connection dbConn)
protected void closeStmt(Statement stmt)
stmt
- statement instance.protected void checkRetryable(Connection conn, SQLException e, String caller) throws TxnHandler.RetryException, MetaException
conn
- database connectione
- exception that was thrown.caller
- name of the method calling thisTxnHandler.RetryException
- when deadlock
detected and retry count has not been exceeded.
TODO: make "caller" more elaborate like include lockId for exampleMetaException
protected long getDbTime(Connection conn) throws MetaException
conn
- database connectionMetaException
- if the time cannot be determinedprotected String getIdentifierQuoteString(Connection conn) throws SQLException
conn
- Active connectionSQLException
protected TxnHandler.DatabaseProduct determineDatabaseProduct(Connection conn) throws MetaException
conn
- database connectionMetaException
- if the type cannot be determined or is unknownCopyright © 2017 The Apache Software Foundation. All rights reserved.