Class LoadBalancerPersistenceInfo
java.lang.Object
org.jppf.load.balancer.persistence.LoadBalancerPersistenceInfo
Instances of this class represent the persisted information for a load-balancer.
The channel identifier represents a unique and reusable idenfier for a remote node if running within a driver, or for a remote driver if running within a client.
- Since:
- 6.0
- Author:
- Laurent Cohen
-
Constructor Summary
ConstructorsConstructorDescriptionLoadBalancerPersistenceInfo(String channelID, String algorithmID, Object state) Initialize this persistence information.LoadBalancerPersistenceInfo(String channelString, String channelID, String algorithm, String algorithmID, Object state) Initialize this persistence information.LoadBalancerPersistenceInfo(String channelString, String channelID, String algorithm, String algorithmID, Object state, Lock lock) Initialize this persistence information. -
Method Summary
Modifier and TypeMethodDescriptionGet the name of the related load-balancing algorithm.Get a hash of the load-balancing algorithm name (obtained viagetAlgorithm()).Get the channel identifier, wich is a hash of the string returned bygetChannelString().Get a unique identifier for the channel, reusable over restarts of the remote process (driver or node).getState()Get the load-balancer state.byte[]Get the serialized state of the load-balancer as an array of bytes.Get the lock used to synchronize access to the load-balancer state.voidserializeToStream(OutputStream stream) COnvenience method to serialize the load-balancer state into the specified output stream.toString()
-
Constructor Details
-
LoadBalancerPersistenceInfo
Initialize this persistence information.- Parameters:
channelID- the unique identifier for the related node or driver.algorithmID- the load balancing algorithm name.state- the state of the load-balancer.
-
LoadBalancerPersistenceInfo
public LoadBalancerPersistenceInfo(String channelString, String channelID, String algorithm, String algorithmID, Object state) Initialize this persistence information.- Parameters:
channelString- the unique identifier for the related channel in readable text.channelID- the unique identifier for the related channel (hash ofchannelString).algorithm- the load balancing algorithm name.algorithmID- a hash of the load balancing algorithm name.state- the state of the load-balancer.
-
LoadBalancerPersistenceInfo
public LoadBalancerPersistenceInfo(String channelString, String channelID, String algorithm, String algorithmID, Object state, Lock lock) Initialize this persistence information.- Parameters:
channelString- the unique identifier for the related channel in readable text.channelID- the unique identifier for the related channel (hash ofchannelString).algorithm- the load balancing algorithm name.algorithmID- a hash of the load balancing algorithm name.state- the state of the load-balancer.lock- lock used to synchronize access to the load-balancer state.
-
-
Method Details
-
getChannelString
Get a unique identifier for the channel, reusable over restarts of the remote process (driver or node).
This method is provided for debugging and logging purposes only, as the returned string is not used by the persistence mechanism.- Returns:
- a strign that uniquely identifies the channel.
-
getChannelID
Get the channel identifier, wich is a hash of the string returned bygetChannelString().- Returns:
- the unique identifier for the channel.
-
getAlgorithm
Get the name of the related load-balancing algorithm.
This method is provided for debugging and logging purposes only, as the returned string is not used by the persistence mechanism.- Returns:
- the load balancing algorithm name in clear.
-
getAlgorithmID
Get a hash of the load-balancing algorithm name (obtained viagetAlgorithm()).- Returns:
- algorithm a hash of the load balancing algorithm name.
-
getState
Get the load-balancer state.- Returns:
- the state of the load-balancer.
-
getStateLock
Get the lock used to synchronize access to the load-balancer state.- Returns:
- a
Lockobject.
-
getStateAsBytes
Get the serialized state of the load-balancer as an array of bytes. This method synchronizes internally on the state object using the lock obtained by callinggetStateLock().- Returns:
- the serialized state of the load-balancer as an array of bytes.
- Throws:
Exception- if any error occurs.
-
serializeToStream
COnvenience method to serialize the load-balancer state into the specified output stream. This method synchronizes internally on the state object using the lock obtained by callinggetStateLock().- Parameters:
stream- the stream to serialize into.- Throws:
Exception- if any error occurs.
-
toString
-