public class FunctionService extends Object
Function execution provides a means to route application behaviour to data or
more generically to peers in a DistributedSystem
or servers in a Pool
.
Modifier | Constructor and Description |
---|---|
protected |
FunctionService(org.apache.geode.internal.cache.execute.FunctionExecutionService functionExecutionService) |
Modifier and Type | Method and Description |
---|---|
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<String,Function> |
getRegisteredFunctions()
Returns all locally registered functions
|
static boolean |
isRegistered(String functionId)
Returns true if the function is registered to FunctionService
|
static Execution |
onMember(DistributedMember distributedMember)
Returns an
Execution object that can be used to execute a data independent function on
a DistributedMember . |
static Execution |
onMember(String... groups)
Returns an
Execution object that can be used to execute a data independent function on
one member of each group provided. |
static Execution |
onMembers(Set<DistributedMember> distributedMembers)
Returns an
Execution object that can be used to execute a data independent function on
the set of DistributedMember s. |
static Execution |
onMembers(String... groups)
Returns an
Execution object that can be used to execute a data independent function on
all peer members. |
static Execution |
onRegion(Region region)
|
static Execution |
onServer(Pool pool)
|
static Execution |
onServer(RegionService regionService)
Returns an
Execution object that can be used to execute a data independent function on
a server that the given cache is connected to. |
static Execution |
onServers(Pool pool)
|
static Execution |
onServers(RegionService regionService)
Returns an
Execution object that can be used to execute a data independent function on
all the servers that the given cache is connected to. |
static void |
registerFunction(Function function)
|
static void |
unregisterFunction(String functionId)
|
protected FunctionService(org.apache.geode.internal.cache.execute.FunctionExecutionService functionExecutionService)
public static Execution onRegion(Region region)
Execution
object that can be used to execute a data dependent function on
the specified Region.Pool
for the region. Execution
, the function is executed on all
GemFire members that define the data region, or a subset of members.
Execution.withFilter(Set)
).
For DistributedRegions with DataPolicy.NORMAL, it throws UnsupportedOperationException. For
DistributedRegions with DataPolicy.EMPTY, execute the function on any random member which has
DataPolicy.REPLICATE region
- the Region
on which the returned Execution
will execute functionsExecution
object that can be used to execute a data dependent function on
the specified Region
FunctionException
- if the region passed in is nullpublic static Execution onServer(Pool pool)
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.
pool
- from which to chose a server for executionExecution
object that can be used to execute a data independent function on
a server in the provided Pool
FunctionException
- if Pool instance passed in is nullpublic static Execution onServers(Pool pool)
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.pool
- the set of servers to execute the functionExecution
object that can be used to execute a data independent function on
all the servers in the provided Pool
FunctionException
- if Pool instance passed in is nullpublic static Execution onServer(RegionService regionService)
Execution
object that can be used to execute a data independent function on
a server that the given cache is connected to.
If the server goes down while dispatching or executing the function, an Exception will be thrown.
regionService
- obtained from ClientCacheFactory.create()
or
ClientCache.createAuthenticatedView(Properties)
.Execution
object that can be used to execute a data independent function on
a server that the given cache is connected toFunctionException
- if cache is null, is not on a client, or it does not have a default
poolpublic static Execution onServers(RegionService regionService)
Execution
object that can be used to execute a data independent function on
all the servers that the given cache is connected to. If one of the servers goes down while
dispatching or executing the function on the server, an Exception will be thrown.regionService
- obtained from ClientCacheFactory.create()
or
ClientCache.createAuthenticatedView(Properties)
.Execution
object that can be used to execute a data independent function on
all the servers that the given cache is connected toFunctionException
- if cache is null, is not on a client, or it does not have a default
poolpublic static Execution onMember(DistributedMember distributedMember)
Execution
object that can be used to execute a data independent function on
a DistributedMember
. If the member is not found, executing the function will throw an
Exception. If the member goes down while dispatching or executing the function on the member,
an Exception will be thrown.distributedMember
- defines a member in the distributed systemExecution
object that can be used to execute a data independent function on
a DistributedMember
FunctionException
- if distributedMember is nullpublic static Execution onMembers(String... groups)
Execution
object that can be used to execute a data independent function on
all peer members. If the optional groups parameter is provided, function is executed on all
members that belong to the provided groups.
If one of the members goes down while dispatching or executing the function on the member, an Exception will be thrown.
groups
- optional list of GemFire configuration property "groups" (see
groups
) on
which to execute the function. Function will be executed on all members of each groupExecution
object that can be used to execute a data independent function on
all peer membersFunctionException
- if no members are found belonging to the provided groupspublic static Execution onMembers(Set<DistributedMember> distributedMembers)
Execution
object that can be used to execute a data independent function on
the set of DistributedMember
s. If one of the members goes down while dispatching or
executing the function, an Exception will be thrown.distributedMembers
- set of distributed members on which Function
to be executedExecution
object that can be used to execute a data independent function on
the set of DistributedMember
s providedFunctionException
- if distributedMembers is nullpublic static Execution onMember(String... groups)
Execution
object that can be used to execute a data independent function on
one member of each group provided.groups
- list of GemFire configuration property "groups" (see
groups
) on
which to execute the function. Function will be executed on one member of each groupExecution
object that can be used to execute a data independent function on
one member of each group providedFunctionException
- if no members are found belonging to the provided groupspublic static Function getFunction(String functionId)
Function
defined by the functionId, returns null if no function is found
for the specified functionIdfunctionId
- a functionIdFunction
defined by the functionId or null if no function is found for the
specified functionIdFunctionException
- if functionID passed is nullpublic static void registerFunction(Function function)
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.
function
- the Function
to registerFunctionException
- if function instance passed is null or Function.getId() returns nullpublic static void unregisterFunction(String functionId)
functionId
- the ID of the functionFunctionException
- if function instance passed is null or Function.getId() returns nullpublic static boolean isRegistered(String functionId)
functionId
- the ID of the functionFunctionException
- if function instance passed is null or Function.getId() returns nullpublic static Map<String,Function> getRegisteredFunctions()
Function.getId()
to Function