/** * we don't expect multiple threads to call this method concurrently but {@link #lockMgr} will * be read by a different threads than one writing it, thus it's {@code volatile} */ @Override public HiveLockManager getLockManager() throws LockException { init(); if (lockMgr == null) { lockMgr = new DbLockManager(conf, this); } return lockMgr; }
/** * we don't expect multiple thread to call this method concurrently but {@link #lockMgr} will * be read by a different threads that one writing it, thus it's {@code volatile} */ @Override public HiveLockManager getLockManager() throws LockException { init(); if (lockMgr == null) { lockMgr = new DbLockManager(conf, this); } return lockMgr; }
@Override public ValidTxnList getValidTxns() throws LockException { init(); try { return getMS().getValidTxns(txnId); } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } }
@Override public ValidTxnList getValidTxns() throws LockException { assert isTxnOpen(); init(); try { return getMS().getValidTxns(txnId); } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } }
@VisibleForTesting long openTxn(Context ctx, String user, long delay) throws LockException { /*Q: why don't we lock the snapshot here??? Instead of having client make an explicit call whenever it chooses A: If we want to rely on locks for transaction scheduling we must get the snapshot after lock acquisition. Relying on locks is a pessimistic strategy which works better under high contention.*/ init(); getLockManager(); if(isTxnOpen()) { throw new LockException("Transaction already opened. " + JavaUtils.txnIdToString(txnId)); } try { txnId = getMS().openTxn(user); stmtId = 0; numStatements = 0; tableWriteIds.clear(); isExplicitTransaction = false; startTransactionCount = 0; LOG.info("Opened " + JavaUtils.txnIdToString(txnId)); ctx.setHeartbeater(startHeartbeat(delay)); return txnId; } catch (TException e) { throw new LockException(e, ErrorMsg.METASTORE_COMMUNICATION_FAILED); } }
@VisibleForTesting long openTxn(Context ctx, String user, long delay) throws LockException { //todo: why don't we lock the snapshot here??? Instead of having client make an explicit call //whenever it chooses init(); if(isTxnOpen()) { throw new LockException("Transaction already opened. " + JavaUtils.txnIdToString(txnId)); } try { txnId = getMS().openTxn(user); statementId = 0; LOG.debug("Opened " + JavaUtils.txnIdToString(txnId)); ctx.setHeartbeater(startHeartbeat(delay)); return txnId; } catch (TException e) { throw new LockException(e, ErrorMsg.METASTORE_COMMUNICATION_FAILED); } }
@Override public HiveLockManager getLockManager() throws LockException { init(); if (lockMgr == null) { lockMgr = new DbLockManager(client); } return lockMgr; }
@Override public ValidTxnList getValidTxns() throws LockException { init(); try { return client.getValidTxns(txnId); } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } }
@Override public long openTxn(String user) throws LockException { init(); try { txnId = client.openTxn(user); LOG.debug("Opened txn " + txnId); return txnId; } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } }