|
IBM WebSphereTM eXtreme Scale, Release 8.5 API Specification |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ObjectMap
This is a handle to a named Map. Maps should have homogeneous keys and values. An instance of this ObjectMap can only be used by the thread that is currently associated with the Session that was used to get this ObjectMap instance. Both Session and ObjectMap objects are not allowed to be shared by multiple threads concurrently.
The CopyMode
setting on the map determines whether or not a copy of the value is returned by get
methods. It also determines whether or not a copy of the committed value is made at commit time. The
LockStrategy
setting for the map determines whether or not a lock is obtained for each map entry
accessed by the transaction, the lock mode of the lock obtained, and when the lock is obtained.
Session.getMap(String)
,
BackingMap.setCopyMode(CopyMode, Class)
,
BackingMap.setLockStrategy(LockStrategy)
Field Summary | |
---|---|
static long |
QUEUE_TIMEOUT_INFINITE
Used as a parameter on the getNextKey(long) method, specifies the method should block until a key
becomes available. |
static long |
QUEUE_TIMEOUT_NONE
Used as a parameter on the getNextKey(long) method, specifies to return a null value if the map is
empty. |
static int |
TTL_FOREVER
A constant indicating the time-to-live value is "forever". |
static int |
USE_DEFAULT
A constant indicating the time-to-live value or lock timeout value is the default setting. |
Method Summary | |
---|---|
void |
clear()
Clear all keys from the Map. |
void |
clearCopyMode()
Resets the CopyMode back to the one in the BackingMap. |
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key. |
void |
flush()
Pushes the current set of changes for the ObjectMap instance to the Loader without
committing the changes. |
Object |
get(Object key)
Retrieves the object from the cache at the given key. |
AgentManager |
getAgentManager()
Returns the Agent Manager that allows DataGrid operations to be performed on the objects within this Map. |
List |
getAll(List keyList)
Gets a list of entries from the map. |
List |
getAllForUpdate(List keyList)
Same as the getAll(List) method except that if pessimistic lock strategy is used for this map, an
upgradable lock mode is obtained for these map entries. |
EntityMetadata |
getEntityMetadata()
Retrieve the metadata for the entity associated with this map. |
Object |
getForUpdate(Object key)
Same as get(Object) method except that if pessimistic lock strategy is used for this map, an
upgradable lock mode is obtained for this map entry. |
Object |
getIndex(String name)
Returns a reference to the named index that can be used with this Map. |
Object |
getIndex(String name,
boolean forUpdate)
Returns a reference to the named index that can be used with this Map. |
Map |
getJavaMap()
Returns an implementation of java.util.Map that is backed by this ObjectMap . |
int |
getMapType()
Returns the type of the underlying BackingMap. |
String |
getName()
Returns the name of the ObjectMap as defined by the configuration. |
Object |
getNextKey(long timeout)
Retrieves a key off the map in first-in-first-out (FIFO) insert order. |
void |
insert(Object key,
Object value)
Performs an explicit insert of a given entry. |
void |
invalidate(Object key,
boolean isGlobal)
Invalidates an entry in the cache based on the key parameter. |
void |
invalidateAll(Collection keyList,
boolean isGlobal)
Invalidate a set of cache entries based on the Collection of keys provided. |
Object |
put(Object key,
Object value)
Puts the Object value into the cache at location represented by key. |
void |
putAll(Map map)
Puts each of the Object value into the cache at location represented by key contained in the Map. |
Object |
remove(Object key)
Removes the Object value from the cache represented by key. |
void |
removeAll(Collection keyList)
Batch remove from the Map. |
void |
setCopyMode(CopyMode copyMode,
Class valueInterface)
Allows the CopyMode for the Map to be overridden on this map on this session only. |
void |
setLockTimeout(int seconds)
Overrides the BackingMap's lock timeout for this ObjectMap. |
int |
setTimeToLive(int ttl)
Establishes the number of seconds that any given cache entry can live for, which is referred to as "time to live" or TTL. |
void |
touch(Object key)
Updates the last access time in the BackingMap without retrieving the value to the ObjectMap. |
void |
update(Object key,
Object value)
Performs an explicit update of a given entry. |
Field Detail |
---|
static final int TTL_FOREVER
static final int USE_DEFAULT
The default setting is to retain the time-to-live value for any existing map entry and to use the default value from BackingMap setting if a new map entry is being created.
For lock timeout override the default setting is to use the value defined on the BackingMap
setLockTimeout(int)
,
setTimeToLive(int)
,
BackingMap.setTimeToLive(int)
,
BackingMap.getTimeToLive()
,
BackingMap.setLockTimeout(int)
,
Constant Field Valuesstatic final long QUEUE_TIMEOUT_NONE
getNextKey(long)
method, specifies to return a null value if the map is
empty.
static final long QUEUE_TIMEOUT_INFINITE
getNextKey(long)
method, specifies the method should block until a key
becomes available.
Method Detail |
---|
String getName()
Object get(Object key) throws ObjectGridException
Whether or not a copy of the object is returned is determined by the CopyMode setting for this map. See
CopyMode
for a description of each possible CopyMode. If the key cannot be found in the map, a
null
value will be returned. A null
value is also returned if a value is
null
and this map allows null
values. To distinguish the two, use the
containsKey
method.
The return value is a SerializedValue
when using the CopyMode.COPY_TO_BYTES_RAW
mode
with a ValueSerializerPlugin plug-in defined on the BackingMap. The SerializedValue
allows access to the value in its serialized form, or its native Java Object form.
The return value is a Tuple
when an an EntityManager API entity is associated with the BackingMap.
Required Client Permission: MapPermission.READ
key
- The entry to fetch
null
, SerializedValue
or Tuple
IllegalArgumentException
- if key is null
ObjectGridException
- if an error occurs during processingcontainsKey(Object)
,
getForUpdate(Object)
,
CopyMode
Object put(Object key, Object value) throws ObjectGridException
The value will be pushed down to the BackingMap/Loader at commit time. The semantics of this method are that a put without a preceding get is an insert. For an entry in a map, a put following a get is always an update. However, if the entry is not in the map, a put following a get is an insert.
Whether or not a copy of the object is made when transaction is committed is determined by the copy mode setting
for this map. See CopyMode
for a description of each possible copy mode.
The return value is a SerializedValue
when using the CopyMode.COPY_TO_BYTES_RAW
mode
with a ValueSerializerPlugin plug-in defined on the BackingMap. The SerializedValue
allows access to the value in its serialized form, or its native Java Object form.
The return value is a Tuple
when an an EntityManager API entity is associated with the BackingMap.
Required Client Permission: MapPermission.WRITE
key
- The entry to put into the mapvalue
- The value to put into the map using the key
IllegalArgumentException
- if key is null
, or if the map does not allow null
values and value is
null
ObjectGridException
- if an error occurs during processingCopyMode
Object getForUpdate(Object key) throws ObjectGridException
get(Object)
method except that if pessimistic lock strategy is used for this map, an
upgradable lock mode is obtained for this map entry. See LockStrategy.PESSIMISTIC
for additional
information. Whether or not a copy of the object is returned is determined by the CopyMode
setting
for this map. See CopyMode
for a description of each possible CopyMode. If the key cannot be found
in the map, a null
value will be returned. A null
value is also returned if the
value is null
and this map allows null
values. To distinguish the two, use the
containsKey
method.
The return value is a SerializedValue
when using the CopyMode.COPY_TO_BYTES_RAW
mode
with a ValueSerializerPlugin plug-in defined on the BackingMap. The SerializedValue
allows access to the value in its serialized form, or its native Java Object form.
The return value is a Tuple
when an an EntityManager API entity is associated with the BackingMap.
Required Client Permission: MapPermission.READ
key
- The entry to fetch
null
, SerializedValue
or Tuple
IllegalArgumentException
- if key is null
ObjectGridException
- if an error occurs during processingcontainsKey(Object)
,
get(Object)
,
CopyMode
,
LockStrategy.PESSIMISTIC
Object remove(Object key) throws ObjectGridException
This removal will be pushed down to the BackingMap/Loader at commit time. If the key cannot be found in the map, a null value will be returned.
The return value is a SerializedValue
when using the CopyMode.COPY_TO_BYTES_RAW
mode
with a ValueSerializerPlugin plug-in defined on the BackingMap. The SerializedValue
allows access to the value in its serialized form, or its native Java Object form.
The return value is a Tuple
when an an EntityManager API entity is associated with the BackingMap.
Required Client Permission: MapPermission.REMOVE
key
- The entry to remove
IllegalArgumentException
- if key is null
ObjectGridException
- if an error occurs during processingList getAll(List keyList) throws ObjectGridException
If a key in the list cannot be found, a null
value will be set at the appropriate position in the
returned list.
A return value is a SerializedValue
when using the CopyMode.COPY_TO_BYTES_RAW
mode
with a ValueSerializerPlugin plug-in defined on the BackingMap. The SerializedValue
allows access to the value in its serialized form, or its native Java Object form.
A return value is a Tuple
when an an EntityManager API entity is associated with the BackingMap.
Required Client Permission: MapPermission.READ
keyList
- A list of keys for identifying which entries to fetch
IllegalArgumentException
- if keyList is null or contains a null
element.
ObjectGridException
- if an error occurs during processingget(Object)
List getAllForUpdate(List keyList) throws ObjectGridException
getAll(List)
method except that if pessimistic lock strategy is used for this map, an
upgradable lock mode is obtained for these map entries. See LockStrategy.PESSIMISTIC
for
additional information. If a key in the list cannot be found, a null
value will be set at the
appropriate position in the returned list.
A return value is a SerializedValue
when using the CopyMode.COPY_TO_BYTES_RAW
mode
with a ValueSerializerPlugin plug-in defined on the BackingMap. The SerializedValue
allows access to the value in its serialized form, or its native Java Object form.
A return value is a Tuple
when an an EntityManager API entity is associated with the BackingMap.
Required Client Permission: MapPermission.READ
keyList
- A list of keys for identifying which entries to fetch
IllegalArgumentException
- if keyList is null or contains a null
element.
ObjectGridException
- if an error occurs during processinggetAll(List)
,
getForUpdate(Object)
,
LockStrategy.PESSIMISTIC
void removeAll(Collection keyList) throws ObjectGridException
Required Client Permission: MapPermission.REMOVE
keyList
- A list of keys for identifying which entries to remove
IllegalArgumentException
- if keyList is null or contains a null
element.
ObjectGridException
- if an error occurs during processingremove(Object)
void putAll(Map map) throws ObjectGridException
The value will be pushed down to the BackingMap/Loader at commit time. The semantics of this method are that a put without a preceding get is an insert. For an entry in a map, a put following a get is always an update. However, if the entry is not in the map, a put following a get is an insert.
Whether or not a copy of the object is made when transaction is committed is determined by the copy mode setting
for this map. See CopyMode
for a description of each possible copy mode.
An existing Map object will be passed in to use for obtaining the keys and values to be inserted or updated into the existing Map.
Required Client Permission: MapPermission.WRITE
map
- The key/values to be put into the map.
IllegalArgumentException
- if map is null
or contains a null
key or if null
values
are not allowed and map contains a null
value.
ObjectGridException
- if an error occurs during processingput(Object, Object)
void invalidate(Object key, boolean isGlobal) throws ObjectGridException
If the key's value has changes pending in the ObjectMap, it is the application's responsibility to flush these changes to the Loader before invalidation. If a flush is not performed prior to invoking the invalidate operation, all pending changes for this key will be removed from the ObjectMap. If the key cannot be found in the map, it will be ignored.
The isGlobal parameter is used to indicate which cache level is used to invalidate the entries. If isGlobal is true, when the transaction is committed, the key is removed from the BackingMap also. If a subsequent get operation is performed, the BackingMap will be skipped and the Loader will be used to get the data. If isGlobal is false, the entry is only invalidated in the ObjectMap (transactional cache). If a subsequent get operation is performed, the BackingMap can be used; and, if it's not in the BackingMap, the Loader will be used to get the data.
A typical use of isGlobal being false is when a large number of records are touched in a transaction and the application wants to evict records that are no longer used in the cache.
Required Client Permission: MapPermission.INVALIDATE
key
- Object representing the key to be used for cache entry invalidationisGlobal
- Indicates whether to remove the entry from the BackingMap (true) or just the ObjectMap (false).
IllegalArgumentException
- if key is null
ObjectGridException
- if an error occurs during processingvoid invalidateAll(Collection keyList, boolean isGlobal) throws ObjectGridException
Required Client Permission: MapPermission.INVALIDATE
keyList
- A Collection of keys representing the entries to be invalidatedisGlobal
- Indicates whether to remove the entry from the BackingMap (true) or just the ObjectMap (false).
IllegalArgumentException
- if keyList is null or contains a null
element.
ObjectGridException
- if an error occurs during processinginvalidate(Object, boolean)
int setTimeToLive(int ttl)
ObjectMap
, any previous value set by the BackingMap.setTimeToLive(int)
method is
overridden for this ObjectMap. If this method is never called on the ObjectMap, the default setting is used. The
default setting is to retain the time-to-live value for any existing map entry and to use the default value from
BackingMap setting if a new map entry is being created. If TTL is never set on the BackingMap, the cache entry
can live "forever".
This method can only be used when the TTLType
is set to LAST_ACCESS_TIME
or
LAST_UPDATE_TIME
on the BackingMap. If this method is called on the ObjectMap and the TTLType
is something other than LAST_ACCESS_TIME
or LAST_UPDATE_TIME
, an IllegalStateException is thrown.
Required Client Permission: MapPermission.INVALIDATE
ttl
- is the time-to-live value in seconds. The value must be >= -1. A value of 0
is used to indicate the cache entry can live "forever" and -1 to indicate to
use default setting. Use of the constant TTL_FOREVER
is recommended
when "forever" is desired and the constantUSE_DEFAULT
is recommended
when "use default" setting is desired.
TTL_FOREVER
and
constant USE_DEFAULT
can be used to determine if the previous
TTL is one of the special values.
IllegalArgumentException
- if seconds argument is < -1.
IllegalStateException
- if BackingMap.getTtlEvictorType()
returns anything other
than TTLType.LAST_ACCESS_TIME
or TTLType.LAST_UPDATE_TIME
.TTL_FOREVER
,
USE_DEFAULT
,
BackingMap.setTimeToLive(int)
,
TTLType.LAST_ACCESS_TIME
,
TTLType.LAST_UPDATE_TIME
void update(Object key, Object value) throws KeyNotFoundException, ObjectGridException
A get
operation is not required prior to invoking the update
method (unlike the
put
method). Also, an update
invocation will never insert a new record. If a the
map's LockStrategy
is LockStrategy.OPTIMISTIC
this method will implicitly get the
entry so as to have the version value of the object for when this method was invoked. Whether or not a copy of
the object is made when transaction is committed is determined by the CopyMode setting for this map. See
CopyMode
for a description of each possible CopyMode.
If a key cannot be found in the map during commit, a TransactionException will be thrown.
Required Client Permission: MapPermission.WRITE
key
- Identifies the entry to be updatedvalue
- The updated value for this entry
IllegalArgumentException
- if key is null
or if the map does not allow null
values and value is
null
.
KeyNotFoundException
- if the key cannot be found in the map
ObjectGridException
- if an error occurs during processinginsert(Object, Object)
,
put(Object, Object)
,
CopyMode
,
LockStrategy.OPTIMISTIC
void insert(Object key, Object value) throws DuplicateKeyException, ObjectGridException
The key must not exist before executing this method. Also, an insert
invocation will never update
an existing record. Whether or not a copy of the object is made when a transaction is committed is determined by
the CopyMode setting for this map. See CopyMode
for a description of each possible CopyMode.
If the key is already in the map, a TransactionException will be thrown during commit.
Required Client Permission: MapPermission.INSERT
key
- Identifies the entry to be insertedvalue
- The value for this entry
IllegalArgumentException
- if key is null
or if the map does not allow null
values and value is
null
.
DuplicateKeyException
- if this entries already exists in the map
ObjectGridException
- if an error occurs during processingput(Object, Object)
,
update(Object, Object)
,
CopyMode
Object getIndex(String name) throws IndexUndefinedException, IndexNotReadyException
Session
. The returned value should be cast to the right
index interface such as MapIndex
, MapRangeIndex
or a custom index interface such
as a geo spatial index.
name
- The index name
IndexUndefinedException
- if the index is not defined on the BackingMap
IndexNotReadyException
- if the index is a dynamic index and it is not readyObject getIndex(String name, boolean forUpdate) throws IndexUndefinedException, IndexNotReadyException
Session
. The returned value should be cast to the right
index interface such as MapIndex
, MapRangeIndex
or a custom index interface such
as a geo spatial index.
name
- The index nameforUpdate
- if true, the returned index will always operate with forUpdate intent.
IndexUndefinedException
- if the index is not defined on the BackingMap
IndexNotReadyException
- if the index is a dynamic index and it is not readyvoid flush() throws ObjectGridException
ObjectMap
instance to the Loader
without
committing the changes. The changes are not propagated to the BackingMap
either. This is useful
for re-priming the Loader
's data without committing the current transaction and starting over.
ObjectGridException
- if an error occurs during processingSession.flush()
boolean containsKey(Object key) throws ObjectGridException
true
if this map contains a mapping for the specified key. ObjectGrid does not support
null keys. If you configured the map to support null
values, this method can be used to determine
whether a key is contained in the map or not.
Required Client Permission: MapPermission.READ
key
- key whose presence in this map is to be tested.
true
if this map contains a mapping for the specified key.
IllegalArgumentException
- if null
key parameter is passed in
ObjectGridException
- if an error occurs during processingMap getJavaMap()
java.util.Map
that is backed by this ObjectMap
.
The returned java.util.Map
implementation can be cast to
com.ibm.websphere.objectgrid.JavaMap
to be able to use the rest of the ObjectGrid programming
model, but with java.util.Map
's use of RuntimeException
s instead of checked
ObjectGridException
s.
java.util.Map
backed by this ObjectMap
Map
,
JavaMap
void touch(Object key) throws ObjectGridException
The last access time is updated during commit. If the key does not exist in the BackingMap, a TransactionException will be returned during commit processing.
key
- key to be touched
IllegalArgumentException
- if key is null
ObjectGridException
- if an error occurs during processingvoid setCopyMode(CopyMode copyMode, Class valueInterface) throws TransactionAlreadyActiveException, ObjectGridException
This method allows an application to use an optimal CopyMode TRANSACTION by TRANSACTION as its needs dictate. The CopyMode cannot be changed during a transaction. There must be no active transaction when this method is called.
copyMode
- must be one of the final static variables defined in CopyMode
. See
CopyMode
class for an explanation of each mode and how the valueInterface is used for
CopyMode.COPY_ON_WRITE
.valueInterface
- the value interface Class object. Specify null in version 7.1 and later.
IllegalArgumentException
- if copyMode is null
or COPY_ON_WRITE CopyMode is specified and the required value
interface parameter is null
TransactionAlreadyActiveException
- if a transaction is active on the associated session
ObjectGridException
- if an error occurs during processingBackingMap.setCopyMode(CopyMode, Class)
,
CopyMode
void clearCopyMode() throws TransactionAlreadyActiveException
This method is used to reverse a previous setCopyMode method call for this ObjectMap. This method can only be called when no transaction is active on the associated session.
TransactionAlreadyActiveException
- if a transaction is active on the associated sessionsetCopyMode(CopyMode, Class)
Object getNextKey(long timeout) throws ObjectGridException
The entry is locked by the session such that other calls to getNextKey will not return the same key. The key can be used to remove or manipulate the value although leaving the entry will result in the key remaining at the beginning of the queue. This order is optimized for performance and is not guaranteed especially across partitions or in highly concurrent environments.
The return value is a SerializedKey
when using a KeySerializerPlugin plug-in defined on
the BackingMap. The SerializedKey allows access to the value in its serialized form, or
its native Java Object form.
The return value is a Tuple
when an an EntityManager API entity is associated with the BackingMap.
timeout
- The period of time in milliseconds to wait for an entry to become available on the queue.
ObjectGridException
- if an error occurs during processingQUEUE_TIMEOUT_INFINITE
,
QUEUE_TIMEOUT_NONE
EntityMetadata getEntityMetadata()
int getMapType()
The return value is equivalent to one of the constants declared on the BackingMap interface,
BackingMap.LOCAL
, BackingMap.SERVER
, or BackingMap.CLIENT
.
AgentManager getAgentManager()
This method should only be called on a client ObjectGrid. If called on a non client ObjectGrid an
IllegalStateException
will be thrown
IllegalStateException
- if this method is invoked on a non client ObjectGridvoid setLockTimeout(int seconds)
Establishes the number of seconds that any given fetch (get, getForUpdate, find, findForUpdate) of a cache entry
will wait to get a lock. When the lock strategy is LockStrategy.NONE
, no lock manager is used by
this map. In this case, a call to this method does nothing.
seconds
- is the lock timeout in seconds. The value must be >= -1. A value of -1 is used to indicate to use
the default setting. Use of the constantUSE_DEFAULT
is recommended when "use default"
setting is desired. A value of 0 indicates that if a lock cannot be retrieved immediately to time out
without waiting for any period of time for the lock to be released and made available.
IllegalArgumentException
- if seconds argument is less than -1 (USE_DEFAULT)USE_DEFAULT
,
BackingMap.setLockTimeout(int)
,
BackingMap.setLockStrategy(LockStrategy)
,
LockStrategy.OPTIMISTIC
,
LockStrategy.PESSIMISTIC
void clear() throws ObjectGridException
This method is an autocommit call, so a session should not be explicitly begun or committed when calling clear on the ObjectMap.
Required Client Permission: MapPermission.REMOVE
ObjectGridException
- if an error occurs during processing
TransactionAlreadyActiveException
- if a transaction is already started.
|
IBM WebSphereTM eXtreme Scale, Release 8.5 API Specification |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |