GigaSpaces XAP 7.0 API

org.openspaces.core.map
Class LockManager

java.lang.Object
  extended by org.openspaces.core.map.LockManager

public class LockManager
extends Object

The lock manager is built on top of IMap and supports the ability to lock and unlock certain keys within the map.

Author:
kimchy

Field Summary
static Object EMPTY_LOCK_VALUE
          A empty lock value written to indicate a lock when there is no value to lock on (i.e. calling lock on a key where there is no value in the cache).
 
Constructor Summary
LockManager(IMap map)
          Creates a new Lock Manager based on the IMap.
 
Method Summary
static boolean isEmptyLockValue(Object value)
           
 boolean islocked(Object key)
          Returns true if the given key is locked.
 LockHandle lock(Object key, long lockTimeToLive, long timeoutWaitingForLock)
          Locks the given key for any updates.
 void putAndUnlock(Object key, Object value)
          Unlocks the given key and puts the given value in a single operation.
 void unlock(Object key)
          Unlocks the given lock on the key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_LOCK_VALUE

public static final Object EMPTY_LOCK_VALUE
A empty lock value written to indicate a lock when there is no value to lock on (i.e. calling lock on a key where there is no value in the cache).

Constructor Detail

LockManager

public LockManager(IMap map)
Creates a new Lock Manager based on the IMap.

Method Detail

isEmptyLockValue

public static boolean isEmptyLockValue(Object value)

lock

public LockHandle lock(Object key,
                       long lockTimeToLive,
                       long timeoutWaitingForLock)
Locks the given key for any updates. Retruns a LockHandle that can be used to perform specific updates under the same lock (by using the transaction object stored within it).

Might create an empty value if there is no value in order to lock on. The empty value can be checked using isEmptyLockValue(Object).

Parameters:
key - The key to lock
lockTimeToLive - The lock time to live (in milliseconds)
timeoutWaitingForLock - The time to wait for an already locked lock
Returns:
LockHandle that can be used to perfrom operations under the given lock

putAndUnlock

public void putAndUnlock(Object key,
                         Object value)
Unlocks the given key and puts the given value in a single operation.

Parameters:
key - The key to unlock and put the value in
value - The value to put after unlocking the key

islocked

public boolean islocked(Object key)
Returns true if the given key is locked. Otherwise returns false.

Parameters:
key - The key to check if it locked or not.
Returns:
true if the given key is locked or not.

unlock

public void unlock(Object key)
Unlocks the given lock on the key

Parameters:
key - The key to unlock

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.