Example usage for org.apache.hadoop.yarn.server MiniYARNCluster MiniYARNCluster

List of usage examples for org.apache.hadoop.yarn.server MiniYARNCluster MiniYARNCluster

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server MiniYARNCluster MiniYARNCluster.

Prototype

@Deprecated
public MiniYARNCluster(String testName, int numResourceManagers, int numNodeManagers, int numLocalDirs,
        int numLogDirs, boolean enableAHS) 

Source Link

Usage

From source file:com.github.sakserv.minicluster.impl.YarnLocalCluster.java

License:Apache License

@Override
public void start() throws Exception {
    LOG.info("YARN: Starting MiniYarnCluster");
    configure();/*  w w  w. j  a  v  a2 s. c  o  m*/
    miniYARNCluster = new MiniYARNCluster(testName, numResourceManagers, numNodeManagers, numLocalDirs,
            numLogDirs, enableHa);

    miniYARNCluster.serviceInit(configuration);
    miniYARNCluster.init(configuration);
    miniYARNCluster.start();
}

From source file:org.apache.metron.integration.components.YarnComponent.java

License:Apache License

@Override
public void start() throws UnableToStartException {
    conf = new YarnConfiguration();
    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 128);
    conf.set("yarn.log.dir", "target");
    conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
    conf.set(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class.getName());
    conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true);

    try {//from w w w .  j a  v  a  2  s.  c o m
        yarnCluster = new MiniYARNCluster(testName, 1, NUM_NMS, 1, 1, true);
        yarnCluster.init(conf);

        yarnCluster.start();

        waitForNMsToRegister();

        URL url = Thread.currentThread().getContextClassLoader().getResource("yarn-site.xml");
        if (url == null) {
            throw new RuntimeException("Could not find 'yarn-site.xml' dummy file in classpath");
        }
        Configuration yarnClusterConfig = yarnCluster.getConfig();
        yarnClusterConfig.set("yarn.application.classpath", new File(url.getPath()).getParent());
        //write the document to a buffer (not directly to the file, as that
        //can cause the file being written to get read -which will then fail.
        ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        yarnClusterConfig.writeXml(bytesOut);
        bytesOut.close();
        //write the bytes to the file in the classpath
        OutputStream os = new FileOutputStream(new File(url.getPath()));
        os.write(bytesOut.toByteArray());
        os.close();
        FileContext fsContext = FileContext.getLocalFSFileContext();
        fsContext.delete(new Path(conf.get("yarn.timeline-service.leveldb-timeline-store.path")), true);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
        }
    } catch (Exception e) {
        throw new UnableToStartException("Exception setting up yarn cluster", e);
    }
}

From source file:org.testifyproject.resource.yarn.MiniYarnResource.java

License:Apache License

@Override
public LocalResourceInstance<MiniYARNCluster, YarnClient> start(TestContext testContext,
        LocalResource localResource, YarnConfiguration config) throws Exception {
    String logDirectory = config.get(YarnConfiguration.YARN_APP_CONTAINER_LOG_DIR);
    fileSystemUtil.recreateDirectory(logDirectory);
    server = new MiniYARNCluster(testContext.getName(), 1, 1, 1, 1, true);
    server.init(config);// www. j  a  v  a2s.  c om
    server.start();

    client = YarnClient.createYarnClient();
    client.init(server.getConfig());
    client.start();

    return LocalResourceInstanceBuilder.builder().resource(server).client(client).build("yarn", localResource);
}