Package org.jppf.load.balancer.spi
Class JPPFBundlerFactory
java.lang.Object
org.jppf.load.balancer.spi.JPPFBundlerFactory
Factory class for JPPF load-balancing algorithms defined through the
JPPFBundlerProvider
service provider interface.- Author:
- Laurent Cohen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThis enum defines the available default load balancing configurations. -
Constructor Summary
ConstructorsConstructorDescriptionJPPFBundlerFactory(JPPFBundlerFactory.Defaults def, TypedProperties config) Default constructor.JPPFBundlerFactory(TypedProperties config) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionconvertJPPFConfiguration(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.getAlgorithmHash(String name) Get the hashed identifier for the specified algorithm.Get the name of an algorithm given its hash.<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.Get the names of all discovered bundler providers.Get the current load-balancing configuration.Bundler<?>Get the fallback bundler.longGet the last update time.Bundler<?>Create an instance of the bundler with the specified name and parameters.setAndGetCurrentInfo(LoadBalancingInformation currentInfo) Set the current load-balancing configuration.Update the current load-balancer settings from the JPF configuration.
-
Constructor Details
-
JPPFBundlerFactory
Default constructor.- Parameters:
config- the configuration used to extract the load-balancer settings.
-
JPPFBundlerFactory
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
Create an instance of the bundler with the specified name and parameters.- Returns:
- a new
Bundlerinstance.
-
updateCurrentConfiguration
Update the current load-balancer settings from the JPF configuration.- Returns:
- the created
LoadBalancingInformationinstance.
-
getBundlerProvider
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
JPPFBundlerProviderinstance or null if the provider could not be found.
-
getBundlerProviderNames
Get the names of all discovered bundler providers.- Returns:
- an unmodifiable list of provider names.
-
getAlgorithmHash
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
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
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
TypedPropertiesinstance containing only the profile-specific parameters.
-
getCurrentInfo
Get the current load-balancing configuration.- Returns:
- a
LoadBalancingInformationinstance.
-
setAndGetCurrentInfo
Set the current load-balancing configuration.- Parameters:
currentInfo- aLoadBalancingInformationinstance.- Returns:
- the updated
LoadBalancingInformationinstance.
-
getLastUpdateTime
public long getLastUpdateTime()Get the last update time.- Returns:
- the last update time as a long value.
-
getFallbackBundler
Get the fallback bundler.- Returns:
- a
Bundlerinstance.
-
getPersistence
- Returns:
- the configured persistence, or
nullif none is configured or the initialization failed.
-
getHashAlgorithm
- Returns:
- the hash function used to generate bundle state identifiers.
-