Class JPPFBundlerFactory

java.lang.Object
org.jppf.load.balancer.spi.JPPFBundlerFactory

public class JPPFBundlerFactory extends Object
Factory class for JPPF load-balancing algorithms defined through the JPPFBundlerProvider service provider interface.
Author:
Laurent Cohen
  • Constructor Details

    • JPPFBundlerFactory

      public JPPFBundlerFactory(TypedProperties config)
      Default constructor.
      Parameters:
      config - the configuration used to extract the load-balancer settings.
    • JPPFBundlerFactory

      public JPPFBundlerFactory(JPPFBundlerFactory.Defaults def, TypedProperties config)
      Default constructor.
      Parameters:
      def - the default values to use if nothing is specified in the JPPF configuration.
      config - the configuration used to extract the load-balancer settings.
  • Method Details

    • newBundler

      public Bundler<?> newBundler()
      Create an instance of the bundler with the specified name and parameters.
      Returns:
      a new Bundler instance.
    • updateCurrentConfiguration

      public LoadBalancingInformation updateCurrentConfiguration()
      Update the current load-balancer settings from the JPF configuration.
      Returns:
      the created LoadBalancingInformation instance.
    • getBundlerProvider

      public <T extends LoadBalancingProfile> JPPFBundlerProvider<T> getBundlerProvider(String name)
      Get the bundler provider with the specified name.
      This method will trigger a lazy loading of the providers if they haven't been loaded yet.
      Type Parameters:
      T - the type of profile used by the bundlers the returned provider creates.
      Parameters:
      name - the name of the bundler provider to retrieve.
      Returns:
      a JPPFBundlerProvider instance or null if the provider could not be found.
    • getBundlerProviderNames

      public List<String> getBundlerProviderNames()
      Get the names of all discovered bundler providers.
      Returns:
      an unmodifiable list of provider names.
    • getAlgorithmHash

      public String getAlgorithmHash(String name)
      Get the hashed identifier for the specified algorithm.
      Parameters:
      name - the name of the algorithm for which to get an identifier.
      Returns:
      a hash of the algorithm name.
    • getAlgorithmNameFromHash

      public String getAlgorithmNameFromHash(String hash)
      Get the name of an algorithm given its hash.
      Parameters:
      hash - the hash of the algorithm name.
      Returns:
      a the name of the algorithm.
    • convertJPPFConfiguration

      public TypedProperties convertJPPFConfiguration(String profileName, TypedProperties configuration)
      Convert a JPPF configuration map to a profile configuration by extracting the properties related to the specified profile and removing the JPPF-specific prefix from their name.
      Parameters:
      profileName - the name of the profile to extract.
      configuration - the JPPF configuration to extract from.
      Returns:
      a TypedProperties instance containing only the profile-specific parameters.
    • getCurrentInfo

      public LoadBalancingInformation getCurrentInfo()
      Get the current load-balancing configuration.
      Returns:
      a LoadBalancingInformation instance.
    • setAndGetCurrentInfo

      public LoadBalancingInformation setAndGetCurrentInfo(LoadBalancingInformation currentInfo)
      Set the current load-balancing configuration.
      Parameters:
      currentInfo - a LoadBalancingInformation instance.
      Returns:
      the updated LoadBalancingInformation instance.
    • getLastUpdateTime

      public long getLastUpdateTime()
      Get the last update time.
      Returns:
      the last update time as a long value.
    • getFallbackBundler

      public Bundler<?> getFallbackBundler()
      Get the fallback bundler.
      Returns:
      a Bundler instance.
    • getPersistence

      public LoadBalancerPersistence getPersistence()
      Returns:
      the configured persistence, or null if none is configured or the initialization failed.
    • getHashAlgorithm

      public String getHashAlgorithm()
      Returns:
      the hash function used to generate bundle state identifiers.