VMware GemFire Java API Reference
Class FunctionService
- java.lang.Object
- 
- org.apache.geode.cache.execute.FunctionService
 
- 
 public class FunctionService extends java.lang.ObjectProvides the entry point into execution of user defined Functions.Function execution provides a means to route application behaviour to data or more generically to peers in a DistributedSystemor servers in aPool.- Since:
- GemFire 6.0
 
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedFunctionService(org.apache.geode.internal.cache.execute.FunctionExecutionService functionExecutionService)
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static FunctiongetFunction(java.lang.String functionId)Returns theFunctiondefined by the functionId, returns null if no function is found for the specified functionIdstatic java.util.Map<java.lang.String,Function>getRegisteredFunctions()Returns all locally registered functionsstatic booleanisRegistered(java.lang.String functionId)Returns true if the function is registered to FunctionServicestatic ExecutiononMember(java.lang.String... groups)Returns anExecutionobject that can be used to execute a data independent function on one member of each group provided.static ExecutiononMember(DistributedMember distributedMember)Returns anExecutionobject that can be used to execute a data independent function on aDistributedMember.static ExecutiononMembers(java.lang.String... groups)Returns anExecutionobject that can be used to execute a data independent function on all peer members.static ExecutiononMembers(java.util.Set<DistributedMember> distributedMembers)Returns anExecutionobject that can be used to execute a data independent function on the set ofDistributedMembers.static ExecutiononRegion(Region region)static ExecutiononServer(Pool pool)static ExecutiononServer(RegionService regionService)Returns anExecutionobject that can be used to execute a data independent function on a server that the given cache is connected to.static ExecutiononServers(Pool pool)static ExecutiononServers(RegionService regionService)Returns anExecutionobject that can be used to execute a data independent function on all the servers that the given cache is connected to.static voidregisterFunction(Function function)static voidunregisterFunction(java.lang.String functionId)
 
- 
- 
- 
Method Detail- 
onRegionpublic static Execution onRegion(Region region) Returns anExecutionobject 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 thePoolfor the region.
 Depending on the filters setup on theExecution, 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
 . For DistributedRegions with DataPolicy.REPLICATE, execute the function locally. For Regions with DataPolicy.PARTITION, it executes on members where the data resides as specified by the filter.- Parameters:
- region- the- Regionon which the returned- Executionwill execute functions
- Returns:
- an Executionobject that can be used to execute a data dependent function on the specifiedRegion
- Throws:
- FunctionException- if the region passed in is null
- Since:
- GemFire 6.0
 
 - 
onServerpublic static Execution onServer(Pool pool) Returns anExecutionobject that can be used to execute a data independent function on a server in the providedPool.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:
- an Executionobject that can be used to execute a data independent function on a server in the providedPool
- Throws:
- FunctionException- if Pool instance passed in is null
- Since:
- GemFire 6.0
 
 - 
onServerspublic static Execution onServers(Pool pool) Returns anExecutionobject that can be used to execute a data independent function on all the servers in the providedPool. 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:
- an Executionobject that can be used to execute a data independent function on all the servers in the providedPool
- Throws:
- FunctionException- if Pool instance passed in is null
- Since:
- GemFire 6.0
 
 - 
onServerpublic static Execution onServer(RegionService regionService) Returns anExecutionobject 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. - Parameters:
- regionService- obtained from- ClientCacheFactory.create()or- ClientCache.createAuthenticatedView(Properties).
- Returns:
- an Executionobject that can be used to execute a data independent function on a server that the given cache is connected to
- Throws:
- FunctionException- if cache is null, is not on a client, or it does not have a default pool
- Since:
- GemFire 6.5
 
 - 
onServerspublic static Execution onServers(RegionService regionService) Returns anExecutionobject 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.- Parameters:
- regionService- obtained from- ClientCacheFactory.create()or- ClientCache.createAuthenticatedView(Properties).
- Returns:
- an Executionobject that can be used to execute a data independent function on all the servers that the given cache is connected to
- Throws:
- FunctionException- if cache is null, is not on a client, or it does not have a default pool
- Since:
- GemFire 6.5
 
 - 
onMemberpublic static Execution onMember(DistributedMember distributedMember) Returns anExecutionobject that can be used to execute a data independent function on aDistributedMember. 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.- Parameters:
- distributedMember- defines a member in the distributed system
- Returns:
- an Executionobject that can be used to execute a data independent function on aDistributedMember
- Throws:
- FunctionException- if distributedMember is null
- Since:
- GemFire 7.0
 
 - 
onMemberspublic static Execution onMembers(java.lang.String... groups) Returns anExecutionobject 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. - Parameters:
- 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 group
- Returns:
- an Executionobject that can be used to execute a data independent function on all peer members
- Throws:
- FunctionException- if no members are found belonging to the provided groups
- Since:
- GemFire 7.0
 
 - 
onMemberspublic static Execution onMembers(java.util.Set<DistributedMember> distributedMembers) Returns anExecutionobject that can be used to execute a data independent function on the set ofDistributedMembers. If one of the members goes down while dispatching or executing the function, an Exception will be thrown.- Parameters:
- distributedMembers- set of distributed members on which- Functionto be executed
- Returns:
- an Executionobject that can be used to execute a data independent function on the set ofDistributedMembers provided
- Throws:
- FunctionException- if distributedMembers is null
- Since:
- GemFire 7.0
 
 - 
onMemberpublic static Execution onMember(java.lang.String... groups) Returns anExecutionobject that can be used to execute a data independent function on one member of each group provided.- Parameters:
- groups- list of GemFire configuration property "groups" (see- groups) on which to execute the function. Function will be executed on one member of each group
- Returns:
- an Executionobject that can be used to execute a data independent function on one member of each group provided
- Throws:
- FunctionException- if no members are found belonging to the provided groups
- Since:
- GemFire 7.0
 
 - 
getFunctionpublic static Function getFunction(java.lang.String functionId) Returns theFunctiondefined by the functionId, returns null if no function is found for the specified functionId- Parameters:
- functionId- a functionId
- Returns:
- the Functiondefined by the functionId or null if no function is found for the specified functionId
- Throws:
- FunctionException- if functionID passed is null
- Since:
- GemFire 6.0
 
 - 
registerFunctionpublic static void registerFunction(Function function) Registers the givenFunctionwith theFunctionServiceusingFunction.getId().Registering a function allows execution of the function using Execution.execute(String). Every member that could execute a function using itsFunction.getId()should register the function.- Parameters:
- function- the- Functionto register
- Throws:
- FunctionException- if function instance passed is null or Function.getId() returns null
- Since:
- GemFire 6.0
 
 - 
unregisterFunctionpublic static void unregisterFunction(java.lang.String functionId) - Parameters:
- functionId- the ID of the function
- Throws:
- FunctionException- if function instance passed is null or Function.getId() returns null
- Since:
- GemFire 6.0
 
 - 
isRegisteredpublic static boolean isRegistered(java.lang.String functionId) Returns true if the function is registered to FunctionService- Parameters:
- functionId- the ID of the function
- Returns:
- whether the function is registered to FunctionService
- Throws:
- FunctionException- if function instance passed is null or Function.getId() returns null
- Since:
- GemFire 6.0
 
 - 
getRegisteredFunctionspublic static java.util.Map<java.lang.String,Function> getRegisteredFunctions() Returns all locally registered functions- Returns:
- A view of registered functions as a Map of Function.getId()toFunction
- Since:
- GemFire 6.0
 
 
- 
 
- 
