Search in sources :

Example 11 with YarnConfiguration

use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.

the class TestYarnClient method testBestEffortTimelineDelegationToken.

@Test
public void testBestEffortTimelineDelegationToken() throws Exception {
    Configuration conf = new YarnConfiguration();
    conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
    SecurityUtil.setAuthenticationMethod(AuthenticationMethod.KERBEROS, conf);
    YarnClientImpl client = spy(new YarnClientImpl() {

        @Override
        TimelineClient createTimelineClient() throws IOException, YarnException {
            timelineClient = mock(TimelineClient.class);
            when(timelineClient.getDelegationToken(any(String.class))).thenThrow(new IOException("Best effort test exception"));
            return timelineClient;
        }
    });
    client.init(conf);
    conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_CLIENT_BEST_EFFORT, true);
    client.serviceInit(conf);
    client.getTimelineDelegationToken();
    try {
        conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_CLIENT_BEST_EFFORT, false);
        client.serviceInit(conf);
        client.getTimelineDelegationToken();
        Assert.fail("Get delegation token should have thrown an exception");
    } catch (Exception e) {
    // Success
    }
}
Also used : TimelineClient(org.apache.hadoop.yarn.client.api.TimelineClient) CapacitySchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ApplicationIdNotProvidedException(org.apache.hadoop.yarn.exceptions.ApplicationIdNotProvidedException) IOException(java.io.IOException) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 12 with YarnConfiguration

use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.

the class TestYarnClient method testShouldNotRetryForeverForNonNetworkExceptions.

@Test(timeout = 30000, expected = ApplicationNotFoundException.class)
public void testShouldNotRetryForeverForNonNetworkExceptions() throws Exception {
    YarnConfiguration conf = new YarnConfiguration();
    conf.setInt(YarnConfiguration.RESOURCEMANAGER_CONNECT_MAX_WAIT_MS, -1);
    ResourceManager rm = null;
    YarnClient yarnClient = null;
    try {
        // start rm
        rm = new ResourceManager();
        rm.init(conf);
        rm.start();
        yarnClient = YarnClient.createYarnClient();
        yarnClient.init(conf);
        yarnClient.start();
        // create invalid application id
        ApplicationId appId = ApplicationId.newInstance(1430126768L, 10645);
        // RM should throw ApplicationNotFoundException exception
        yarnClient.getApplicationReport(appId);
    } finally {
        if (yarnClient != null) {
            yarnClient.stop();
        }
        if (rm != null) {
            rm.stop();
        }
    }
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 13 with YarnConfiguration

use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.

the class TestDistributedScheduling method doBefore.

@Before
public void doBefore() throws Exception {
    cluster = new MiniYARNCluster("testDistributedSchedulingE2E", 1, 1, 1);
    conf = new YarnConfiguration();
    conf.setBoolean(YarnConfiguration.OPPORTUNISTIC_CONTAINER_ALLOCATION_ENABLED, true);
    conf.setBoolean(YarnConfiguration.DIST_SCHEDULING_ENABLED, true);
    conf.setInt(YarnConfiguration.NM_OPPORTUNISTIC_CONTAINERS_MAX_QUEUE_LENGTH, 10);
    cluster.init(conf);
    cluster.start();
    yarnConf = cluster.getConfig();
    // the client has to connect to AMRMProxy
    yarnConf.set(YarnConfiguration.RM_SCHEDULER_ADDRESS, YarnConfiguration.DEFAULT_AMRM_PROXY_ADDRESS);
    rmClient = YarnClient.createYarnClient();
    rmClient.init(yarnConf);
    rmClient.start();
    // Submit application
    attemptId = createApp(rmClient, cluster, conf);
    appId = attemptId.getApplicationId();
    client = createAMRMProtocol(rmClient, appId, cluster, yarnConf);
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) Before(org.junit.Before)

Example 14 with YarnConfiguration

use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.

the class AbstractZKRegistryTest method createZKServer.

@BeforeClass
public static void createZKServer() throws Exception {
    File zkDir = new File("target/zookeeper");
    FileUtils.deleteDirectory(zkDir);
    assertTrue(zkDir.mkdirs());
    zookeeper = new MicroZookeeperService("InMemoryZKService");
    YarnConfiguration conf = new YarnConfiguration();
    conf.set(MicroZookeeperServiceKeys.KEY_ZKSERVICE_DIR, zkDir.getAbsolutePath());
    zookeeper.init(conf);
    zookeeper.start();
    addToTeardown(zookeeper);
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) File(java.io.File) MicroZookeeperService(org.apache.hadoop.registry.server.services.MicroZookeeperService) BeforeClass(org.junit.BeforeClass)

Example 15 with YarnConfiguration

use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.

the class RMWebApp method buildRedirectPath.

private String buildRedirectPath() {
    // make a copy of the original configuration so not to mutate it. Also use
    // an YarnConfiguration to force loading of yarn-site.xml.
    YarnConfiguration yarnConf = new YarnConfiguration(rm.getConfig());
    String activeRMHAId = RMHAUtils.findActiveRMHAId(yarnConf);
    String path = "";
    if (activeRMHAId != null) {
        yarnConf.set(YarnConfiguration.RM_HA_ID, activeRMHAId);
        InetSocketAddress sock = YarnConfiguration.useHttps(yarnConf) ? yarnConf.getSocketAddr(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT) : yarnConf.getSocketAddr(YarnConfiguration.RM_WEBAPP_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);
        path = sock.getHostName() + ":" + Integer.toString(sock.getPort());
        path = YarnConfiguration.useHttps(yarnConf) ? "https://" + path : "http://" + path;
    }
    return path;
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)477 Test (org.junit.Test)300 Configuration (org.apache.hadoop.conf.Configuration)179 Before (org.junit.Before)65 IOException (java.io.IOException)63 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)51 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)48 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)47 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)41 Path (org.apache.hadoop.fs.Path)39 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)38 File (java.io.File)37 ArrayList (java.util.ArrayList)28 HashMap (java.util.HashMap)27 RMContainerTokenSecretManager (org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager)27 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)26 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)25 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)24 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)24 RMContextImpl (org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl)24