GemFire 5.8

Package com.gemstone.gemfire.cache.execute

The com.gemstone.gemfire.cache.execute package provides APIs used for function execution on gemfire system members.

See:
          Description

Interface Summary
Execution Provides methods to build the context for the execution of a Function.
Function Defines the interface a user defined function implements.
FunctionContext Defines the execution context of a Function.
RegionFunctionContext Defines the execution context of a data dependent Function.
ResultCollector Defines the interface for a container that gathers results from function execution.
 

Class Summary
FunctionAdapter Application developers can extend this class instead of implementing the Function interface.
FunctionService Provides the entry point into execution of user defined Functions.
 

Exception Summary
FunctionException Thrown to indicate incorrect execution of Functions in GemFire.
 

Package com.gemstone.gemfire.cache.execute Description

The com.gemstone.gemfire.cache.execute package provides APIs used for function execution on gemfire system members.

GemFire's Function Execution Service supports execution of user-defined methods on targeted GemFire system members.
The fundamental premise is to route the function transparently to the GemFire system member that hosts the data subset required by the application function and avoid moving data around on the network. Application function can be executed on just one fabric node, executed in parallel on a subset of nodes or in parallel across all the nodes.

The Function Execution Service API is based on the following classes and interfaces which work together to provide the function execution capability. The API allows execution of functions that are "data dependent" or "data independent". Data dependent functions are functions that need access to the local data set, on the targeted member.

Example of a "data dependent" exection using the Function Execution Service

    Region region;
    Set keySet = Collections.singleton("myKey");
    Function multiGetFunction;
    Serializable args;
    ResultCollector rc = FunctionService.onRegion(region)
                                        .withArgs(args)
                                        .withFilter(keySet)
                                        .withCollector(new MyCustomResultCollector())
                                        .execute(multiGetFunction.getId());
    //Application can do something else here before retrieving the result
    Serializable functionResult = rc.getResult();

Example of a "data independent" exection using the Function Execution Service

    DistributedSystem ds;
    Function memberSetupFunction;
    Serializable args;
    ResultCollector rc = FunctionService.onMembers(ds)
                                        .withArgs(args)
                                        .execute(memberSetupFunction.getId());
    //Application can do something else here before retrieving the result
    Serializable functionResult = rc.getResult();

Some scenarios where function execution can be useful:

  1. Any arbitrary aggregation operation that requires iteration over local data sets done more efficiently through a single call to the cache server
  2. Application wants to execute a server side behavior.
  3. Application wants to initialize some of its components once on each server which might be used later by executed functions, for example initialization of a 3rd party service.


GemFire 5.8

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