@Override protected void serviceInit(Configuration conf) throws Exception { RackResolver.init(conf); super.serviceInit(conf); }
/** * resolving the network topology. * @param hostName the hostname of this node. * @return the resolved {@link Node} for this nodemanager. */ public static Node resolve(String hostName) { return RackResolver.resolve(hostName); }
/** * Utility method for getting a hostname resolved to a node in the * network topology. This method initializes the class with the * right resolver implementation. * @param conf * @param hostName * @return node {@link Node} after resolving the hostname */ public static Node resolve(Configuration conf, String hostName) { init(conf); return coreResolve(hostName); }
@Test public void testCaching() { Configuration conf = new Configuration(); conf.setClass( CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, MyResolver.class, DNSToSwitchMapping.class); RackResolver.init(conf); try { InetAddress iaddr = InetAddress.getByName("host1"); MyResolver.resolvedHost1 = iaddr.getHostAddress(); } catch (UnknownHostException e) { // Ignore if not found } Node node = RackResolver.resolve("host1"); Assert.assertEquals("/rack1", node.getNetworkLocation()); node = RackResolver.resolve("host1"); Assert.assertEquals("/rack1", node.getNetworkLocation()); node = RackResolver.resolve(invalidHost); Assert.assertEquals(NetworkTopology.DEFAULT_RACK, node.getNetworkLocation()); }
@Test public void testScriptName() { Configuration conf = new Configuration(); conf .setClass( CommonConfigurationKeysPublic. NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, ScriptBasedMapping.class, DNSToSwitchMapping.class); conf.set(CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY, "testScript"); RackResolver.init(conf); Assert.assertEquals(RackResolver.getDnsToSwitchMapping().toString(), "script-based mapping with script testScript"); } }
/** * Utility method for getting a hostname resolved to a node in the * network topology. This method doesn't initialize the class. * Call {@link #init(Configuration)} explicitly. * @param hostName * @return node {@link Node} after resolving the hostname */ public static Node resolve(String hostName) { if (!initCalled) { throw new IllegalStateException("RackResolver class not yet initialized"); } return coreResolve(hostName); }
RackResolver.init(conf); Map<String, String> locToRackMap = new HashMap<String, String>(distinctLocations.size()); Map<String, LocationHolder> rackLocations = createLocationsMap(conf); String rack = emptyLocation; if (location != emptyLocation) { rack = RackResolver.resolve(location).getNetworkLocation();
@Test public void testScriptName() { Configuration conf = new Configuration(); conf .setClass( CommonConfigurationKeysPublic. NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, ScriptBasedMapping.class, DNSToSwitchMapping.class); conf.set(CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY, "testScript"); RackResolver.init(conf); Assert.assertEquals(RackResolver.getDnsToSwitchMapping().toString(), "script-based mapping with script testScript"); } }
/** * Utility method for getting a hostname resolved to a node in the * network topology. This method doesn't initialize the class. * Call {@link #init(Configuration)} explicitly. * @param hostName * @return node {@link Node} after resolving the hostname */ public static Node resolve(String hostName) { if (!initCalled) { throw new IllegalStateException("RackResolver class not yet initialized"); } return coreResolve(hostName); }
@Test public void testCaching() { Configuration conf = new Configuration(); conf.setClass( CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, MyResolver.class, DNSToSwitchMapping.class); RackResolver.init(conf); try { InetAddress iaddr = InetAddress.getByName("host1"); MyResolver.resolvedHost1 = iaddr.getHostAddress(); } catch (UnknownHostException e) { // Ignore if not found } Node node = RackResolver.resolve("host1"); Assert.assertEquals("/rack1", node.getNetworkLocation()); node = RackResolver.resolve("host1"); Assert.assertEquals("/rack1", node.getNetworkLocation()); node = RackResolver.resolve(invalidHost); Assert.assertEquals(NetworkTopology.DEFAULT_RACK, node.getNetworkLocation()); }
/** * resolving the network topology. * @param hostName the hostname of this node. * @return the resolved {@link Node} for this nodemanager. */ public static Node resolve(String hostName) { return RackResolver.resolve(hostName); }
@Override protected void serviceInit(Configuration conf) throws Exception { RackResolver.init(conf); super.serviceInit(conf); }
/** * Utility method for getting a hostname resolved to a node in the * network topology. This method initializes the class with the * right resolver implementation. * @param conf * @param hostName * @return node {@link Node} after resolving the hostname */ public static Node resolve(Configuration conf, String hostName) { init(conf); return coreResolve(hostName); }
@Test public void testScriptName() { Configuration conf = new Configuration(); conf .setClass( CommonConfigurationKeysPublic. NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, ScriptBasedMapping.class, DNSToSwitchMapping.class); conf.set(CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY, "testScript"); RackResolver.init(conf); Assert.assertEquals(RackResolver.getDnsToSwitchMapping().toString(), "script-based mapping with script testScript"); } }
/** * Utility method for getting a hostname resolved to a node in the * network topology. This method doesn't initialize the class. * Call {@link #init(Configuration)} explicitly. * @param hostName * @return node {@link Node} after resolving the hostname */ public static Node resolve(String hostName) { if (!initCalled) { throw new IllegalStateException("RackResolver class not yet initialized"); } return coreResolve(hostName); }
@Test public void testCaching() { Configuration conf = new Configuration(); conf.setClass( CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, MyResolver.class, DNSToSwitchMapping.class); RackResolver.init(conf); try { InetAddress iaddr = InetAddress.getByName("host1"); MyResolver.resolvedHost1 = iaddr.getHostAddress(); } catch (UnknownHostException e) { // Ignore if not found } Node node = RackResolver.resolve("host1"); Assert.assertEquals("/rack1", node.getNetworkLocation()); node = RackResolver.resolve("host1"); Assert.assertEquals("/rack1", node.getNetworkLocation()); node = RackResolver.resolve(invalidHost); Assert.assertEquals(NetworkTopology.DEFAULT_RACK, node.getNetworkLocation()); }
/** * resolving the network topology. * @param hostName the hostname of this node. * @return the resolved {@link Node} for this nodemanager. */ public static Node resolve(String hostName) { return RackResolver.resolve(hostName); }
@Override protected void serviceInit(Configuration conf) throws Exception { RackResolver.init(conf); super.serviceInit(conf); }
/** * Utility method for getting a hostname resolved to a node in the * network topology. This method initializes the class with the * right resolver implementation. * @param conf * @param hostName * @return node {@link Node} after resolving the hostname */ public static Node resolve(Configuration conf, String hostName) { init(conf); return coreResolve(hostName); }