Class FileLoadBalancerPersistence
java.lang.Object
org.jppf.persistence.AbstractFilePersistence<LoadBalancerPersistenceInfo,LoadBalancerPersistenceException>
org.jppf.load.balancer.persistence.FileLoadBalancerPersistence
- All Implemented Interfaces:
LoadBalancerPersistence
public class FileLoadBalancerPersistence
extends AbstractFilePersistence<LoadBalancerPersistenceInfo,LoadBalancerPersistenceException>
implements LoadBalancerPersistence
File-based persistence implementation for the state of the JPPF load-balancers.
It relies on a directory structure is as follows:
persistence_root |_channel_identifier1 | |_algorithm1.data | |_... | |_algorithmP1.data |_... |_channel_identifiern |_algorithm1.data |_... |_algorithmPn.data
Where:
- Each
channel_identifierirepresents a hash of a string concatenated from various properties of the channel. A channel represents a connection between a node and a driver for server-side load-balancing, or between a driver and a client for client-side load-balancing. This id is unique for each channel and resilient over restarts of both related peers, contrary to their uuids, which are recreated each time a component starts. Using a hash also ensures that it can be used a s a valid folder name in a file system - Each
algorithmiprefix is the hash of the related load-balancing algorithm name. Again, it ensures it can be used to form a valid file name - Each
algorithmi.data file represents the serialized state of the related load-balancer
- Since:
- 6.0
- Author:
- Laurent Cohen
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jppf.persistence.AbstractFilePersistence
AbstractFilePersistence.DirectoryFilter -
Field Summary
FieldsFields inherited from class org.jppf.persistence.AbstractFilePersistence
DEFAULT_EXTENSION, rootPath, TEMP_EXTENSION -
Constructor Summary
ConstructorsConstructorDescriptionInitialize this persistence with the root pathDEFAULT_ROOTunder the current user directory.FileLoadBalancerPersistence(String... paths) Initialize this persistence with the specified path as root directory. -
Method Summary
Modifier and TypeMethodDescriptionprotected LoadBalancerPersistenceExceptionCreate the appropriate type of exception.voidDelete 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.Methods inherited from class org.jppf.persistence.AbstractFilePersistence
checkDirectory, deleteIfEmpty, getSubDir, isSameFile, pathname, toString
-
Field Details
-
DEFAULT_ROOT
The default root path if none is specified.- See Also:
-
-
Constructor Details
-
FileLoadBalancerPersistence
public FileLoadBalancerPersistence()Initialize this persistence with the root pathDEFAULT_ROOTunder the current user directory. -
FileLoadBalancerPersistence
Initialize this persistence with the specified path as root directory.- Parameters:
paths- the root directory for this persistence.
-
-
Method Details
-
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.
-
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.
-
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
-
convertException
Description copied from class:AbstractFilePersistenceCreate the appropriate type of exception.- Specified by:
convertExceptionin classAbstractFilePersistence<LoadBalancerPersistenceInfo,LoadBalancerPersistenceException> - Parameters:
e- the actual exception from which to create the new one.- Returns:
- an exception of type E.
-
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.
-