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
 void interruptLockOwner(PlanKey planKey)
          Interrupts the owner of the lock represented by PlanKey
 boolean isLocked(PlanKey planKey)
          Checks if the given PlanKey has been locked
<V> V
lock(PlanKey planKey, 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
                        PlanKey planKey)
Description copied from interface: PlanExecutionLockService
Checks if the given PlanKey has been locked

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

lock

public <V> V lock(@NotNull
                  PlanKey planKey,
                  @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:
planKey - to lock
acquisitionPolicy - to acquire the lock
callable - to execute
Returns:
callable result
Throws:
java.lang.Exception - if error

interruptLockOwner

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

Specified by:
interruptLockOwner in interface PlanExecutionLockService


Copyright © 2012 Atlassian. All Rights Reserved.