Example usage for org.apache.hadoop.yarn.conf YarnConfiguration get

List of usage examples for org.apache.hadoop.yarn.conf YarnConfiguration get

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.conf YarnConfiguration get.

Prototype

public String get(String name) 

Source Link

Document

Get the value of the name property, null if no such property exists.

Usage

From source file:org.springframework.yarn.config.annotation.SpringYarnConfigurationMasterTests.java

License:Apache License

@Test
public void testSimpleConfig() throws Exception {
    assertNotNull(ctx);// ww  w.  ja va  2 s .c  o m
    assertTrue(ctx.containsBean("yarnConfiguration"));
    YarnConfiguration config = (YarnConfiguration) ctx.getBean("yarnConfiguration");
    assertNotNull(config);

    YarnAppmaster master = (YarnAppmaster) ctx.getBean("yarnAppmaster");
    assertNotNull(master);

    assertTrue(ctx.containsBean("yarnLocalresources"));
    ResourceLocalizer localizer = (ResourceLocalizer) ctx.getBean("yarnLocalresources");
    assertNotNull(localizer);

    assertTrue(ctx.containsBean(YarnSystemConstants.DEFAULT_ID_ENVIRONMENT));
    @SuppressWarnings("unchecked")
    Map<String, String> environment = (Map<String, String>) ctx
            .getBean(YarnSystemConstants.DEFAULT_ID_ENVIRONMENT);
    assertNotNull(environment);

    assertTrue(ctx.containsBean(YarnContextUtils.TASK_SCHEDULER_BEAN_NAME));
    assertNotNull(ctx.getBean(YarnContextUtils.TASK_SCHEDULER_BEAN_NAME));

    assertThat(config.get("resource.property"), is("test-site-1.xml"));
    assertThat(config.get("resource.property.2"), is("test-site-2.xml"));
    assertThat(config.get("foo"), is("jee"));
    assertThat(config.get("fs.defaultFS"), is("hdfs://foo.uri"));

    Collection<CopyEntry> copyEntries = TestUtils.readField("copyEntries", localizer);
    assertNotNull(copyEntries);
    assertThat(copyEntries.size(), is(2));

    Iterator<CopyEntry> iterator = copyEntries.iterator();

    CopyEntry copyEntry1 = iterator.next();
    String copyEntrySrc1 = TestUtils.readField("src", copyEntry1);
    String copyEntryDest1 = TestUtils.readField("dest", copyEntry1);
    Boolean copyEntryStaging1 = TestUtils.readField("staging", copyEntry1);
    assertThat(copyEntrySrc1, is("foo.jar"));
    assertThat(copyEntryDest1, is("/tmp"));
    assertThat(copyEntryStaging1, is(true));

    CopyEntry copyEntry2 = iterator.next();
    String copyEntrySrc2 = TestUtils.readField("src", copyEntry2);
    String copyEntryDest2 = TestUtils.readField("dest", copyEntry2);
    Boolean copyEntryStaging2 = TestUtils.readField("staging", copyEntry2);
    assertThat(copyEntrySrc2, is("foo2.jar"));
    assertThat(copyEntryDest2, is("/tmp"));
    assertThat(copyEntryStaging2, is(false));

}

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);//from w ww .  j av a 2 s  . c o  m
    server.start();

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

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