|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openspaces.core.DefaultGigaMap
public class DefaultGigaMap
An implementation of the GigaMap
interface simplifying the work with
JCache and Map interface on top of the Space.
Provides declarative transactions support (for methods that are by nature transactional, such as
get
and put
) and the ability to set defaults for both timeToLive
and waitForResponse
.
Will also automatically apply the current running transaction isolation level when performing read operations (that in turn are translated into the Space).
Constructor Summary | |
---|---|
DefaultGigaMap(IMap map,
TransactionProvider txProvider,
ExceptionTranslator exTranslator,
int defaultIsolationLevel)
Constructs a new DefaultGigaMap implementation. |
Method Summary | |
---|---|
void |
addListener(CacheListener cacheListener)
Add a listener to the list of cache listeners. |
void |
clear()
The clear method will remove all objects from the cache including the key and the associated value. |
void |
clear(boolean clearMaster)
The clear method will remove all objects from the cache including the key and the associated value. |
boolean |
containsKey(Object key)
Returns true if the cache contains the specified key. |
boolean |
containsValue(Object value)
Returns true if this cache maps one or more keys to the specified value. |
Set |
entrySet()
Returns a set view of the objects currently contained in the cache. |
boolean |
evict(Object key)
The evict method will remove object from the cache the matches the provided key. |
Object |
get(Object key)
The get method will return, from the cache, the object associated with the argument "key". |
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. |
Map |
getAll(Collection keys)
The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys". |
CacheEntry |
getCacheEntry(Object key)
Returns the CacheEntry object associated with the object identified by "key". |
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. |
int |
getModifiersForIsolationLevel()
Gets the isolation level from the current running transaction (enabling the usage of Spring declarative isolation level settings). |
TransactionProvider |
getTxProvider()
Returns the transaction provider allowing accessing the current running transaction. |
boolean |
isEmpty()
Return true if entrySet().isEmpty() return true. |
boolean |
isLocked(Object key)
Returns true if the given key is locked. |
Set |
keySet()
Returns a set view of the keys currently contained in the cache. |
void |
load(Object key)
The load method provides a means to "pre load" the cache. |
void |
loadAll(Collection keys)
The loadAll method provides a means to "pre load" objects into the cache. |
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 |
peek(Object key)
The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache. |
Object |
put(Object key,
Object value)
The put method adds the object "value" to the cache identified by the object "key". |
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)
Copies all of the mappings from the specified map to 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)
The remove method will delete the object from the cache including the key, the associated value and the associated CacheStatistics object. |
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 |
removeListener(CacheListener cacheListener)
Remove a listener from the list of cache listeners. |
void |
setDefaultLockTimeToLive(long defaultLockTimeToLive)
|
void |
setDefaultTimeToLive(long defaultTimeToLive)
|
void |
setDefaultWaitForResponse(long defaultWaitForResponse)
|
void |
setDefaultWaitingForLockTimeout(long defaultWaitingForLockTimeout)
|
int |
size()
Returns the size of this map. |
String |
toString()
|
void |
unlock(Object key)
Unlocks the given lock on the key |
Collection |
values()
Returns a collection view of the values contained in this cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.j_spaces.javax.cache.Cache |
---|
equals, hashCode |
Constructor Detail |
---|
public DefaultGigaMap(IMap map, TransactionProvider txProvider, ExceptionTranslator exTranslator, int defaultIsolationLevel)
map
- The map implementation to delegate operations totxProvider
- The transaction provider for declarative transaction ex.exTranslator
- Exception translator to translate low level exceptions into GigaSpaces runtime
exceptionMethod Detail |
---|
public void setDefaultWaitForResponse(long defaultWaitForResponse)
public void setDefaultTimeToLive(long defaultTimeToLive)
public void setDefaultLockTimeToLive(long defaultLockTimeToLive)
public void setDefaultWaitingForLockTimeout(long defaultWaitingForLockTimeout)
public IMap getMap()
GigaMap
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 GigaMap.getTxProvider()
should be used to acquire the
current running transaction.
getMap
in interface GigaMap
public TransactionProvider getTxProvider()
GigaMap
IMap
operations that requires explicit
transaction object.
getTxProvider
in interface GigaMap
public int size()
Cache
size
in interface Cache
size
in interface Map
public boolean isEmpty()
Cache
isEmpty
in interface Cache
isEmpty
in interface Map
true
if emptypublic boolean containsKey(Object key)
Cache
containsKey
in interface Cache
containsKey
in interface Map
key
- key whose presence in this cache is to be tested.
true
, if the cache contains the specified key.public boolean containsValue(Object value)
Cache
containsValue
in interface Cache
containsValue
in interface Map
value
- value whose presence in this cache is to be tested.
true
, if the cache contains the specified value.public Object get(Object key)
Cache
get
in interface Cache
get
in interface Map
key
- key whose associated value is to be returned.
public Object get(Object key, long waitForResponse)
GigaMap
key
in this cache.
Client will wait at most waitForResponse
milliseconds for
get call to return.
get
in interface GigaMap
key
- key whose associated value is to be returned.waitForResponse
- time to wait for response
public Object get(Object key, long waitForResponse, int modifiers)
GigaMap
key
in this cache.
Client will wait at most waitForResponse
milliseconds for
get call to return.
get
in interface GigaMap
key
- key whose associated value is to be returned.waitForResponse
- time to wait for responsemodifiers
- one or a union of ReadModifiers
.
public Object put(Object key, Object value)
Cache
put
in interface Cache
put
in interface Map
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
public Object put(Object key, Object value, long timeToLive)
GigaMap
value
to the cache with specified key
for
timeToLive
milliseconds to live in the cache.
put
in interface GigaMap
key
- key for the value
value
- object(~ entry)timeToLive
- time to keep object in this cache, in milliseconds
public Object put(Object key, Object value, long timeToLive, long timeout)
GigaMap
value
to the cache with specified key
for
timeToLive
milliseconds to live in the cache.
put
in interface GigaMap
key
- key for the value
value
- object(~ entry)timeToLive
- time to keep object in this cache, in millisecondstimeout
- A timeout to use if the object is locked under a transaction (in milliseconds)
public Object put(Object key, Object value, LockHandle lockHandle)
GigaMap
value
to the cache with specified key
.
put
in interface GigaMap
key
- key for the value
value
- object(~ entry)lockHandle
- If the key is locked, will perform the operation within the same lock
public Object put(Object key, Object value, long timeToLive, LockHandle lockHandle)
GigaMap
value
to the cache with specified key
for
timeToLive
milliseconds to live in the cache.
put
in interface GigaMap
key
- key for the value
value
- object(~ entry)timeToLive
- time to keep object in this cache, in millisecondslockHandle
- If the key is locked, will perform the operation within the same lock
public Object remove(Object key)
Cache
remove
in interface Cache
remove
in interface Map
key
- key whose associated value is to be removed.
public Object remove(Object key, long waitForResponse)
GigaMap
key
from this cache.
Client will wait at most waitForResponse
milliseconds for
get call to return.
remove
in interface GigaMap
key
- key whose associated value is to be returned.waitForResponse
- time to wait for response
public Object remove(Object key, long waitForResponse, LockHandle lockHandle)
GigaMap
key
from this cache.
Client will wait at most waitForResponse
milliseconds for
get call to return.
remove
in interface GigaMap
key
- key whose associated value is to be returned.waitForResponse
- time to wait for responselockHandle
- If the key is locked, will perform the operation within the same lock
public void putAll(Map t)
Cache
putAll
in interface Cache
putAll
in interface Map
t
- A map of key and values to be copy into the cachepublic void putAll(Map t, long timeToLive)
GigaMap
putAll
in interface GigaMap
t
- A map of key and values to be copy into the cachepublic void clear()
Cache
clear
in interface Cache
clear
in interface Map
public void clear(boolean clearMaster)
GigaMap
clear
in interface GigaMap
clearMaster
- if true
clear also master, when false
same as Map.clear()
.)public Set keySet()
Cache
keySet
in interface Cache
keySet
in interface Map
public Collection values()
Cache
values
in interface Cache
values
in interface Map
public Set entrySet()
Cache
entrySet
in interface Cache
entrySet
in interface Map
public void addListener(CacheListener cacheListener)
Cache
addListener
in interface Cache
cacheListener
- call back CacheListener
public boolean evict(Object key)
Cache
evict
in interface Cache
key
- the key to evict
true
, if the key was evictedpublic Map getAll(Collection keys) throws CacheException
Cache
getAll
in interface Cache
keys
- keys whose associated values are to be returned.
CacheException
- error accord while loadingpublic CacheEntry getCacheEntry(Object key)
Cache
getCacheEntry
in interface Cache
key
- key whose associated value is to be returned.
public void load(Object key) throws CacheException
Cache
CacheLoader
. If the object already exists
in the cache, no action is taken. If no loader is associated with the
object, no object will be loaded into the cache.
load
in interface Cache
key
- key whose associated value is to be loaded.
CacheException
- error accord while loadingpublic void loadAll(Collection keys) throws CacheException
Cache
loadAll
in interface Cache
keys
- keys' Collection whose associated value to be loaded using the associated
CacheLoader
if this cache doesn't contain it.
CacheException
- error accord while loadingpublic Object peek(Object key)
Cache
peek
in interface Cache
key
- key whose associated value is to be peek.
public void removeListener(CacheListener cacheListener)
Cache
removeListener
in interface Cache
cacheListener
- the CacheListener
to removepublic net.jini.core.transaction.Transaction getCurrentTransaction()
GigaMap
null
if no transaction is in progress.
getCurrentTransaction
in interface GigaMap
public LockHandle lock(Object key)
GigaMap
LockHandle
that can be bused to perform specific updates under the same lock (by calling
GigaMap.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.
lock
in interface GigaMap
key
- The key to lock
public LockHandle lock(Object key, long lockTimeToLive, long waitingForLockTimeout)
GigaMap
LockHandle
that can be used to perform specific updates under the same lock (by using the transaction
object stored within it).
lock
in interface GigaMap
key
- The key to locklockTimeToLive
- The lock time to live (in milliseconds)waitingForLockTimeout
- The time to wait for an already locked lock
public void unlock(Object key)
GigaMap
unlock
in interface GigaMap
key
- The key to unlockpublic boolean isLocked(Object key)
GigaMap
true
if the given key is locked. Otherwise returns false
.
isLocked
in interface GigaMap
key
- The key to check if it locked or not.
true
if the given key is locked or not.public void putAndUnlock(Object key, Object value)
GigaMap
putAndUnlock
in interface GigaMap
key
- The key to unlock and put the value invalue
- The value to put after unlocking the keypublic long getDefaultTimeToLive()
GigaMap
getDefaultTimeToLive
in interface GigaMap
public long getDefaultWaitForResponse()
GigaMap
getDefaultWaitForResponse
in interface GigaMap
public int getModifiersForIsolationLevel()
TransactionDefinition.ISOLATION_DEFAULT
will use the
default isolation level associated with this class (which is REPEATABLE_READ
).
public String toString()
toString
in class Object
|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |