public synchronized TransactorCache getTransactorCache() { checkIfClosed(); if (transactorCache == null) { transactorCache = new TransactorCache(env); } else if (transactorCache.getStatus() == TcStatus.CLOSED) { throw new IllegalStateException("TransactorCache is closed!"); } return transactorCache; }
public void addTimedoutTransactor(final Long transactorId, final long lockTs, final Long startTime) { // @formatter:on try { AtomicLong cachedLockTs = timeoutCache.get(transactorId, new Callable<AtomicLong>() { @Override public AtomicLong call() throws Exception { logTimedoutTransactor(transactorId, lockTs, startTime); return new AtomicLong(lockTs); } }); long currVal = cachedLockTs.get(); while (lockTs > currVal) { if (cachedLockTs.compareAndSet(currVal, lockTs)) { logTimedoutTransactor(transactorId, lockTs, startTime); } // its possible another thread updates and the above compare and set failed, so the // following will get us out of loop in this case... it will also get // us out of loop in case where compared and set succeeds currVal = cachedLockTs.get(); } } catch (ExecutionException e) { throw new RuntimeException(e); } }
long lockTs = entry.getKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK; if (transactorCache.checkTimedout(transactorId, lockTs)) { locksToRecover.add(entry); stats.incrementTimedOutLocks(); } else if (!transactorCache.checkExists(transactorId)) { locksToRecover.add(entry); stats.incrementDeadLocks(); long lockTs = entry.getKey().startTs; Long transactorId = new LockValue(entry.getValue().get(0).getValue().get()).getTransactor(); transactorCache.addTimedoutTransactor(transactorId, lockTs, startTime);
@Override public synchronized void close() { isClosed = true; if (tnode != null) { tnode.close(); } if (tsTracker != null) { tsTracker.close(); } if (transactorCache != null) { transactorCache.close(); } if (oracleClient != null) { oracleClient.close(); } cw.close(); bulkCw.close(); sbw.close(); try { bw.close(); } catch (MutationsRejectedException e) { throw new RuntimeException(e); } curator.close(); }