Class PlacementAlgorithm
- java.lang.Object
-
- com.unboundid.directory.sdk.proxy.api.PlacementAlgorithm
-
- All Implemented Interfaces:
Configurable
,ExampleUsageProvider
,Reconfigurable<PlacementAlgorithmConfig>
,UnboundIDExtension
@Extensible @DirectoryProxyServerExtension(appliesToLocalContent=false, appliesToRemoteContent=true) @ThreadSafety(level=INTERFACE_THREADSAFE) public abstract class PlacementAlgorithm extends java.lang.Object implements UnboundIDExtension, Reconfigurable<PlacementAlgorithmConfig>, ExampleUsageProvider
This class defines an API that must be implemented by extensions which are used to select the backend set in which a new entry should be added in an entry-balanced environment. The decision may be based on a wide range of factors, including the contents of the entry to be added, the number of entries in each of the backend servers, or other kinds of criteria.
Note that the placement algorithm will only be used for entries which are immediate subordinates of the entry which is the balancing point. Entries which are more than one level below the balancing point will automatically be added into the same backend set as their parent entry.
Configuring Placement Algorithms
In order to configure a placement algorithm created using this API, use a command like:dsconfig create-placement-algorithm \ --algorithm-name "{algorithm-name}" \ --processor-name "{processor-name}" \ --type third-party \ --set enabled:true \ --set "extension-class:{class-name}" \ --set "extension-argument:{name=value}"
where "{algorithm-name}" is the to use for the placement algorithm instance, "{processor-name}" is the name of the entry-balancing request processor for which the placement algorithm will be used, "{class-name}" is the fully-qualified name of the Java class that extendscom.unboundid.directory.sdk.proxy.api.PlacementAlgorithm
, and "{name=value}" represents name-value pairs for any arguments to provide to the placement algorithm. If multiple arguments should be provided to the placement algorithm, then the "--set extension-argument:{name=value}
" option should be provided multiple times.
-
-
Constructor Summary
Constructors Constructor Description PlacementAlgorithm()
Creates a new instance of this placement algorithm.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
applyBalancingConfigurationChange(java.lang.String balancingBaseDN, java.util.List<BackendSet> backendSets)
Adapts to a change in the backend sets configured for use with the associated entry-balancing request processor.ResultCode
applyConfiguration(PlacementAlgorithmConfig config, ArgumentParser parser, java.util.List<java.lang.String> adminActionsRequired, java.util.List<java.lang.String> messages)
Attempts to apply the configuration from the provided argument parser to this extension.void
defineConfigArguments(ArgumentParser parser)
Updates the provided argument parser to define any configuration arguments which may be used by this extension.void
finalizePlacementAlgorithm()
Performs any cleanup which may be necessary when this LDAP health check is to be taken out of service.java.util.Map<java.util.List<java.lang.String>,java.lang.String>
getExamplesArgumentSets()
Retrieves a map containing examples of configurations that may be used for this extension.abstract java.lang.String[]
getExtensionDescription()
Retrieves a human-readable description for this extension.abstract java.lang.String
getExtensionName()
Retrieves a human-readable name for this extension.void
initializePlacementAlgorithm(ProxyServerContext serverContext, PlacementAlgorithmConfig config, ArgumentParser parser, java.lang.String balancingBaseDN, java.util.List<BackendSet> backendSets)
Initializes this placement algorithm.boolean
isConfigurationAcceptable(PlacementAlgorithmConfig config, ArgumentParser parser, java.util.List<java.lang.String> unacceptableReasons)
Indicates whether the configuration represented by the provided argument parser is acceptable for use by this extension.abstract BackendSet
selectBackendSet(OperationContext operationContext, AddRequest addRequest)
Determines the backend set that should be used to process the specified add operation.BackendSet
selectRebalancingBackendSet(OperationContext operationContext, BackendSet backendSet)
Select a new backend set for an entry that has been modified or a child entry that has been added below an existing entry in a backend set.boolean
supportsRebalancing()
Determines whether this placement algorithm implements theselectRebalancingBackendSet(com.unboundid.directory.sdk.common.types.OperationContext, com.unboundid.directory.sdk.proxy.types.BackendSet)
method to rebalance existing entries.java.lang.String
toString()
Retrieves a string representation of this placement algorithm.abstract void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this placement algorithm to the provided buffer.
-
-
-
Constructor Detail
-
PlacementAlgorithm
public PlacementAlgorithm()
Creates a new instance of this placement algorithm. All placement algorithm implementations must include a default constructor, but any initialization should generally be done in theinitializePlacementAlgorithm
method.
-
-
Method Detail
-
getExtensionName
public abstract java.lang.String getExtensionName()
Retrieves a human-readable name for this extension.- Specified by:
getExtensionName
in interfaceUnboundIDExtension
- Returns:
- A human-readable name for this extension.
-
getExtensionDescription
public abstract java.lang.String[] getExtensionDescription()
Retrieves a human-readable description for this extension. Each element of the array that is returned will be considered a separate paragraph in generated documentation.- Specified by:
getExtensionDescription
in interfaceUnboundIDExtension
- Returns:
- A human-readable description for this extension, or
null
or an empty array if no description should be available.
-
defineConfigArguments
public void defineConfigArguments(ArgumentParser parser) throws ArgumentException
Updates the provided argument parser to define any configuration arguments which may be used by this extension. The argument parser may also be updated to define relationships between arguments (e.g., to specify required, exclusive, or dependent argument sets).- Specified by:
defineConfigArguments
in interfaceConfigurable
- Parameters:
parser
- The argument parser to be updated with the configuration arguments which may be used by this extension.- Throws:
ArgumentException
- If a problem is encountered while updating the provided argument parser.
-
initializePlacementAlgorithm
public void initializePlacementAlgorithm(ProxyServerContext serverContext, PlacementAlgorithmConfig config, ArgumentParser parser, java.lang.String balancingBaseDN, java.util.List<BackendSet> backendSets) throws LDAPException
Initializes this placement algorithm.- Parameters:
serverContext
- A handle to the server context for the Directory Proxy server in which this extension is running.config
- The general configuration for this placement algorithm.parser
- The argument parser which has been initialized from the configuration for this placement algorithm..balancingBaseDN
- The balancing base DN for the associated entry-balancing request processor.backendSets
- The list of backend sets that will be used with the entry-balancing request processor.- Throws:
LDAPException
- If a problem occurs while initializing this LDAP health check.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(PlacementAlgorithmConfig config, ArgumentParser parser, java.util.List<java.lang.String> unacceptableReasons)
Indicates whether the configuration represented by the provided argument parser is acceptable for use by this extension. The parser will have been used to parse any configuration available for this extension, and any automatic validation will have been performed. This method may be used to perform any more complex validation which cannot be performed automatically by the argument parser.- Specified by:
isConfigurationAcceptable
in interfaceReconfigurable<PlacementAlgorithmConfig>
- Parameters:
config
- The general configuration for this extension.parser
- The argument parser that has been used to parse the proposed configuration for this extension.unacceptableReasons
- A list to which messages may be added to provide additional information about why the provided configuration is not acceptable.- Returns:
true
if the configuration in the provided argument parser appears to be acceptable, orfalse
if not.
-
applyConfiguration
public ResultCode applyConfiguration(PlacementAlgorithmConfig config, ArgumentParser parser, java.util.List<java.lang.String> adminActionsRequired, java.util.List<java.lang.String> messages)
Attempts to apply the configuration from the provided argument parser to this extension.- Specified by:
applyConfiguration
in interfaceReconfigurable<PlacementAlgorithmConfig>
- Parameters:
config
- The general configuration for this extension.parser
- The argument parser that has been used to parse the new configuration for this extension.adminActionsRequired
- A list to which messages may be added to provide additional information about any additional administrative actions that may be required to apply some of the configuration changes.messages
- A list to which messages may be added to provide additional information about the processing performed by this method.- Returns:
- A result code providing information about the result of applying
the configuration change. A result of
SUCCESS
should be used to indicate that all processing completed successfully. Any other result will indicate that a problem occurred during processing.
-
finalizePlacementAlgorithm
public void finalizePlacementAlgorithm()
Performs any cleanup which may be necessary when this LDAP health check is to be taken out of service.
-
applyBalancingConfigurationChange
public abstract void applyBalancingConfigurationChange(java.lang.String balancingBaseDN, java.util.List<BackendSet> backendSets)
Adapts to a change in the backend sets configured for use with the associated entry-balancing request processor.- Parameters:
balancingBaseDN
- The updated balancing base DN for the associated entry-balancing request processor.backendSets
- The updated list of backend sets for the associated entry-balancing request processor.
-
selectBackendSet
public abstract BackendSet selectBackendSet(OperationContext operationContext, AddRequest addRequest)
Determines the backend set that should be used to process the specified add operation.- Parameters:
operationContext
- The operation context for the add operation to be processed.addRequest
- The add request being processed.- Returns:
- The backend set in which the add should be processed, or
null
if there is no appropriate backend set.
-
selectRebalancingBackendSet
public BackendSet selectRebalancingBackendSet(OperationContext operationContext, BackendSet backendSet)
Select a new backend set for an entry that has been modified or a child entry that has been added below an existing entry in a backend set.- Parameters:
operationContext
- The operation context for the operation that was processed.backendSet
- The backend set that currently holds the entry.- Returns:
- The backend set where the modified or added entry should be
relocated, or
null
if the entry should not be relocated.
-
supportsRebalancing
public boolean supportsRebalancing()
Determines whether this placement algorithm implements theselectRebalancingBackendSet(com.unboundid.directory.sdk.common.types.OperationContext, com.unboundid.directory.sdk.proxy.types.BackendSet)
method to rebalance existing entries.- Returns:
true
if this placement algorithm supports re-balancing, orfalse
if not.
-
toString
public final java.lang.String toString()
Retrieves a string representation of this placement algorithm.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this placement algorithm.
-
toString
public abstract void toString(java.lang.StringBuilder buffer)
Appends a string representation of this placement algorithm to the provided buffer.- Parameters:
buffer
- The buffer to which the string representation should be appended.
-
getExamplesArgumentSets
public java.util.Map<java.util.List<java.lang.String>,java.lang.String> getExamplesArgumentSets()
Retrieves a map containing examples of configurations that may be used for this extension. The map key should be a list of sample arguments, and the corresponding value should be a description of the behavior that will be exhibited by the extension when used with that configuration.- Specified by:
getExamplesArgumentSets
in interfaceExampleUsageProvider
- Returns:
- A map containing examples of configurations that may be used for
this extension. It may be
null
or empty if there should not be any example argument sets.
-
-