Package org.apache.bookkeeper.net
Class ScriptBasedMapping
- java.lang.Object
-
- org.apache.bookkeeper.net.AbstractDNSToSwitchMapping
-
- org.apache.bookkeeper.net.CachedDNSToSwitchMapping
-
- org.apache.bookkeeper.net.ScriptBasedMapping
-
- All Implemented Interfaces:
Configurable,DNSToSwitchMapping
public final class ScriptBasedMapping extends CachedDNSToSwitchMapping
This class implements theDNSToSwitchMappinginterface using a script configured via theCommonConfigurationKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEYoption. It contains a static classRawScriptBasedMappingthat performs the work: reading the configuration parameters, executing any defined script, handling errors and such like. The outer class extendsCachedDNSToSwitchMappingto cache the delegated queries. This DNS mapper'sCachedDNSToSwitchMapping.isSingleSwitch()predicate returns true if and only if a script is defined.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intDEFAULT_ARG_COUNTDefault number of arguments: 100.(package private) static intMIN_ALLOWABLE_ARGSMinimum number of arguments: 1.static java.lang.StringNO_SCRIPTText used in thetoString()method if there is no string "no script".(package private) static java.lang.StringSCRIPT_ARG_COUNT_KEYKey to the argument count that the script supports "networkTopologyScriptNumberArgs".(package private) static java.lang.StringSCRIPT_FILENAME_KEYKey to the script filename "networkTopologyScriptFileName".-
Fields inherited from class org.apache.bookkeeper.net.CachedDNSToSwitchMapping
rawMapping
-
-
Constructor Summary
Constructors Constructor Description ScriptBasedMapping()Create an instance with the default configuration.ScriptBasedMapping(org.apache.commons.configuration2.Configuration conf)Create an instance from the given configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.commons.configuration2.ConfigurationgetConf()Return the configuration used by this object.voidsetConf(org.apache.commons.configuration2.Configuration conf)Set the configuration to be used by this object.java.lang.StringtoString()-
Methods inherited from class org.apache.bookkeeper.net.CachedDNSToSwitchMapping
getSwitchMap, isSingleSwitch, reloadCachedMappings, resolve, useHostName
-
Methods inherited from class org.apache.bookkeeper.net.AbstractDNSToSwitchMapping
dumpTopology, getBookieAddressResolver, isMappingSingleSwitch, isSingleSwitchByScriptPolicy, setBookieAddressResolver, validateConf
-
-
-
-
Field Detail
-
MIN_ALLOWABLE_ARGS
static final int MIN_ALLOWABLE_ARGS
Minimum number of arguments: 1.- See Also:
- Constant Field Values
-
DEFAULT_ARG_COUNT
static final int DEFAULT_ARG_COUNT
Default number of arguments: 100.- See Also:
- Constant Field Values
-
SCRIPT_FILENAME_KEY
static final java.lang.String SCRIPT_FILENAME_KEY
Key to the script filename "networkTopologyScriptFileName".- See Also:
- Constant Field Values
-
SCRIPT_ARG_COUNT_KEY
static final java.lang.String SCRIPT_ARG_COUNT_KEY
Key to the argument count that the script supports "networkTopologyScriptNumberArgs".- See Also:
- Constant Field Values
-
NO_SCRIPT
public static final java.lang.String NO_SCRIPT
Text used in thetoString()method if there is no string "no script".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ScriptBasedMapping
public ScriptBasedMapping()
Create an instance with the default configuration.Calling
setConf(Configuration)will trigger a re-evaluation of the configuration settings and so be used to set up the mapping script.
-
ScriptBasedMapping
public ScriptBasedMapping(org.apache.commons.configuration2.Configuration conf)
Create an instance from the given configuration.- Parameters:
conf- configuration
-
-
Method Detail
-
getConf
public org.apache.commons.configuration2.Configuration getConf()
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Overrides:
getConfin classAbstractDNSToSwitchMapping- Returns:
- configuration used by this object.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classCachedDNSToSwitchMapping
-
setConf
public void setConf(org.apache.commons.configuration2.Configuration conf)
Set the configuration to be used by this object.This will get called in the superclass constructor, so a check is needed to ensure that the raw mapping is defined before trying to relaying a null configuration.
- Specified by:
setConfin interfaceConfigurable- Overrides:
setConfin classAbstractDNSToSwitchMapping- Parameters:
conf-
-
-