|
GigaSpaces - Open Spaces | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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(com.j_spaces.map.IMap map,
TransactionProvider txProvider,
ExceptionTranslator exTranslator,
int defaultIsolationLevel)
Constructs a new DefaultGigaMap implementation. |
Method Summary | |
---|---|
void |
addListener(com.j_spaces.javax.cache.CacheListener cacheListener)
|
void |
clear()
|
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)
|
boolean |
containsValue(Object value)
|
Set |
entrySet()
|
boolean |
evict(Object key)
|
Object |
get(Object 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)
|
com.j_spaces.javax.cache.CacheEntry |
getCacheEntry(Object 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. |
com.j_spaces.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()
|
boolean |
isLocked(Object key)
Returns true if the given key is locked. |
Set |
keySet()
|
void |
load(Object key)
|
void |
loadAll(Collection keys)
|
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)
|
Object |
put(Object key,
Object value)
|
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. |
void |
putAll(Map t)
|
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)
|
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(com.j_spaces.javax.cache.CacheListener cacheListener)
|
void |
setDefaultLockTimeToLive(long defaultLockTimeToLive)
|
void |
setDefaultTimeToLive(long defaultTimeToLive)
|
void |
setDefaultWaitForResponse(long defaultWaitForResponse)
|
void |
setDefaultWaitingForLockTimeout(long defaultWaitingForLockTimeout)
|
int |
size()
|
String |
toString()
|
void |
unlock(Object key)
Unlocks the given lock on the key |
Collection |
values()
|
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(com.j_spaces.map.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 com.j_spaces.map.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()
size
in interface com.j_spaces.javax.cache.Cache
size
in interface Map
public boolean isEmpty()
isEmpty
in interface com.j_spaces.javax.cache.Cache
isEmpty
in interface Map
public boolean containsKey(Object key)
containsKey
in interface com.j_spaces.javax.cache.Cache
containsKey
in interface Map
public boolean containsValue(Object value)
containsValue
in interface com.j_spaces.javax.cache.Cache
containsValue
in interface Map
public Object get(Object key)
get
in interface com.j_spaces.javax.cache.Cache
get
in interface Map
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)
put
in interface com.j_spaces.javax.cache.Cache
put
in interface Map
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, 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)
remove
in interface com.j_spaces.javax.cache.Cache
remove
in interface Map
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)
putAll
in interface com.j_spaces.javax.cache.Cache
putAll
in interface Map
public 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()
clear
in interface com.j_spaces.javax.cache.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()
keySet
in interface com.j_spaces.javax.cache.Cache
keySet
in interface Map
public Collection values()
values
in interface com.j_spaces.javax.cache.Cache
values
in interface Map
public Set entrySet()
entrySet
in interface com.j_spaces.javax.cache.Cache
entrySet
in interface Map
public void addListener(com.j_spaces.javax.cache.CacheListener cacheListener)
addListener
in interface com.j_spaces.javax.cache.Cache
public boolean evict(Object key)
evict
in interface com.j_spaces.javax.cache.Cache
public Map getAll(Collection keys) throws com.j_spaces.javax.cache.CacheException
getAll
in interface com.j_spaces.javax.cache.Cache
com.j_spaces.javax.cache.CacheException
public com.j_spaces.javax.cache.CacheEntry getCacheEntry(Object key)
getCacheEntry
in interface com.j_spaces.javax.cache.Cache
public void load(Object key) throws com.j_spaces.javax.cache.CacheException
load
in interface com.j_spaces.javax.cache.Cache
com.j_spaces.javax.cache.CacheException
public void loadAll(Collection keys) throws com.j_spaces.javax.cache.CacheException
loadAll
in interface com.j_spaces.javax.cache.Cache
com.j_spaces.javax.cache.CacheException
public Object peek(Object key)
peek
in interface com.j_spaces.javax.cache.Cache
public void removeListener(com.j_spaces.javax.cache.CacheListener cacheListener)
removeListener
in interface com.j_spaces.javax.cache.Cache
public 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 - Open Spaces | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |