Example usage for org.apache.hadoop.mapreduce.counters Limits init

List of usage examples for org.apache.hadoop.mapreduce.counters Limits init

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.counters Limits init.

Prototype

public synchronized static void init(Configuration conf) 

Source Link

Usage

From source file:co.cask.cdap.StandaloneMain.java

License:Apache License

public static StandaloneMain create(CConfiguration cConf, Configuration hConf) {
    // This is needed to use LocalJobRunner with fixes (we have it in app-fabric).
    // For the modified local job runner
    hConf.addResource("mapred-site-local.xml");
    hConf.reloadConfiguration();/*from  w  w w .  j  av a2 s  .  c o m*/
    // Due to incredibly stupid design of Limits class, once it is initialized, it keeps its settings. We
    // want to make sure it uses our settings in this hConf, so we have to force it initialize here before
    // someone else initializes it.
    Limits.init(hConf);

    File localDataDir = new File(cConf.get(Constants.CFG_LOCAL_DATA_DIR));
    hConf.set(Constants.CFG_LOCAL_DATA_DIR, localDataDir.getAbsolutePath());
    hConf.set(Constants.AppFabric.OUTPUT_DIR, cConf.get(Constants.AppFabric.OUTPUT_DIR));
    hConf.set("hadoop.tmp.dir",
            new File(localDataDir, cConf.get(Constants.AppFabric.TEMP_DIR)).getAbsolutePath());

    // Windows specific requirements
    if (OSDetector.isWindows()) {
        // not set anywhere by the project, expected to be set from IDEs if running from the project instead of sdk
        // hadoop.dll is at cdap-unit-test\src\main\resources\hadoop.dll for some reason
        String hadoopDLLPath = System.getProperty("hadoop.dll.path");
        if (hadoopDLLPath != null) {
            System.load(hadoopDLLPath);
        } else {
            // this is where it is when the standalone sdk is built
            String userDir = System.getProperty("user.dir");
            System.load(Joiner.on(File.separator).join(userDir, "lib", "native", "hadoop.dll"));
        }
    }

    //Run dataset service on random port
    List<Module> modules = createPersistentModules(cConf, hConf);

    return new StandaloneMain(modules, cConf);
}