Class AsynchronousLoadBalancerPersistence
java.lang.Object
org.jppf.load.balancer.persistence.AsynchronousLoadBalancerPersistence
- All Implemented Interfaces:
LoadBalancerPersistence
An asynchronous wrapper for any other load-balancer persistence implementation. The methods of
LoadBalancerPersistence that do not return a result
(void return type) are non-blocking and return immediately. All other methods will block until they are executed and their result is available.
The execution of the interface's methods are delegated to a thread pool, whose size can be defined in the configuration or defaults to 1.
This asynchronous persistence can be configured in two forms:
# shorten the configuration value for clarity wrapper = org.jppf.load.balancer.persistence.AsynchronousLoadBalancerPersistence # asynchronous persistence with default thread pool size jppf.load.balancing.persistence = ${wrapper} <actual_persistence> <param1> ... <paramN> # asynchronous persistence with a specified thread pool size jppf.load.balancer.persistence = ${wrapper} <pool_size> <actual_persistence> <param1> ... <paramN>
Here is an example configuration for an asynchronous database persistence:
pkg = org.jppf.load.balancer.persistence # asynchronous database persistence with pool of 4 threads, # a table named 'JPPF_TEST' and datasource named 'loadBalancerDS' jppf.load.balancing.persistence = ${pkg}.AsynchronousLoadBalancerPersistence 4 \ ${pkg}.DatabaseLoadBalancerPersistence JPPF_TEST loadBalancerDS
- Since:
- 6.0
- Author:
- Laurent Cohen
-
Constructor Summary
ConstructorsConstructorDescriptionAsynchronousLoadBalancerPersistence(String... params) Initialize this persistence with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidDelete the specified load-balancer state(s) from the persistence store.intGet the number of persistence operations, including load, store, delete and list, that have started but not yet completed.List all entries in the persistence store.Load the state of a load balancer from the persistence sstore.voidStore a load balancer to the persistence sstore.toString()
-
Constructor Details
-
AsynchronousLoadBalancerPersistence
public AsynchronousLoadBalancerPersistence(String... params) throws LoadBalancerPersistenceException Initialize this persistence with the specified parameters.- Parameters:
params- if the first parameter is a number, then it represents the number of threads that perform the asynchronous processing, and the remaining parameters represent the wrapped persistence implementation. Otherwise it represents the wrapped persistence and the remaining parameters are those of the wrapped persistence.- Throws:
LoadBalancerPersistenceException- if any error occurs.
-
-
Method Details
-
load
Description copied from interface:LoadBalancerPersistenceLoad the state of a load balancer from the persistence sstore.- Specified by:
loadin interfaceLoadBalancerPersistence- Parameters:
info- aLoadBalancerPersistenceInfoobject representing the load balancer and its state.- Returns:
- an object representing the load balancer state, or
nullif no entry exists in the persistence store for the specified node identifier. - Throws:
LoadBalancerPersistenceException- if any erorr occurs during the persistence operation.
-
store
Description copied from interface:LoadBalancerPersistenceStore a load balancer to the persistence sstore.- Specified by:
storein interfaceLoadBalancerPersistence- Parameters:
info- aLoadBalancerPersistenceInfoobject representing the load balancer and its state.- Throws:
LoadBalancerPersistenceException- if any erorr occurs during the persistence operation.
-
delete
Description copied from interface:LoadBalancerPersistenceDelete the specified load-balancer state(s) from the persistence store.The
infoparameter embeds both the scope and identifiers for the artifacts to delete:- if
infoisnullor bothinfo.getChannelID()andinfo.getAlgorithmID()arenull, then all entries in the persistence store are deleted - if only
info.getAlgorithmID()isnull, then the states of all algorithm for the specified channel are deleted - if only
info.getChannelID()isnull, then the states of the specified algorithm are deleted for all the channels - if neither
info.getChannelID()norinfo.getAlgorithmID()arenull, then only the state of the specified algorithm for the specified channel is deleted
- Specified by:
deletein interfaceLoadBalancerPersistence- Parameters:
info- encapsulates information about the artifacts to delete.- Throws:
LoadBalancerPersistenceException- if any erorr occurs during the persistence operation.
- if
-
list
Description copied from interface:LoadBalancerPersistenceList all entries in the persistence store.The
infoparameter embeds both the scope and identifiers for the artifacts to list:- if
infoisnullor bothinfo.getChannelID()andinfo.getAlgorithmID()arenull, then all channelIDs in the persistence store are returned - if only
info.getAlgorithmID()isnull, then all the algorithm IDs for the specified channel are returned - if only
info.getChannelID()isnull, then the the IDs of the channels that have a persisted state for the algorithm are returned - if neither
info.getChannelID()norinfo.getAlgorithmID()arenull, then the specified algorithmID is returned (list with a single entry) if the specified channel has an entry for it, otherwise an empty list must be returned
- Specified by:
listin interfaceLoadBalancerPersistence- Parameters:
info- encapsulates information about the artifacts to delete.- Returns:
- a list of nodeIDs or algorithmIDs, depending on the input parameter.
- Throws:
LoadBalancerPersistenceException- if any erorr occurs during the persistence operation.
- if
-
toString
-
getUncompletedOperations
public int getUncompletedOperations()Description copied from interface:LoadBalancerPersistenceGet the number of persistence operations, including load, store, delete and list, that have started but not yet completed.- Specified by:
getUncompletedOperationsin interfaceLoadBalancerPersistence- Returns:
- the number of uncompleted operations.
-