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

java.lang.Object
  extended by org.terracotta.locking.strategy.LongLockStrategy<K>
All Implemented Interfaces:
GenericLockStrategy<Long,K>

public class LongLockStrategy<K>
extends Object
implements GenericLockStrategy<Long,K>


Constructor Summary
LongLockStrategy()
           
 
Method Summary
 void beginLock(Long lockID, int type)
          Called to acquire a lock on the given lockId at the given level.
 void commitLock(Long lockID, int type)
          Called to release a lock on the given lockId held at the given level.
 Long generateLockIdForKey(String instanceQualifier, K key)
          Generate the lock identifier to be used when performing operations for the given key.
 void pinLock(Long lockID)
          Called to indicate that the associated lock might be required frequently.
 boolean tryBeginLock(Long lockID, int type, long nanos)
          Called to attempt to acquire a lock on the given lockId at the given level.
 void unpinLock(Long 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
 

Constructor Detail

LongLockStrategy

public LongLockStrategy()
Method Detail

generateLockIdForKey

public Long generateLockIdForKey(String instanceQualifier,
                                 K key)
Description copied from interface: GenericLockStrategy
Generate the lock identifier to be used when performing operations for the given key.

To prevent inter-map lock collisions the instanceQualifier provided by the caller should be used to form the key.

Specified by:
generateLockIdForKey in interface GenericLockStrategy<Long,K>
Parameters:
instanceQualifier - A unique identifier for the map being operated on.
key - key to be locked
Returns:
lock identifier

beginLock

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

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

pinLock

public void pinLock(Long lockID)
Description copied from interface: GenericLockStrategy
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<Long,K>

unpinLock

public void unpinLock(Long lockId)
Description copied from interface: GenericLockStrategy
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<Long,K>

commitLock

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

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

tryBeginLock

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

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


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