Package org.apache.hadoop.net
Class ScriptBasedMapping
java.lang.Object
org.apache.hadoop.net.AbstractDNSToSwitchMapping
org.apache.hadoop.net.CachedDNSToSwitchMapping
org.apache.hadoop.net.ScriptBasedMapping
- All Implemented Interfaces:
Configurable,DNSToSwitchMapping
This class implements the
DNSToSwitchMapping interface using a
script configured via the
CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY option.
It contains a static class RawScriptBasedMapping that performs
the work: reading the configuration parameters, executing any defined
script, handling errors and such like. The outer
class extends CachedDNSToSwitchMapping to cache the delegated
queries.
This DNS mapper's CachedDNSToSwitchMapping.isSingleSwitch() predicate returns
true if and only if a script is defined.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classorg.apache.hadoop.net.ScriptBasedMapping.RawScriptBasedMappingThis is the uncached script mapping that is fed into the cache managed by the superclassCachedDNSToSwitchMapping -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringText used in thetoString()method if there is no string "no script"Fields inherited from class org.apache.hadoop.net.CachedDNSToSwitchMapping
rawMapping -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance with the default configuration.Create an instance from the given configurationScriptBasedMapping(DNSToSwitchMapping rawMap) Create an instance from the given raw mapping -
Method Summary
Modifier and TypeMethodDescriptiongetConf()Return the configuration used by this object.voidsetConf(Configuration conf) Set the configuration to be used by this object.toString()Methods inherited from class org.apache.hadoop.net.CachedDNSToSwitchMapping
getSwitchMap, isSingleSwitch, reloadCachedMappings, reloadCachedMappings, resolveMethods inherited from class org.apache.hadoop.net.AbstractDNSToSwitchMapping
dumpTopology, isMappingSingleSwitch, isSingleSwitchByScriptPolicy
-
Field Details
-
NO_SCRIPT
Text used in thetoString()method if there is no string "no script"- See Also:
-
-
Constructor Details
-
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
Create an instance from the given raw mapping- Parameters:
rawMap- raw DNSTOSwithMapping
-
ScriptBasedMapping
Create an instance from the given configuration- Parameters:
conf- configuration
-
-
Method Details
-
getConf
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Overrides:
getConfin classAbstractDNSToSwitchMapping- Returns:
- Configuration
-
toString
- Overrides:
toStringin classCachedDNSToSwitchMapping
-
setConf
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- input Configuration.
-