Package com.atlassian.bamboo.plan
Class PlanExecutionLockServiceImpl
java.lang.Object
com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl
- All Implemented Interfaces:
PlanExecutionLockService
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<V> V
inlineProcessLocks
(@NotNull TriggerableInternalKey internalKey, @NotNull AcquisitionPolicy acquisitionPolicy, @NotNull Callable<V> callable) A parallel locking mechanism that allows a backdoor to the standard lock.void
interruptLockOwner
(@NotNull TriggerableInternalKey internalKey) Interrupts the owner of the lock represented byTriggerableInternalKey
boolean
isLocked
(@NotNull TriggerableInternalKey internalKey) Checks if the givenString
has been locked<V> V
lock
(@NotNull TriggerableInternalKey internalKey, @NotNull AcquisitionPolicy acquisitionPolicy, @NotNull Callable<V> callable) Quick note about the implementation Since the acquisition policyAcquisitionPolicy.WAIT
can block for an indefinite amount of time we acquire this lock before trying to take the global execution lock otherwise callers torunWhenNoExecutionRequestsAreBeingMade(Callable)
in the worst case will wait indefinitely.<V> V
runWhenNoExecutionRequestsAreBeingMade
(@NotNull Callable<V> callable) Executes the givenCallable
when there are no requests being made to execute plans
-
Constructor Details
-
PlanExecutionLockServiceImpl
public PlanExecutionLockServiceImpl()
-
-
Method Details
-
runWhenNoExecutionRequestsAreBeingMade
public <V> V runWhenNoExecutionRequestsAreBeingMade(@NotNull @NotNull Callable<V> callable) throws Exception Description copied from interface:PlanExecutionLockService
Executes the givenCallable
when there are no requests being made to execute plans- Specified by:
runWhenNoExecutionRequestsAreBeingMade
in interfacePlanExecutionLockService
- Type Parameters:
V
- callable result type- Parameters:
callable
- to execute- Returns:
- callable result
- Throws:
Exception
- if error
-
isLocked
Description copied from interface:PlanExecutionLockService
Checks if the givenString
has been locked- Specified by:
isLocked
in interfacePlanExecutionLockService
- Parameters:
internalKey
- to check- Returns:
- locked state
-
lock
@Nullable public <V> V lock(@NotNull @NotNull TriggerableInternalKey internalKey, @NotNull @NotNull AcquisitionPolicy acquisitionPolicy, @NotNull @NotNull Callable<V> callable) throws Exception Quick note about the implementation Since the acquisition policyAcquisitionPolicy.WAIT
can block for an indefinite amount of time we acquire this lock before trying to take the global execution lock otherwise callers torunWhenNoExecutionRequestsAreBeingMade(Callable)
in the worst case will wait indefinitely.- Specified by:
lock
in interfacePlanExecutionLockService
- Type Parameters:
V
- callable result type- Parameters:
internalKey
- to lockacquisitionPolicy
- to acquire the lockcallable
- to execute- Returns:
- callable result
- Throws:
Exception
- if error
-
inlineProcessLocks
@Nullable public <V> V inlineProcessLocks(@NotNull @NotNull TriggerableInternalKey internalKey, @NotNull @NotNull AcquisitionPolicy acquisitionPolicy, @NotNull @NotNull Callable<V> callable) throws Exception Description copied from interface:PlanExecutionLockService
A parallel locking mechanism that allows a backdoor to the standard lock. This should only be used for short lived locking (whereas the standard lock might be used for change detection). This is by convention only, so take care. This lock will participate inPlanExecutionLockService.isLocked(TriggerableInternalKey)
andPlanExecutionLockService.interruptLockOwner(TriggerableInternalKey)
- Specified by:
inlineProcessLocks
in interfacePlanExecutionLockService
- Returns:
- Throws:
Exception
-
interruptLockOwner
Description copied from interface:PlanExecutionLockService
Interrupts the owner of the lock represented byTriggerableInternalKey
- Specified by:
interruptLockOwner
in interfacePlanExecutionLockService
-