GemFire 5.8

com.gemstone.gemfire.cache.execute
Class FunctionService

java.lang.Object
  extended by com.gemstone.gemfire.cache.execute.FunctionService

public final class FunctionService
extends Object

Provides the entry point into execution of user defined Functions.

Function execution provides a means to route application behavior to data or more generically to peers in a DistributedSystem or servers in a Pool.

Since:
5.8LA

Method Summary
static Function getFunction(String functionId)
          Returns the Function defined by the functionId, returns null if no function is found for the specified functionId
static Map getRegisteredFunctions()
          Returns all locally registered functions
static Execution onMember(DistributedSystem system, DistributedMember distributedMember)
          Returns a Execution object that can be used to execute a data independent function on a DistributedMember of the DistributedSystem.
static Execution onMembers(DistributedSystem system)
          Returns a Execution object that can be used to execute a data independent function on all members of the DistributedSystem.
static Execution onMembers(DistributedSystem system, Set distributedMembers)
          Returns a Execution object that can be used to execute a data independent function on the set of DistributedMembers of the DistributedSystem.
static Execution onRegion(Region region)
          Returns a Execution object that can be used to execute a data dependent function on the specified Region.
static Execution onServer(Pool pool)
          Returns a Execution object that can be used to execute a data independent function on a server in the provided Pool.
static Execution onServers(Pool pool)
          Returns a Execution object that can be used to execute a data independent function on all the servers in the provided Pool.
static Function registerFunction(Function function)
          Registers the given Function with the FunctionService using Function.getId().
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

onRegion

public static Execution onRegion(Region region)
Returns a Execution object that can be used to execute a data dependent function on the specified Region.
When invoked from a GemFire client, the method returns an Execution instance that sends a message to one of the connected servers as specified by the Pool for the region. Depending on the filters setup on the Execution, the function is executed on all GemFire members that define the data region, or a subset of members. Execution.withFilter(Set)).

Parameters:
region -
Returns:
Execution
Throws:
NullPointerException - if the region passed in is null
Since:
5.8LA

onServer

public static Execution onServer(Pool pool)
Returns a Execution object that can be used to execute a data independent function on a server in the provided Pool.

If the server goes down while dispatching or executing the function, an Exception will be thrown.

Parameters:
pool - from which to chose a server for execution
Returns:
Execution
Throws:
NullPointerException - if Pool instance passed in is null
Since:
5.8LA

onServers

public static Execution onServers(Pool pool)
Returns a Execution object that can be used to execute a data independent function on all the servers in the provided Pool. If one of the servers goes down while dispatching or executing the function on the server, an Exception will be thrown.

Parameters:
pool - the set of servers to execute the function
Returns:
Execution
Throws:
NullPointerException - if Pool instance passed in is null
Since:
5.8LA

onMember

public static Execution onMember(DistributedSystem system,
                                 DistributedMember distributedMember)
Returns a Execution object that can be used to execute a data independent function on a DistributedMember of the DistributedSystem. If the member is not found in the system, the function execution will throw an Exception. If the member goes down while dispatching or executing the function on the member, an Exception will be thrown.

Parameters:
system - defines the distributed system
distributedMember - defines a member in the distributed system
Returns:
Execution
Throws:
NullPointerException - if either input parameter is null
Since:
5.8LA

onMembers

public static Execution onMembers(DistributedSystem system)
Returns a Execution object that can be used to execute a data independent function on all members of the DistributedSystem. If one of the members goes down while dispatching or executing the function on the member, an Exception will be thrown.

Parameters:
system - defines the distributed system
Returns:
Execution
Throws:
NullPointerException - if DistributedSystem instance passed is null
Since:
5.8LA

onMembers

public static Execution onMembers(DistributedSystem system,
                                  Set distributedMembers)
Returns a Execution object that can be used to execute a data independent function on the set of DistributedMembers of the DistributedSystem. If one of the members goes down while dispatching or executing the function, an Exception will be thrown.

Parameters:
system - defines the distributed system
distributedMembers - set of distributed members on which Function to be executed
Throws:
NullPointerException - if DistributedSystem instance passed is null
Since:
5.8LA

getFunction

public static Function getFunction(String functionId)
Returns the Function defined by the functionId, returns null if no function is found for the specified functionId

Parameters:
functionId -
Returns:
Function
Since:
5.8LA

registerFunction

public static Function registerFunction(Function function)
Registers the given Function with the FunctionService using Function.getId().

Registering a function allows execution of the function using Execution.execute(String). Every member that could execute a function using its Function.getId() should register the function.

Throws:
NullPointerException - if function instance passed is null or Function.getId() returns null
Since:
5.8LA

getRegisteredFunctions

public static Map getRegisteredFunctions()
Returns all locally registered functions

Returns:
a live read-only view of registered functions as a Map of Function.getId() to Function
Since:
5.8LA

GemFire 5.8

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