org.apache.hadoop.net
Class ScriptBasedMapping

java.lang.Object
  extended by org.apache.hadoop.net.AbstractDNSToSwitchMapping
      extended by org.apache.hadoop.net.CachedDNSToSwitchMapping
          extended by org.apache.hadoop.net.ScriptBasedMapping
All Implemented Interfaces:
Configurable, DNSToSwitchMapping

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class ScriptBasedMapping
extends CachedDNSToSwitchMapping

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.


Field Summary
static String NO_SCRIPT
          Text used in the toString() method if there is no string "no script"
 
Fields inherited from class org.apache.hadoop.net.CachedDNSToSwitchMapping
rawMapping
 
Constructor Summary
ScriptBasedMapping()
          Create an instance with the default configuration.
ScriptBasedMapping(Configuration conf)
          Create an instance from the given configuration
ScriptBasedMapping(DNSToSwitchMapping rawMap)
          Create an instance from the given raw mapping
 
Method Summary
 Configuration getConf()
          Return the configuration used by this object.
 void setConf(Configuration conf)
          Set the configuration to be used by this object.
 String toString()
           
 
Methods inherited from class org.apache.hadoop.net.CachedDNSToSwitchMapping
getSwitchMap, isSingleSwitch, reloadCachedMappings, reloadCachedMappings, resolve
 
Methods inherited from class org.apache.hadoop.net.AbstractDNSToSwitchMapping
dumpTopology, isMappingSingleSwitch, isSingleSwitchByScriptPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_SCRIPT

public static final String NO_SCRIPT
Text used in the toString() 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(DNSToSwitchMapping rawMap)
Create an instance from the given raw mapping

Parameters:
rawMap - raw DNSTOSwithMapping

ScriptBasedMapping

public ScriptBasedMapping(Configuration conf)
Create an instance from the given configuration

Parameters:
conf - configuration
Method Detail

getConf

public Configuration getConf()
Description copied from interface: Configurable
Return the configuration used by this object.

Specified by:
getConf in interface Configurable
Overrides:
getConf in class AbstractDNSToSwitchMapping

toString

public String toString()
Overrides:
toString in class CachedDNSToSwitchMapping

setConf

public void setConf(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:
setConf in interface Configurable
Overrides:
setConf in class AbstractDNSToSwitchMapping
Parameters:
conf -


Copyright © 2014 Apache Software Foundation. All Rights Reserved.