KEY
- key typeVALUE
- value typePARAMETER
- invocation parameter typeRESULT
- result typepublic abstract class NamedMapInvokable<KEY,VALUE,PARAMETER,RESULT>
extends java.lang.Object
implements java.io.Serializable
Base class for implementing parallel invocations, which are executed on all keys in the map across
the cluster in a distributed manner. Instances of NamedMapInvokable
are submitted to the map by calling
NamedMap.invoke(NamedMapInvokable, Object)
.
Warning: an instance of NamedMapInvokable
can be used concurrently by several threads,
so implementations should not access any inner variables in a non-thread safe manner.
Constructor and Description |
---|
NamedMapInvokable() |
Modifier and Type | Method and Description |
---|---|
RESULT |
eval(KEY key,
VALUE value,
PARAMETER parameter)
This method is called for each key in the map.
|
RESULT |
evalPartialKeySet(NamedMapInvokableContext<KEY,VALUE> context,
PARAMETER parameter)
This method is called for a group of keys in the map.
|
CustomSerializer<RESULT> |
getParameterCustomSerializer()
Returns the
CustomSerializer used for serializing/deserializing invocation parameter
objects. |
CustomSerializer<RESULT> |
getResultCustomSerializer()
Returns the
CustomSerializer used for serializing/deserializing result objects. |
abstract RESULT |
merge(RESULT firstResult,
RESULT secondResult,
PARAMETER parameter)
This method is used for merging two invocation results into one.
|
public RESULT eval(KEY key, VALUE value, PARAMETER parameter) throws InvokeException
key
- key to processvalue
- value to processparameter
- invocation parameter objectnull
if this key does not have a result.InvokeException
- when a server invocation error has occurred.public RESULT evalPartialKeySet(NamedMapInvokableContext<KEY,VALUE> context, PARAMETER parameter) throws InvokeException
This method is called for a group of keys in the map. It is expected that it will
iterate through all keys and values by calling next(...) on the context
and getting
the current key and value through context.getKey()
and context.getValue()
.
It is important that the context only iterates through a subset of the keys in the map. The final result
is produced by calling merge(Object, Object, Object)
to perform a pairwise merge of all
subset results.
This method can be called concurrently by several threads, but with different context objects, so care should be taken not to store any non-thread safe state in class variables.
context
- operation context with methods to iterate through
keys and values; can also be used to modify the
current value or remove the current key from the mapparameter
- invocation parameter objectnull
if this group of keys does not have a result.InvokeException
- when a server invocation error has occurred.public abstract RESULT merge(RESULT firstResult, RESULT secondResult, PARAMETER parameter) throws InvokeException
This method is used for merging two invocation results into one.
Note: if the result objects are mutable, modifying and returning one of the provided results as a merged result can improve performance and memory efficiency by eliminating the need to allocate a new result object for each merge.firstResult
- first result to mergesecondResult
- second result to mergeparameter
- invocation parameter objectnull
if there is no such resultInvokeException
- when a server invocation error has occurred.public CustomSerializer<RESULT> getResultCustomSerializer()
CustomSerializer
used for serializing/deserializing result objects.
This method can be overridden to define custom serialization for the result object.
By default, standard serialization is used.public CustomSerializer<RESULT> getParameterCustomSerializer()
CustomSerializer
used for serializing/deserializing invocation parameter
objects. This method can be overridden to define custom serialization for the parameter object.
By default, standard serialization is used.