org.terracotta.locking.strategy
Class BasicLockStrategy<K>

java.lang.Object
  extended by org.terracotta.locking.strategy.BasicLockStrategy<K>
Type Parameters:
K - supported key type.
All Implemented Interfaces:
GenericLockStrategy<String,K>, LockStrategy<K>
Direct Known Subclasses:
HashcodeLockStrategy, NullLockStrategy, OneToOneLockStrategy

public abstract class BasicLockStrategy<K>
extends Object
implements LockStrategy<K>

A simple always locking abstract LockStrategy.

Subclasses need only implement a method for lock string generation in order to have a fully functional lock strategy.


Constructor Summary
BasicLockStrategy()
           
 
Method Summary
 void beginLock(String lockID, int type)
          Called to acquire a lock on the given lockId at the given level.
 void commitLock(String lockID, int type)
          Called to release a lock on the given lockId held at the given level.
 void pinLock(String lockID)
          Called to indicate that the associated lock might be required frequently.
 boolean tryBeginLock(String lockID, int type, long nanos)
          Called to attempt to acquire a lock on the given lockId at the given level.
 void unpinLock(String lockID)
          Called to indicate that the associated lock is no longer required frequently.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.terracotta.locking.LockStrategy
generateLockIdForKey
 

Constructor Detail

BasicLockStrategy

public BasicLockStrategy()
Method Detail

beginLock

public void beginLock(String lockID,
                      int type)
Description copied from interface: LockStrategy
Called to acquire a lock on the given lockId at the given level.

Specified by:
beginLock in interface GenericLockStrategy<String,K>
Specified by:
beginLock in interface LockStrategy<K>
Parameters:
lockID - lock to lock
type - hold type to acquire

pinLock

public void pinLock(String lockID)
Description copied from interface: LockStrategy
Called to indicate that the associated lock might be required frequently.

This call can be used to help guide resource allocation and collection.

Specified by:
pinLock in interface GenericLockStrategy<String,K>
Specified by:
pinLock in interface LockStrategy<K>

unpinLock

public void unpinLock(String lockID)
Description copied from interface: LockStrategy
Called to indicate that the associated lock is no longer required frequently.

This call can be used to help guide resource allocation and collection.

Specified by:
unpinLock in interface GenericLockStrategy<String,K>
Specified by:
unpinLock in interface LockStrategy<K>

commitLock

public void commitLock(String lockID,
                       int type)
Description copied from interface: LockStrategy
Called to release a lock on the given lockId held at the given level.

Specified by:
commitLock in interface GenericLockStrategy<String,K>
Specified by:
commitLock in interface LockStrategy<K>
Parameters:
lockID - lock to unlock
type - hold type to release

tryBeginLock

public boolean tryBeginLock(String lockID,
                            int type,
                            long nanos)
                     throws InterruptedException
Description copied from interface: LockStrategy
Called to attempt to acquire a lock on the given lockId at the given level.

Specified by:
tryBeginLock in interface GenericLockStrategy<String,K>
Specified by:
tryBeginLock in interface LockStrategy<K>
Parameters:
lockID - lock to lock
type - hold type to acquire
Throws:
InterruptedException


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.