public class FilteredForestConfiguration extends java.lang.Object implements ForestConfiguration
A utility class for wrapping a ForestConfiguration retrieved
from
DataMovementManager.readForestConfig()
. This class
does not modify the ForestConfiguration (of course,
ForestConfiguration is immutable) but instead provides a modified
ForestConfiguration when listForests is called. Passing this (or
any ForestConfiguration) to
Batcher.withForestConfig(com.marklogic.client.datamovement.ForestConfiguration)
will reset the forests seen and used by the Batcher. This class is
used by HostAvailabilityListener to black-list unavailable hosts
(such as in the case of a failover).
Since this does frequent comparision of host names and they compare case insensitive, this converts all host names to lower case.
FilteredForestConfiguration isn't thread-safe, so only one thread should use one instance. WriteBatcher.withForestConfig and QueryBatcher.withForestConfig are thread-safe, however, so any thread can call those any time to pass in an instance of FilteredForestConfiguration.
As with the provided listeners, this utility will not meet the needs of all applications but the source code for it should serve as helpful sample code so you can write your own custom ForestConfiguration wrapper.
Constructor and Description |
---|
FilteredForestConfiguration(ForestConfiguration forestConfig)
Initialize with a ForestConfiguration, usually
from
DataMovementManager.readForestConfig() . |
Modifier and Type | Method and Description |
---|---|
Forest[] |
listForests()
Must be called after configuration methods
(withBlackList, withWhiteList, withRenamedHost).
|
FilteredForestConfiguration |
withBlackList(java.lang.String... hostNames)
Add hosts to the list of black-listed hosts
(hosts which the Batcher will not see when it calls
listForests).
|
FilteredForestConfiguration |
withRenamedHost(java.lang.String hostName,
java.lang.String targetHostName)
Rename hosts to network-addressable names rather
than the host names known to the MarkLogic cluster.
|
FilteredForestConfiguration |
withWhiteList(java.lang.String... hostNames)
Add hosts to a white-list.
|
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, toString, wait, wait, wait
getPreferredHosts
public FilteredForestConfiguration(ForestConfiguration forestConfig)
DataMovementManager.readForestConfig()
.forestConfig
- the ForestConfiguration to
wrappublic Forest[] listForests()
listForests
in interface ForestConfiguration
public FilteredForestConfiguration withBlackList(java.lang.String... hostNames)
hostNames
- the hosts to black-listpublic FilteredForestConfiguration withWhiteList(java.lang.String... hostNames)
hostNames
- the hosts to white-listpublic FilteredForestConfiguration withRenamedHost(java.lang.String hostName, java.lang.String targetHostName)
hostName
- the host to renametargetHostName
- the network-addressable host name
to useCopyright © 2024 MarkLogic Corporation. All Rights Reserved.