com.bigdata.concurrent
Class LockManagerTask<R extends Comparable<R>,T>

java.lang.Object
  extended by com.bigdata.concurrent.LockManagerTask<R,T>
All Implemented Interfaces:
Callable<T>

public class LockManagerTask<R extends Comparable<R>,T>
extends Object
implements Callable<T>

Class encapsulates handshaking with the LockManager for an operation requiring exclusive access to one or more resources and that are willing to pre-declare their resource requirements.

Version:
$Id: LockManagerTask.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static boolean INFO
           
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
LockManagerTask(LockManager<R> lockManager, R[] resource, Callable<T> target)
           
 
Method Summary
 T call()
          Acquires pre-declared locks and then runs the operation identified to the constructor.
 long getLockLatency()
          The elapsed nanoseconds the task waited to acquire its locks.
 LockManager<R> getLockManager()
          The LockManager.
 long getLockTimeout()
          The timeout (milliseconds) or ZERO (0L) for an infinite timeout.
 int getMaxLockTries()
          The maximum #of times that the task will attempt to acquire its locks (positive integer).
 R[] getResource()
          The resource(s) that are pre-declared by the task.
 long setLockTimeout(long newValue)
           
 int setMaxLockTries(int newValue)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

INFO

protected static final boolean INFO
Constructor Detail

LockManagerTask

public LockManagerTask(LockManager<R> lockManager,
                       R[] resource,
                       Callable<T> target)
Parameters:
lockManager - The lock manager.
resource - The resource(s) to be locked.
target - The Runnable target that will be invoked iff the locks are successfully acquired.
Method Detail

getLockManager

public LockManager<R> getLockManager()
The LockManager.


getResource

public R[] getResource()
The resource(s) that are pre-declared by the task. call() will ensure that the task as a lock on these resources before it invokes #run() to execution the task.


setMaxLockTries

public int setMaxLockTries(int newValue)

getLockLatency

public long getLockLatency()
The elapsed nanoseconds the task waited to acquire its locks.


getMaxLockTries

public int getMaxLockTries()
The maximum #of times that the task will attempt to acquire its locks (positive integer).


setLockTimeout

public long setLockTimeout(long newValue)

getLockTimeout

public long getLockTimeout()
The timeout (milliseconds) or ZERO (0L) for an infinite timeout.


call

public final T call()
             throws Exception
Acquires pre-declared locks and then runs the operation identified to the constructor.

Specified by:
call in interface Callable<T>
Returns:
null
Throws:
Exception - if something goes wrong.
InterruptedException - if the current thread is interrupted.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.