GemFire 6.6.1

com.gemstone.gemfire.cache.execute
Interface Function

All Superinterfaces:
Serializable
All Known Implementing Classes:
FunctionAdapter

public interface Function
extends Serializable

Defines the interface a user defined function implements. Functions 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.

Since:
6.0
See Also:
FunctionAdapter, FunctionService

Method Summary
 void execute(FunctionContext context)
          The method which contains the logic to be executed.
 String getId()
          Return a unique function identifier, used to register the function with FunctionService
 boolean hasResult()
          Specifies whether the function sends results while executing.
 boolean isHA()
          Specifies whether the function is eligible for re-execution (in case of failure).
 boolean optimizeForWrite()
          Return true to indicate to GemFire the method requires optimization for writing the targeted FunctionService.onRegion(com.gemstone.gemfire.cache.Region) and any associated routing objects.
 

Method Detail

hasResult

boolean hasResult()
Specifies whether the function sends results while executing. The method returns false if no result is expected.

If hasResult() returns false, ResultCollector.getResult() throws FunctionException.

If hasResult() returns true, ResultCollector.getResult() blocks and waits for the result of function execution

Returns:
whether this function returns a Result back to the caller.
Since:
6.0

execute

void execute(FunctionContext context)
The method which contains the logic to be executed. This method should be thread safe and may be invoked more than once on a given member for a single 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.

Parameters:
context - as created by Execution
Since:
6.0

getId

String getId()
Return a unique function identifier, used to register the function with FunctionService

Returns:
string identifying this function
Since:
6.0

optimizeForWrite

boolean optimizeForWrite()

Return true to indicate to GemFire the method requires optimization for writing the targeted FunctionService.onRegion(com.gemstone.gemfire.cache.Region) and any associated routing objects.

Returning false will optimize for read behavior on the targeted FunctionService.onRegion(com.gemstone.gemfire.cache.Region) and any associated routing objects.

This method is only consulted when Region passed to FunctionService#onRegion(com.gemstone.gemfire.cache.Region) is a partitioned region

Returns:
false if the function is read only, otherwise returns true
Since:
6.0
See Also:
FunctionService

isHA

boolean isHA()
Specifies whether the function is eligible for re-execution (in case of failure).

Returns:
whether the function is eligible for re-execution.
Since:
6.5
See Also:
FunctionContext.isPossibleDuplicate()

GemFire 6.6.1

Copyright © 1997-2011 VMware, Inc. All rights reserved.