public static Supplier<AdvisoryLocksCondition> get(LockService lockService, Iterable<HeldLocksToken> lockTokens, Supplier<LockRequest> lockSupplier) { return () -> { Set<HeldLocksToken> externalLocks = ImmutableSet.copyOf(lockTokens); ExternalLocksCondition externalCondition = externalLocks.isEmpty() ? null : new ExternalLocksCondition(lockService, externalLocks); LockRequest lockRequest = lockSupplier.get(); if (lockRequest != null) { Validate.isTrue(lockRequest.getVersionId() == null, "Using a version id is not allowed"); HeldLocksToken newToken = acquireLock(lockService, lockRequest); TransactionLocksCondition transactionCondition = new TransactionLocksCondition(lockService, newToken); return externalCondition == null ? transactionCondition : new CombinedLocksCondition(externalCondition, transactionCondition); } return externalCondition == null ? NO_LOCKS_CONDITION : externalCondition; }; }
lockDescriptorMap.put(entry.getKey().getDescriptor(), entry.getValue()); if (request.getVersionId() != null) { versionIdMap.put(client, request.getVersionId()); request.getLockTimeout(), request.getVersionId(), request.getCreatingThreadName()); locks.clear(); if (log.isTraceEnabled()) {
public static SimpleLockRequest of(LockRequest request, String lockDescriptor, LockMode lockMode, String clientId) { return ImmutableSimpleLockRequest.builder() .lockDescriptor(lockDescriptor) .lockMode(lockMode) .lockCount(request.getLocks().size()) .lockTimeout(request.getLockTimeout().toMillis()) .lockGroupBehavior(request.getLockGroupBehavior()) .blockingMode(request.getBlockingMode()) .blockingDuration(extractBlockingDurationOrNull(request.getBlockingDuration())) .versionId(request.getVersionId()) .creatingThread(request.getCreatingThreadName()) .clientId(clientId).build(); }
newRequest.doNotBlock(); newRequest.timeoutAfter(request.getLockTimeout()); if (request.getVersionId() != null) { newRequest.withLockedInVersionId(request.getVersionId());
public static Supplier<AdvisoryLocksCondition> get(LockService lockService, Iterable<HeldLocksToken> lockTokens, Supplier<LockRequest> lockSupplier) { return () -> { Set<HeldLocksToken> externalLocks = ImmutableSet.copyOf(lockTokens); ExternalLocksCondition externalCondition = externalLocks.isEmpty() ? null : new ExternalLocksCondition(lockService, externalLocks); LockRequest lockRequest = lockSupplier.get(); if (lockRequest != null) { Validate.isTrue(lockRequest.getVersionId() == null, "Using a version id is not allowed"); HeldLocksToken newToken = acquireLock(lockService, lockRequest); TransactionLocksCondition transactionCondition = new TransactionLocksCondition(lockService, newToken); return externalCondition == null ? transactionCondition : new CombinedLocksCondition(externalCondition, transactionCondition); } return externalCondition == null ? NO_LOCKS_CONDITION : externalCondition; }; }
newRequest.doNotBlock(); newRequest.timeoutAfter(request.getLockTimeout()); if (request.getVersionId() != null) { newRequest.withLockedInVersionId(request.getVersionId());