com.atlassian.bamboo.plan
Class PlanExecutionLockServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl
All Implemented Interfaces:
PlanExecutionLockService

public class PlanExecutionLockServiceImpl
extends java.lang.Object
implements PlanExecutionLockService


Constructor Summary
PlanExecutionLockServiceImpl()
           
 
Method Summary
<V> V
inlineProcessLocks(TriggerableInternalKey internalKey, AcquisitionPolicy acquisitionPolicy, java.util.concurrent.Callable<V> callable)
          A parallel locking mechanism that allows a backdoor to the standard lock.
 void interruptLockOwner(TriggerableInternalKey internalKey)
          Interrupts the owner of the lock represented by TriggerableInternalKey
 boolean isLocked(TriggerableInternalKey internalKey)
          Checks if the given String has been locked
<V> V
lock(TriggerableInternalKey internalKey, AcquisitionPolicy acquisitionPolicy, java.util.concurrent.Callable<V> callable)
          Quick note about the implementation Since the acquisition policy AcquisitionPolicy.WAIT can block for an indefinite amount of time we acquire this lock before trying to take the global execution lock otherwise callers to runWhenNoExecutionRequestsAreBeingMade(Callable) in the worst case will wait indefinitely.
<V> V
runWhenNoExecutionRequestsAreBeingMade(java.util.concurrent.Callable<V> callable)
          Executes the given Callable when there are no requests being made to execute plans
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlanExecutionLockServiceImpl

public PlanExecutionLockServiceImpl()
Method Detail

runWhenNoExecutionRequestsAreBeingMade

public <V> V runWhenNoExecutionRequestsAreBeingMade(@NotNull
                                                    java.util.concurrent.Callable<V> callable)
                                         throws java.lang.Exception
Description copied from interface: PlanExecutionLockService
Executes the given Callable when there are no requests being made to execute plans

Specified by:
runWhenNoExecutionRequestsAreBeingMade in interface PlanExecutionLockService
Type Parameters:
V - callable result type
Parameters:
callable - to execute
Returns:
callable result
Throws:
java.lang.Exception - if error

isLocked

public boolean isLocked(@NotNull
                        TriggerableInternalKey internalKey)
Description copied from interface: PlanExecutionLockService
Checks if the given String has been locked

Specified by:
isLocked in interface PlanExecutionLockService
Parameters:
internalKey - to check
Returns:
locked state

lock

public <V> V lock(@NotNull
                  TriggerableInternalKey internalKey,
                  @NotNull
                  AcquisitionPolicy acquisitionPolicy,
                  @NotNull
                  java.util.concurrent.Callable<V> callable)
       throws java.lang.Exception
Quick note about the implementation Since the acquisition policy AcquisitionPolicy.WAIT can block for an indefinite amount of time we acquire this lock before trying to take the global execution lock otherwise callers to runWhenNoExecutionRequestsAreBeingMade(Callable) in the worst case will wait indefinitely.

Specified by:
lock in interface PlanExecutionLockService
Type Parameters:
V - callable result type
Parameters:
internalKey - to lock
acquisitionPolicy - to acquire the lock
callable - to execute
Returns:
callable result
Throws:
java.lang.Exception - if error

inlineProcessLocks

public <V> V inlineProcessLocks(@NotNull
                                TriggerableInternalKey internalKey,
                                @NotNull
                                AcquisitionPolicy acquisitionPolicy,
                                @NotNull
                                java.util.concurrent.Callable<V> callable)
                     throws java.lang.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 in PlanExecutionLockService.isLocked(TriggerableInternalKey) and PlanExecutionLockService.interruptLockOwner(TriggerableInternalKey)

Specified by:
inlineProcessLocks in interface PlanExecutionLockService
Returns:
Throws:
java.lang.Exception

interruptLockOwner

public void interruptLockOwner(@NotNull
                               TriggerableInternalKey internalKey)
Description copied from interface: PlanExecutionLockService
Interrupts the owner of the lock represented by TriggerableInternalKey

Specified by:
interruptLockOwner in interface PlanExecutionLockService


Copyright © 2013 Atlassian Software Systems Pty Ltd. All Rights Reserved.