Class LoadBalancerPersistenceInfo

java.lang.Object
org.jppf.load.balancer.persistence.LoadBalancerPersistenceInfo

public class LoadBalancerPersistenceInfo extends Object
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 Details

    • LoadBalancerPersistenceInfo

      public LoadBalancerPersistenceInfo(String channelID, String algorithmID, Object state)
      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 of channelString).
      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 of channelString).
      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

      public String 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

      public String getChannelID()
      Get the channel identifier, wich is a hash of the string returned by getChannelString().
      Returns:
      the unique identifier for the channel.
    • getAlgorithm

      public String 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

      public String getAlgorithmID()
      Get a hash of the load-balancing algorithm name (obtained via getAlgorithm()).
      Returns:
      algorithm a hash of the load balancing algorithm name.
    • getState

      public Object getState()
      Get the load-balancer state.
      Returns:
      the state of the load-balancer.
    • getStateLock

      public Lock getStateLock()
      Get the lock used to synchronize access to the load-balancer state.
      Returns:
      a Lock object.
    • getStateAsBytes

      public byte[] getStateAsBytes() throws Exception
      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 calling getStateLock().
      Returns:
      the serialized state of the load-balancer as an array of bytes.
      Throws:
      Exception - if any error occurs.
    • serializeToStream

      public void serializeToStream(OutputStream stream) throws Exception
      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 calling getStateLock().
      Parameters:
      stream - the stream to serialize into.
      Throws:
      Exception - if any error occurs.
    • toString

      public String toString()
      Overrides:
      toString in class Object