Package com.atlassian.bamboo.plan
Class PlanExecutionLockServiceImpl
- java.lang.Object
-
- com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl
-
- All Implemented Interfaces:
PlanExecutionLockService
public class PlanExecutionLockServiceImpl extends Object implements PlanExecutionLockService
-
-
Constructor Summary
Constructors Constructor Description PlanExecutionLockServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> VinlineProcessLocks(@NotNull TriggerableInternalKey internalKey, @NotNull AcquisitionPolicy acquisitionPolicy, @NotNull Callable<V> callable)A parallel locking mechanism that allows a backdoor to the standard lock.voidinterruptLockOwner(@NotNull TriggerableInternalKey internalKey)Interrupts the owner of the lock represented byTriggerableInternalKeybooleanisLocked(@NotNull TriggerableInternalKey internalKey)Checks if the givenStringhas been locked<V> Vlock(@NotNull TriggerableInternalKey internalKey, @NotNull AcquisitionPolicy acquisitionPolicy, @NotNull Callable<V> callable)Quick note about the implementation Since the acquisition policyAcquisitionPolicy.WAITcan 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> VrunWhenNoExecutionRequestsAreBeingMade(@NotNull Callable<V> callable)Executes the givenCallablewhen there are no requests being made to execute plans
-
-
-
Method Detail
-
runWhenNoExecutionRequestsAreBeingMade
public <V> V runWhenNoExecutionRequestsAreBeingMade(@NotNull @NotNull Callable<V> callable) throws ExceptionDescription copied from interface:PlanExecutionLockServiceExecutes the givenCallablewhen there are no requests being made to execute plans- Specified by:
runWhenNoExecutionRequestsAreBeingMadein interfacePlanExecutionLockService- Type Parameters:
V- callable result type- Parameters:
callable- to execute- Returns:
- callable result
- Throws:
Exception- if error
-
isLocked
public boolean isLocked(@NotNull @NotNull TriggerableInternalKey internalKey)Description copied from interface:PlanExecutionLockServiceChecks if the givenStringhas been locked- Specified by:
isLockedin 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 ExceptionQuick note about the implementation Since the acquisition policyAcquisitionPolicy.WAITcan 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:
lockin 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 ExceptionDescription copied from interface:PlanExecutionLockServiceA 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:
inlineProcessLocksin interfacePlanExecutionLockService- Returns:
- Throws:
Exception
-
interruptLockOwner
public void interruptLockOwner(@NotNull @NotNull TriggerableInternalKey internalKey)Description copied from interface:PlanExecutionLockServiceInterrupts the owner of the lock represented byTriggerableInternalKey- Specified by:
interruptLockOwnerin interfacePlanExecutionLockService
-
-