GemFire 6.5

com.gemstone.gemfire.cache.execute
Class FunctionAdapter

java.lang.Object
  extended by com.gemstone.gemfire.cache.execute.FunctionAdapter
All Implemented Interfaces:
Function, Serializable

public abstract class FunctionAdapter
extends Object
implements Function

Application developers can extend this class instead of implementing the Function interface.

This implementation provides the following defaults

  1. Function.hasResult() returns true
  2. Function.optimizeForWrite() returns false
  3. Function.isHA() returns true

Since:
6.0
See Also:
Function, Serialized Form

Constructor Summary
FunctionAdapter()
           
 
Method Summary
abstract  void execute(FunctionContext context)
          The method which contains the logic to be executed.
abstract  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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionAdapter

public FunctionAdapter()
Method Detail

execute

public abstract void execute(FunctionContext context)
Description copied from interface: Function
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.

Specified by:
execute in interface Function
Parameters:
context - as created by Execution

getId

public abstract String getId()
Description copied from interface: Function
Return a unique function identifier, used to register the function with FunctionService

Specified by:
getId in interface Function
Returns:
string identifying this function

hasResult

public boolean hasResult()
Description copied from interface: Function
Specifies whether the function sends results while executing. The method returns false if no result is expected.

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

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

Specified by:
hasResult in interface Function
Returns:
whether this function returns a Result back to the caller.

optimizeForWrite

public boolean optimizeForWrite()
Description copied from interface: Function

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 invoked as a data dependent function

Specified by:
optimizeForWrite in interface Function
Returns:
false if the function is read only, otherwise returns true
See Also:
FunctionService

isHA

public boolean isHA()
Description copied from interface: Function
Specifies whether the function is eligible for re-execution (in case of failure).

Specified by:
isHA in interface Function
Returns:
whether the function is eligible for re-execution.
See Also:
RegionFunctionContext.isPossibleDuplicate()

GemFire 6.5

Copyright © 2002-2010 GemStone Systems, Inc. All Rights Reserved.