Java Code Examples for org.apache.hadoop.net.NetworkTopology

Following code examples demonstrate how to use org.apache.hadoop.net.NetworkTopology from hadoop. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.apache.hadoop.net.NetworkTopology and various code implementation of this class.
Example 1
Project : hadoop Source File : BlockPlacementPolicyFakeData.java View Source Code on GitHub

  
  public BlockPlacementPolicyFakeData(Configuration conf,  FSClusterStats stats,
                           NetworkTopology clusterMap) {
    initialize(conf, stats, clusterMap, null, null, null);
    
    FSNamesystem.LOG.info("new BlockPlacementPolicyFakeData: " + this);
    lastInstance = this;
  }
			
Example 2
Project : hadoop Source File : FSNamesystemTest.java View Source Code on GitHub

    public void testNetworkTopology() {
        DatanodeDescriptor rack1_data1 = new DatanodeDescriptor(new DatanodeID("rack1_data1"), "/rack1/data1", "localhost");
        DatanodeDescriptor rack1_data2 = new DatanodeDescriptor(new DatanodeID("rack1_data2"), "/rack1/data2", "localhost");
        DatanodeDescriptor rack1_data3 = new DatanodeDescriptor(new DatanodeID("rack1_data3"), "/rack1/data3", "localhost");
        DatanodeDescriptor rack2_data1 = new DatanodeDescriptor(new DatanodeID("rack2_data1"), "/rack2/data1", "localhost");
        DatanodeDescriptor rack2_data2 = new DatanodeDescriptor(new DatanodeID("rack2_data2"), "/rack2/data2", "localhost");

        NetworkTopology networkTopology = new NetworkTopology();

        networkTopology.add(rack1_data1);
        networkTopology.add(rack1_data2);
        networkTopology.add(rack1_data3);
        networkTopology.add(rack2_data1);
        networkTopology.add(rack2_data2);

        Assert.assertEquals(4, networkTopology.getDistance(rack2_data1, rack2_data2));
        Assert.assertEquals(6, networkTopology.getDistance(rack1_data1, rack2_data2));

        Assert.assertEquals("/rack2/data2", networkTopology.getNode("/rack2/data2").getNetworkLocation());

    }
			
Example 3
Project : hadoop Source File : CapacityBlockPlacementPolicy.java View Source Code on GitHub

    @Override
    public void initialize(Configuration conf, FSClusterStats stats,
                           NetworkTopology clusterMap,
                           Host2NodesMap host2datanodeMap) {
        super.initialize(conf, stats, clusterMap, host2datanodeMap);

        this.chooseNodeByCapacity = conf.getBoolean(
                DFS_BLOCK_PLACEMENT_POLICY_CAPACITY_EANBLED, true);

        this.capacityWeightFactor = conf.getFloat(
                DFS_BLOCK_PLACEMENT_POLICY_CAPACITY_FACTOR, this.capacityWeightFactor);

        CapacityBlockPlacementPolicy.totalRandomPrintInterval = conf.getLong(
                DFS_BLOCK_PLACEMENT_POLICY_CAPACITY_PRINTINTERVAL, CapacityBlockPlacementPolicy.totalRandomPrintInterval);

        if (this.capacityWeightFactor < 0)
            this.capacityWeightFactor = 0;

        LOG.info(DFS_BLOCK_PLACEMENT_POLICY_CAPACITY_EANBLED + " : " + this.chooseNodeByCapacity);
        LOG.info(DFS_BLOCK_PLACEMENT_POLICY_CAPACITY_FACTOR + " : " + this.capacityWeightFactor);
        LOG.info(DFS_BLOCK_PLACEMENT_POLICY_CAPACITY_PRINTINTERVAL + " : " + totalRandomPrintInterval + " second(s)");
    }
			
Example 4
Project : hadoop Source File : DataNodeInfos.java View Source Code on GitHub

    public static void main(String[] args) {

        Configuration conf = new Configuration();
        conf.addResource(new Path("/data/gitrep/springcloud2/RepairHdfs/src/main/java/core-site.xml"));
        conf.addResource(new Path("/data/gitrep/springcloud2/RepairHdfs/src/main/java/hdfs-site.xml"));
        NetworkTopology clusterMap = NetworkTopology.getInstance(conf);
        Node node = clusterMap.chooseRandom(NodeBase.ROOT);
        System.out.println(node);

    }