public class FilteredForestConfiguration extends 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(String... hostNames)
Add hosts to the list of black-listed hosts (hosts which the Batcher will not see when it calls listForests).
|
FilteredForestConfiguration |
withRenamedHost(String hostName,
String targetHostName)
Rename hosts to network-addressable names rather than the host names known to the MarkLogic cluster.
|
FilteredForestConfiguration |
withWhiteList(String... hostNames)
Add hosts to a white-list.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPreferredHostspublic FilteredForestConfiguration(ForestConfiguration forestConfig)
Initialize with a ForestConfiguration, usually from DataMovementManager.readForestConfig().
forestConfig - the ForestConfiguration to wrappublic Forest[] listForests()
Must be called after configuration methods (withBlackList, withWhiteList, withRenamedHost).
listForests in interface ForestConfigurationpublic FilteredForestConfiguration withBlackList(String... hostNames)
Add hosts to the list of black-listed hosts (hosts which the Batcher will not see when it calls listForests). Do not use at the same time as withWhiteList.
hostNames - the hosts to black-listpublic FilteredForestConfiguration withWhiteList(String... hostNames)
Add hosts to a white-list. Only hosts on the list will be returned when the Batcher calls listForests. Should not be used in combination with black-list as that could be confusing to manage.
hostNames - the hosts to white-listpublic FilteredForestConfiguration withRenamedHost(String hostName, String targetHostName)
Rename hosts to network-addressable names rather than the host names known to the MarkLogic cluster.
hostName - the host to renametargetHostName - the network-addressable host name to useCopyright © 2013-2017 MarkLogic Corporation.