Search in sources :

Example 1 with TXRegionLockRequest

use of org.apache.geode.internal.cache.locks.TXRegionLockRequest in project geode by apache.

the class ClientTXStateStub method obtainLocalLocks.

/**
   * Lock the keys in a local transaction manager
   * 
   * @throws CommitConflictException if the key is already locked by some other transaction
   */
private void obtainLocalLocks() {
    lockReq = new TXLockRequest();
    InternalCache cache = GemFireCacheImpl.getExisting("");
    for (TransactionalOperation txOp : this.recordedOperations) {
        if (ServerRegionOperation.lockKeyForTx(txOp.getOperation())) {
            TXRegionLockRequest rlr = lockReq.getRegionLockRequest(txOp.getRegionName());
            if (rlr == null) {
                rlr = new TXRegionLockRequestImpl(cache.getRegionByPath(txOp.getRegionName()));
                lockReq.addLocalRequest(rlr);
            }
            if (txOp.getOperation() == ServerRegionOperation.PUT_ALL || txOp.getOperation() == ServerRegionOperation.REMOVE_ALL) {
                rlr.addEntryKeys(txOp.getKeys());
            } else {
                rlr.addEntryKey(txOp.getKey());
            }
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("TX: client localLockRequest: {}", lockReq);
    }
    try {
        lockReq.obtain();
    } catch (CommitConflictException e) {
        // cleanup tx artifacts on server
        rollback();
        throw e;
    }
    if (internalAfterLocalLocks != null) {
        internalAfterLocalLocks.run();
    }
}
Also used : CommitConflictException(org.apache.geode.cache.CommitConflictException) TXRegionLockRequestImpl(org.apache.geode.internal.cache.TXRegionLockRequestImpl) TXLockRequest(org.apache.geode.internal.cache.TXLockRequest) InternalCache(org.apache.geode.internal.cache.InternalCache) TXRegionLockRequest(org.apache.geode.internal.cache.locks.TXRegionLockRequest)

Aggregations

CommitConflictException (org.apache.geode.cache.CommitConflictException)1 InternalCache (org.apache.geode.internal.cache.InternalCache)1 TXLockRequest (org.apache.geode.internal.cache.TXLockRequest)1 TXRegionLockRequestImpl (org.apache.geode.internal.cache.TXRegionLockRequestImpl)1 TXRegionLockRequest (org.apache.geode.internal.cache.locks.TXRegionLockRequest)1