Example usage for org.apache.hadoop.fs CommonConfigurationKeysPublic NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY

List of usage examples for org.apache.hadoop.fs CommonConfigurationKeysPublic NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY

Introduction

In this page you can find the example usage for org.apache.hadoop.fs CommonConfigurationKeysPublic NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY.

Prototype

String NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY

To view the source code for org.apache.hadoop.fs CommonConfigurationKeysPublic NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY.

Click Source Link

Usage

From source file:org.apache.tez.common.MockDNSToSwitchMapping.java

License:Apache License

public static void initializeMockRackResolver() {
    Configuration rackResolverConf = new Configuration(false);
    rackResolverConf.set(CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
            MockDNSToSwitchMapping.class.getName());
    RackResolver.init(rackResolverConf);
}

From source file:org.springframework.yarn.examples.grid.yarn.YarnManagedContainerGroupsTests.java

License:Apache License

private YarnManagedContainerGroups createYmcgResolveToDefaultWithRack() throws Exception {

    Configuration configuration = new Configuration();
    configuration.setClass(CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
            TestRackResolver.class, DNSToSwitchMapping.class);

    // For some weird reason hadoop's rack resolver init
    // is static so we need to tweak field via reflection
    // order to re-init it.
    // TODO: this may break other tests if rack resolver is initialized after this test
    Field initCalledField = RackResolver.class.getDeclaredField("initCalled");
    initCalledField.setAccessible(true);
    initCalledField.setBoolean(null, false);
    RackResolver.init(configuration);// w w  w . j  a  va  2 s  .c  o m

    GenericContainerGroupResolver groupResolver = new GenericContainerGroupResolver();
    groupResolver.setConfiguration(configuration);
    groupResolver.setResolveRacks(true);
    Map<String, List<String>> resolves = new Hashtable<String, List<String>>();
    resolves.put(YarnManagedContainerGroups.DEFAULT_GROUP, Arrays.asList(new String[] { "*" }));
    resolves.put(RACK_GROUP, Arrays.asList(new String[] { "/" + RACK3 }));
    groupResolver.setResolves(resolves);
    groupResolver.afterPropertiesSet();

    YarnManagedContainerGroups managedGroups = new YarnManagedContainerGroups(true);
    managedGroups.setResolver(groupResolver);

    // default group size to 1
    Map<String, Integer> groupSizes = new Hashtable<String, Integer>();
    groupSizes.put(YarnManagedContainerGroups.DEFAULT_GROUP, 2);
    groupSizes.put(RACK_GROUP, 1);
    managedGroups.setGroupSizes(groupSizes);
    return managedGroups;
}