org.apache.hadoop.net
Class ScriptBasedMapping.RawScriptBasedMapping

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

protected static class ScriptBasedMapping.RawScriptBasedMapping
extends AbstractDNSToSwitchMapping

This is the uncached script mapping that is fed into the cache managed by the superclass CachedDNSToSwitchMapping


Constructor Summary
ScriptBasedMapping.RawScriptBasedMapping()
          Constructor.
 
Method Summary
 boolean isSingleSwitch()
          Declare that the mapper is single-switched if a script was not named in the configuration.
 void reloadCachedMappings()
          Reload all of the cached mappings.
 void reloadCachedMappings(List<String> names)
          Reload cached mappings on specific nodes.
 List<String> resolve(List<String> names)
          Resolves a list of DNS-names/IP-addresses and returns back a list of switch information (network paths).
protected  String runResolveCommand(List<String> args, String commandScriptName)
          Build and execute the resolution command.
 void setConf(Configuration conf)
          Set the configuration and extract the configuration parameters of interest
 String toString()
           
 
Methods inherited from class org.apache.hadoop.net.AbstractDNSToSwitchMapping
dumpTopology, getConf, getSwitchMap, isMappingSingleSwitch, isSingleSwitchByScriptPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptBasedMapping.RawScriptBasedMapping

public ScriptBasedMapping.RawScriptBasedMapping()
Constructor. The mapping is not ready to use until setConf(Configuration) has been called

Method Detail

setConf

public void setConf(Configuration conf)
Set the configuration and extract the configuration parameters of interest

Specified by:
setConf in interface Configurable
Overrides:
setConf in class AbstractDNSToSwitchMapping
Parameters:
conf - the new configuration

resolve

public List<String> resolve(List<String> names)
Description copied from interface: DNSToSwitchMapping
Resolves a list of DNS-names/IP-addresses and returns back a list of switch information (network paths). One-to-one correspondence must be maintained between the elements in the lists. Consider an element in the argument list - x.y.com. The switch information that is returned must be a network path of the form /foo/rack, where / is the root, and 'foo' is the switch where 'rack' is connected. Note the hostname/ip-address is not part of the returned path. The network topology of the cluster would determine the number of components in the network path.

If a name cannot be resolved to a rack, the implementation should return NetworkTopology.DEFAULT_RACK. This is what the bundled implementations do, though it is not a formal requirement

Parameters:
names - the list of hosts to resolve (can be empty)
Returns:
list of resolved network paths. If names is empty, the returned list is also empty

runResolveCommand

protected String runResolveCommand(List<String> args,
                                   String commandScriptName)
Build and execute the resolution command. The command is executed in the directory specified by the system property "user.dir" if set; otherwise the current working directory is used

Parameters:
args - a list of arguments
Returns:
null if the number of arguments is out of range, or the output of the command.

isSingleSwitch

public boolean isSingleSwitch()
Declare that the mapper is single-switched if a script was not named in the configuration.

Overrides:
isSingleSwitch in class AbstractDNSToSwitchMapping
Returns:
true iff there is no script

toString

public String toString()
Overrides:
toString in class Object

reloadCachedMappings

public void reloadCachedMappings()
Description copied from interface: DNSToSwitchMapping
Reload all of the cached mappings. If there is a cache, this method will clear it, so that future accesses will get a chance to see the new data.


reloadCachedMappings

public void reloadCachedMappings(List<String> names)
Description copied from interface: DNSToSwitchMapping
Reload cached mappings on specific nodes. If there is a cache on these nodes, this method will clear it, so that future accesses will see updated data.



Copyright © 2014 Apache Software Foundation. All Rights Reserved.