Example usage for org.apache.hadoop.net NetworkTopology DEFAULT_RACK

List of usage examples for org.apache.hadoop.net NetworkTopology DEFAULT_RACK

Introduction

In this page you can find the example usage for org.apache.hadoop.net NetworkTopology DEFAULT_RACK.

Prototype

String DEFAULT_RACK

To view the source code for org.apache.hadoop.net NetworkTopology DEFAULT_RACK.

Click Source Link

Usage

From source file:com.bianfeng.bfas.hive.io.RealtimeInputFormat2.java

License:Apache License

private String[] fakeRacks(BlockLocation[] blkLocations, int index) throws IOException {
    String[] allHosts = blkLocations[index].getHosts();
    String[] allTopos = new String[allHosts.length];
    for (int i = 0; i < allHosts.length; i++) {
        allTopos[i] = NetworkTopology.DEFAULT_RACK + "/" + allHosts[i];
    }/*  w w w. ja  v a2  s  . c  o m*/
    return allTopos;
}

From source file:org.apache.hama.bsp.FileInputFormat.java

License:Apache License

private static String[] fakeRacks(BlockLocation[] blkLocations, int index) throws IOException {
    String[] allHosts = blkLocations[index].getHosts();
    String[] allTopos = new String[allHosts.length];
    for (int i = 0; i < allHosts.length; i++) {
        allTopos[i] = NetworkTopology.DEFAULT_RACK + "/" + allHosts[i];
    }/* w  w w . j  a v  a2 s  . co  m*/
    return allTopos;
}

From source file:org.lilyproject.hadooptestfw.fork.MiniMRCluster.java

License:Apache License

public MiniMRCluster(int jobTrackerPort, int taskTrackerPort, int numTaskTrackers, String namenode, int numDir,
        String[] racks, String[] hosts, UserGroupInformation ugi, JobConf conf, int numTrackerToExclude)
        throws IOException {
    if (racks != null && racks.length < numTaskTrackers) {
        LOG.error("Invalid number of racks specified. It should be at least "
                + "equal to the number of tasktrackers");
        shutdown();//from  ww  w  .  j ava 2 s.  c  om
    }
    if (hosts != null && numTaskTrackers > hosts.length) {
        throw new IllegalArgumentException("The length of hosts [" + hosts.length
                + "] is less than the number of tasktrackers [" + numTaskTrackers + "].");
    }

    //Generate rack names if required
    if (racks == null) {
        System.out.println("Generating rack names for tasktrackers");
        racks = new String[numTaskTrackers];
        for (int i = 0; i < racks.length; ++i) {
            racks[i] = NetworkTopology.DEFAULT_RACK;
        }
    }

    //Generate some hostnames if required
    if (hosts == null) {
        System.out.println("Generating host names for tasktrackers");
        hosts = new String[numTaskTrackers];
        for (int i = 0; i < numTaskTrackers; i++) {
            hosts[i] = "host" + i + ".foo.com";
        }
    }
    this.jobTrackerPort = jobTrackerPort;
    this.taskTrackerPort = taskTrackerPort;
    this.jobTrackerInfoPort = 0;
    this.numTaskTrackers = 0;
    this.namenode = namenode;
    this.ugi = ugi;
    this.conf = conf; // this is the conf the mr starts with
    this.numTrackerToExclude = numTrackerToExclude;

    // start the jobtracker
    startJobTracker();

    // Create the TaskTrackers
    for (int idx = 0; idx < numTaskTrackers; idx++) {
        String rack = null;
        String host = null;
        if (racks != null) {
            rack = racks[idx];
        }
        if (hosts != null) {
            host = hosts[idx];
        }

        startTaskTracker(host, rack, idx, numDir);
    }

    this.job = createJobConf(conf);
    waitUntilIdle();
}