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

java.lang.Object
  extended by org.terracotta.locking.strategy.BasicLockStrategy<K>
      extended by org.terracotta.locking.strategy.NullLockStrategy<K>
All Implemented Interfaces:
GenericLockStrategy<String,K>, LockStrategy<K>

public class NullLockStrategy<K>
extends BasicLockStrategy<K>

A non-locking lock strategy.

Using this implementation results in a HashMap like distributed map which relies on external locking to provide visibility and exclusion guarantees.


Constructor Summary
NullLockStrategy()
           
 
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.
 String generateLockIdForKey(String instanceQualifier, K key)
          Generate the lock identifier to be used when performing operations for the given key.
 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
 

Constructor Detail

NullLockStrategy

public NullLockStrategy()
Method Detail

generateLockIdForKey

public String generateLockIdForKey(String instanceQualifier,
                                   K key)
Description copied from interface: LockStrategy
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.

Parameters:
instanceQualifier - A unique identifier for the map being operated on.
key - key to be locked
Returns:
lock identifier

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>
Overrides:
beginLock in class BasicLockStrategy<K>
Parameters:
lockID - lock to lock
type - hold type to acquire

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>
Overrides:
commitLock in class BasicLockStrategy<K>
Parameters:
lockID - lock to unlock
type - hold type to release

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>
Overrides:
unpinLock in class BasicLockStrategy<K>

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>
Overrides:
pinLock in class BasicLockStrategy<K>

tryBeginLock

public boolean tryBeginLock(String lockID,
                            int type,
                            long nanos)
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>
Overrides:
tryBeginLock in class BasicLockStrategy<K>
Parameters:
lockID - lock to lock
type - hold type to acquire


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