@FunctionalInterface public interface Function extends Identifiable<java.lang.String>
Function
s can be of different
types. Some can have results while others need not return any result. Some functions require
writing in the targeted Region
while some may just be read operations. Consider extending
FunctionAdapter
which has default values for some of the function attributes.
Even though this interface extends Serializable, functions will only be serialized if they are
not registered. For best performance it is recommended that you implement getId()
to
return a non-null identifier and register your function using
FunctionService.registerFunction(Function)
or the cache.xml function
element.
FunctionAdapter
,
FunctionService
Modifier and Type | Method and Description |
---|---|
void |
execute(FunctionContext context)
The method which contains the logic to be executed.
|
default java.lang.String |
getId()
Return a unique function identifier, used to register the function with
FunctionService |
default boolean |
hasResult()
Specifies whether the function sends results while executing.
|
default boolean |
isHA()
Specifies whether the function is eligible for re-execution (in case of failure).
|
default boolean |
optimizeForWrite()
Return true to indicate to GemFire the method requires optimization for writing the targeted
FunctionService.onRegion(org.apache.geode.cache.Region) and any associated
routing objects. |
default boolean hasResult()
If hasResult()
returns false, ResultCollector.getResult()
throws
FunctionException
.
If hasResult()
returns true, ResultCollector.getResult()
blocks and
waits for the result of function execution
void execute(FunctionContext context)
Execution
. The context
provided to this function is the one which was built using Execution. The contexts
can be data dependent or data-independent so user should check to see if the context provided
in parameter is instance of RegionFunctionContext
.context
- as created by Execution
default java.lang.String getId()
FunctionService
getId
in interface Identifiable<java.lang.String>
default boolean optimizeForWrite()
Return true to indicate to GemFire the method requires optimization for writing the targeted
FunctionService.onRegion(org.apache.geode.cache.Region)
and any associated
routing objects.
Returning false will optimize for read behavior on the targeted
FunctionService.onRegion(org.apache.geode.cache.Region)
and any associated
routing objects.
This method is only consulted when Region passed to FunctionService#onRegion(org.apache.geode.cache.Region) is a partitioned region
FunctionService
default boolean isHA()
FunctionContext.isPossibleDuplicate()