/** * If {@code !}{@link #isMutationStarted()}, check all locks and expected * values, then mark the transaction as started. * <p> * If {@link #isMutationStarted()}, this does nothing. * * @throws com.thinkaurelius.titan.diskstorage.BackendException * * @return true if this transaction holds at least one lock, false if the * transaction holds no locks */ boolean prepareForMutations() throws BackendException { if (!isMutationStarted()) { checkAllLocks(); checkAllExpectedValues(); mutationStarted(); } return !expectedValuesByStore.isEmpty(); }
/** * {@inheritDoc} * <p/> * This implementation supports locking when {@code lockStore} is non-null. * <p/> * Consider the following scenario. This method is called twice with * identical key, column, and txh arguments, but with different * expectedValue arguments in each call. In testing, it seems titan's * graphdb requires that implementations discard the second expectedValue * and, when checking expectedValues vs actual values just prior to mutate, * only the initial expectedValue argument should be considered. */ @Override public void acquireLock(StaticBuffer key, StaticBuffer column, StaticBuffer expectedValue, StoreTransaction txh) throws BackendException { if (locker != null) { ExpectedValueCheckingTransaction tx = (ExpectedValueCheckingTransaction) txh; if (tx.isMutationStarted()) throw new PermanentLockingException("Attempted to obtain a lock after mutations had been persisted"); KeyColumn lockID = new KeyColumn(key, column); log.debug("Attempting to acquireLock on {} ev={}", lockID, expectedValue); locker.writeLock(lockID, tx.getConsistentTx()); tx.storeExpectedValue(this, lockID, expectedValue); } else { store.acquireLock(key, column, expectedValue, unwrapTx(txh)); } }
/** * If {@code !}{@link #isMutationStarted()}, check all locks and expected * values, then mark the transaction as started. * <p> * If {@link #isMutationStarted()}, this does nothing. * * @throws com.thinkaurelius.titan.diskstorage.BackendException * * @return true if this transaction holds at least one lock, false if the * transaction holds no locks */ boolean prepareForMutations() throws BackendException { if (!isMutationStarted()) { checkAllLocks(); checkAllExpectedValues(); mutationStarted(); } return !expectedValuesByStore.isEmpty(); }
/** * If {@code !}{@link #isMutationStarted()}, check all locks and expected * values, then mark the transaction as started. * <p> * If {@link #isMutationStarted()}, this does nothing. * * @throws com.thinkaurelius.titan.diskstorage.BackendException * * @return true if this transaction holds at least one lock, false if the * transaction holds no locks */ boolean prepareForMutations() throws BackendException { if (!isMutationStarted()) { checkAllLocks(); checkAllExpectedValues(); mutationStarted(); } return !expectedValuesByStore.isEmpty(); }
/** * {@inheritDoc} * <p/> * This implementation supports locking when {@code lockStore} is non-null. * <p/> * Consider the following scenario. This method is called twice with * identical key, column, and txh arguments, but with different * expectedValue arguments in each call. In testing, it seems titan's * graphdb requires that implementations discard the second expectedValue * and, when checking expectedValues vs actual values just prior to mutate, * only the initial expectedValue argument should be considered. */ @Override public void acquireLock(StaticBuffer key, StaticBuffer column, StaticBuffer expectedValue, StoreTransaction txh) throws BackendException { if (locker != null) { ExpectedValueCheckingTransaction tx = (ExpectedValueCheckingTransaction) txh; if (tx.isMutationStarted()) throw new PermanentLockingException("Attempted to obtain a lock after mutations had been persisted"); KeyColumn lockID = new KeyColumn(key, column); log.debug("Attempting to acquireLock on {} ev={}", lockID, expectedValue); locker.writeLock(lockID, tx.getConsistentTx()); tx.storeExpectedValue(this, lockID, expectedValue); } else { store.acquireLock(key, column, expectedValue, unwrapTx(txh)); } }
/** * {@inheritDoc} * <p/> * This implementation supports locking when {@code lockStore} is non-null. * <p/> * Consider the following scenario. This method is called twice with * identical key, column, and txh arguments, but with different * expectedValue arguments in each call. In testing, it seems titan's * graphdb requires that implementations discard the second expectedValue * and, when checking expectedValues vs actual values just prior to mutate, * only the initial expectedValue argument should be considered. */ @Override public void acquireLock(StaticBuffer key, StaticBuffer column, StaticBuffer expectedValue, StoreTransaction txh) throws BackendException { if (locker != null) { ExpectedValueCheckingTransaction tx = (ExpectedValueCheckingTransaction) txh; if (tx.isMutationStarted()) throw new PermanentLockingException("Attempted to obtain a lock after mutations had been persisted"); KeyColumn lockID = new KeyColumn(key, column); log.debug("Attempting to acquireLock on {} ev={}", lockID, expectedValue); locker.writeLock(lockID, tx.getConsistentTx()); tx.storeExpectedValue(this, lockID, expectedValue); } else { store.acquireLock(key, column, expectedValue, unwrapTx(txh)); } }