ehcache

net.sf.ehcache.transaction
Class ReadCommittedSoftLockImpl

java.lang.Object
  extended by net.sf.ehcache.transaction.ReadCommittedSoftLockImpl
All Implemented Interfaces:
SoftLock

public class ReadCommittedSoftLockImpl
extends Object
implements SoftLock

A SoftLock implementation with Read-Committed isolation level

Author:
Ludovic Orban

Method Summary
 void clearTryLock()
          Clear the state of the soft lock after a tryLock() call succeeded.
 void freeze()
          Freeze the soft lock.
 Element getElement(TransactionID currentTransactionId, SoftLockID softLockId)
          Get the element the current transaction is supposed to see.
 Object getKey()
          Get the key of the element this soft lock is guarding
 boolean isExpired()
          Check if the soft lock expired, ie: that the thread which locked it died
 void lock()
          Lock the soft lock
 String toString()
          
 boolean tryLock(long ms)
          Attempt to lock the soft lock
 void unfreeze()
          Unfreeze the soft lock
 void unlock()
          Unlock the soft lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getKey

public Object getKey()
Get the key of the element this soft lock is guarding

Specified by:
getKey in interface SoftLock
Returns:
the key

getElement

public Element getElement(TransactionID currentTransactionId,
                          SoftLockID softLockId)
Get the element the current transaction is supposed to see.

Specified by:
getElement in interface SoftLock
Parameters:
currentTransactionId - the current transaction under which this call is executed
softLockId - the soft lock ID
Returns:
the Element visible to the current transaction

lock

public void lock()
Lock the soft lock

Specified by:
lock in interface SoftLock

tryLock

public boolean tryLock(long ms)
                throws InterruptedException
Attempt to lock the soft lock

Specified by:
tryLock in interface SoftLock
Parameters:
ms - the time in milliseconds before this method gives up
Returns:
true if the soft lock was locked, false otherwise
Throws:
InterruptedException - if the thread calling this method was interrupted

clearTryLock

public void clearTryLock()
Clear the state of the soft lock after a tryLock() call succeeded.

Specified by:
clearTryLock in interface SoftLock

unlock

public void unlock()
Unlock the soft lock. Once a soft lock got unlocked, it is considered 'dead': it cannot be locked again and must be cleaned up

Specified by:
unlock in interface SoftLock

freeze

public void freeze()
Freeze the soft lock. A soft lock should only be frozen for a very short period of time as this blocks the SoftLock.getElement(TransactionID, SoftLockID) method calls. Freeze is used to mark the start of a commit / rollback phase

Specified by:
freeze in interface SoftLock

unfreeze

public void unfreeze()
Unfreeze the soft lock

Specified by:
unfreeze in interface SoftLock

isExpired

public boolean isExpired()
Check if the soft lock expired, ie: that the thread which locked it died

Specified by:
isExpired in interface SoftLock
Returns:
true if the soft lock is orphan and should be cleaned up, false otherwise

toString

public String toString()

Overrides:
toString in class Object

ehcache

Copyright 2001-2015, Terracotta, Inc.