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();
}
}
Aggregations