GigaSpaces XAP 7.0 API

org.openspaces.core
Interface GigaMap

All Superinterfaces:
Cache, Map
All Known Implementing Classes:
DefaultGigaMap

public interface GigaMap
extends Map, Cache

Provides a simpler interface on top of IMap and Cache implementation.

Though this interface has a single implementation it is still important to work against the interface as it allows for simpler testing and mocking.

Transaction management is implicit and works in a declarative manner. Operations do not accept a transaction object, and will automatically use the TransactionProvider in order to acquire the current running transaction. If there is no current running transaction the operation will be executed without a transaction.

Author:
kimchy

Method Summary
 void clear(boolean clearMaster)
          The clear method will remove all objects from the cache including the key and the associated value.
 Object get(Object key, long waitForResponse)
          Returns the object that is associated with key in this cache.
 Object get(Object key, long waitForResponse, int modifiers)
          Returns the object that is associated with key in this cache.
 net.jini.core.transaction.Transaction getCurrentTransaction()
          Returns the current running transaction.
 long getDefaultTimeToLive()
          Returns the default time to live of entries in the map.
 long getDefaultWaitForResponse()
          Returns the default wait for response value for entries in the map.
 IMap getMap()
          Returns the IMap used by this GigaMap implementation to delegate different space operations.
 TransactionProvider getTxProvider()
          Returns the transaction provider allowing accessing the current running transaction.
 boolean isLocked(Object key)
          Returns true if the given key is locked.
 LockHandle lock(Object key)
          Locks the given key for any updates.
 LockHandle lock(Object key, long lockTimeToLive, long waitingForLockTimeout)
          Locks the given key for any updates.
 Object put(Object key, Object value, LockHandle lockHandle)
          Puts value to the cache with specified key.
 Object put(Object key, Object value, long timeToLive)
          Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.
 Object put(Object key, Object value, long timeToLive, LockHandle lockHandle)
          Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.
 Object put(Object key, Object value, long timeToLive, long timeout)
          Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.
 void putAll(Map t, long timeToLive)
          Copies all of the mappings from the specified map to the cache.
 void putAndUnlock(Object key, Object value)
          Unlocks the given key and puts the given value in a single operation.
 Object remove(Object key, long waitForResponse)
          Removes the mapping for this key from this cache.
 Object remove(Object key, long waitForResponse, LockHandle lockHandle)
          Removes the mapping for this key from this cache.
 void unlock(Object key)
          Unlocks the given lock on the key
 
Methods inherited from interface com.j_spaces.javax.cache.Cache
addListener, clear, containsKey, containsValue, entrySet, equals, evict, get, getAll, getCacheEntry, hashCode, isEmpty, keySet, load, loadAll, peek, put, putAll, remove, removeListener, size, values
 

Method Detail

getMap

IMap getMap()
Returns the IMap used by this GigaMap implementation to delegate different space operations.

Allows to execute map operations that are not exposed by this interface, as well as using it as a parameter to other low level GigaSpace components.

If a transaction object is required for low level operations (as low level operations do not have declarative transaction ex) the getTxProvider() should be used to acquire the current running transaction.


getTxProvider

TransactionProvider getTxProvider()
Returns the transaction provider allowing accessing the current running transaction. Allows to execute low level IMap operations that requires explicit transaction object.


getCurrentTransaction

net.jini.core.transaction.Transaction getCurrentTransaction()
Returns the current running transaction. Can be null if no transaction is in progress.


get

Object get(Object key,
           long waitForResponse)
Returns the object that is associated with key in this cache. Client will wait at most waitForResponse milliseconds for get call to return.

Parameters:
key - key whose associated value is to be returned.
waitForResponse - time to wait for response
Returns:
Returns the object that is associated with the key

get

Object get(Object key,
           long waitForResponse,
           int modifiers)
Returns the object that is associated with key in this cache. Client will wait at most waitForResponse milliseconds for get call to return.

Parameters:
key - key whose associated value is to be returned.
waitForResponse - time to wait for response
modifiers - one or a union of ReadModifiers.
Returns:
Returns the object that is associated with the key

put

Object put(Object key,
           Object value,
           long timeToLive)
Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.

Parameters:
key - key for the value
value - object(~ entry)
timeToLive - time to keep object in this cache, in milliseconds
Returns:
previous value associated with specified key, or null if there was no mapping for key.

put

Object put(Object key,
           Object value,
           long timeToLive,
           long timeout)
Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.

Parameters:
key - key for the value
value - object(~ entry)
timeToLive - time to keep object in this cache, in milliseconds
timeout - A timeout to use if the object is locked under a transaction (in milliseconds)
Returns:
previous value associated with specified key, or null if there was no mapping for key.

put

Object put(Object key,
           Object value,
           LockHandle lockHandle)
Puts value to the cache with specified key.

Parameters:
key - key for the value
value - object(~ entry)
lockHandle - If the key is locked, will perform the operation within the same lock
Returns:
previous value associated with specified key, or null if there was no mapping for key.

put

Object put(Object key,
           Object value,
           long timeToLive,
           LockHandle lockHandle)
Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.

Parameters:
key - key for the value
value - object(~ entry)
timeToLive - time to keep object in this cache, in milliseconds
lockHandle - If the key is locked, will perform the operation within the same lock
Returns:
previous value associated with specified key, or null if there was no mapping for key.

putAll

void putAll(Map t,
            long timeToLive)
Copies all of the mappings from the specified map to the cache.

Parameters:
t - A map of key and values to be copy into the cache

remove

Object remove(Object key,
              long waitForResponse)
Removes the mapping for this key from this cache. Client will wait at most waitForResponse milliseconds for get call to return.

Parameters:
key - key whose associated value is to be returned.
waitForResponse - time to wait for response
Returns:
The removed object

remove

Object remove(Object key,
              long waitForResponse,
              LockHandle lockHandle)
Removes the mapping for this key from this cache. Client will wait at most waitForResponse milliseconds for get call to return.

Parameters:
key - key whose associated value is to be returned.
waitForResponse - time to wait for response
lockHandle - If the key is locked, will perform the operation within the same lock
Returns:
The removed object

clear

void clear(boolean clearMaster)
The clear method will remove all objects from the cache including the key and the associated value.

Parameters:
clearMaster - if true clear also master, when false same as Map.clear().)

lock

LockHandle lock(Object key)
Locks the given key for any updates. Returns a LockHandle that can be bused to perform specific updates under the same lock (by calling put(Object,Object,org.openspaces.core.map.LockHandle) for example).

Will use the configured default lock time to live and default waiting for lock timeout values. By default the lock time to live is 60 seconds and waiting for lock timeout is 10 seconds.

Parameters:
key - The key to lock
Returns:
LockHandle that can be used to perform operations under the given lock

lock

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

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

unlock

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

Parameters:
key - The key to unlock

isLocked

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.

putAndUnlock

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

getDefaultTimeToLive

long getDefaultTimeToLive()
Returns the default time to live of entries in the map.


getDefaultWaitForResponse

long getDefaultWaitForResponse()
Returns the default wait for response value for entries in the map.


GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.