Search in sources :

Example 1 with ResourceManager

use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.

the class SLSRunner method startRM.

private void startRM() throws IOException, ClassNotFoundException {
    Configuration rmConf = new YarnConfiguration();
    String schedulerClass = rmConf.get(YarnConfiguration.RM_SCHEDULER);
    // exercise/track behaviors that are not common to the scheduler api
    if (Class.forName(schedulerClass) == CapacityScheduler.class) {
        rmConf.set(YarnConfiguration.RM_SCHEDULER, SLSCapacityScheduler.class.getName());
    } else {
        rmConf.set(YarnConfiguration.RM_SCHEDULER, ResourceSchedulerWrapper.class.getName());
        rmConf.set(SLSConfiguration.RM_SCHEDULER, schedulerClass);
    }
    rmConf.set(SLSConfiguration.METRICS_OUTPUT_DIR, metricsOutputDir);
    final SLSRunner se = this;
    rm = new ResourceManager() {

        @Override
        protected ApplicationMasterLauncher createAMLauncher() {
            return new MockAMLauncher(se, this.rmContext, amMap);
        }
    };
    rm.init(rmConf);
    rm.start();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) SLSConfiguration(org.apache.hadoop.yarn.sls.conf.SLSConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) MockAMLauncher(org.apache.hadoop.yarn.sls.resourcemanager.MockAMLauncher) ApplicationMasterLauncher(org.apache.hadoop.yarn.server.resourcemanager.amlauncher.ApplicationMasterLauncher) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) ResourceSchedulerWrapper(org.apache.hadoop.yarn.sls.scheduler.ResourceSchedulerWrapper) SLSCapacityScheduler(org.apache.hadoop.yarn.sls.scheduler.SLSCapacityScheduler)

Example 2 with ResourceManager

use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager 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 3 with ResourceManager

use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.

the class TestRMFailover method testUncaughtExceptionHandlerWithHAEnabled.

/**
   * Throw {@link RuntimeException} inside a thread of
   * {@link ResourceManager} with HA enabled and check if the
   * {@link ResourceManager} is transited to standby state.
   *
   * @throws InterruptedException if any
   */
@Test
public void testUncaughtExceptionHandlerWithHAEnabled() throws InterruptedException {
    conf.set(YarnConfiguration.RM_CLUSTER_ID, "yarn-test-cluster");
    conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
    cluster.init(conf);
    cluster.start();
    assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
    ResourceManager resourceManager = cluster.getResourceManager(cluster.getActiveRMIndex());
    final RMCriticalThreadUncaughtExceptionHandler exHandler = new RMCriticalThreadUncaughtExceptionHandler(resourceManager.getRMContext());
    // Create a thread and throw a RTE inside it
    final RuntimeException rte = new RuntimeException("TestRuntimeException");
    final Thread testThread = new Thread(new Runnable() {

        @Override
        public void run() {
            throw rte;
        }
    });
    testThread.setName("TestThread");
    testThread.setUncaughtExceptionHandler(exHandler);
    testThread.start();
    testThread.join();
    int maxWaitingAttempts = 2000;
    while (maxWaitingAttempts-- > 0) {
        if (resourceManager.getRMContext().getHAServiceState() == HAServiceState.STANDBY) {
            break;
        }
        Thread.sleep(1);
    }
    assertFalse("RM didn't transition to Standby ", maxWaitingAttempts < 0);
}
Also used : RMCriticalThreadUncaughtExceptionHandler(org.apache.hadoop.yarn.server.resourcemanager.RMCriticalThreadUncaughtExceptionHandler) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) Test(org.junit.Test)

Example 4 with ResourceManager

use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.

the class TestRMFailover method testAutomaticFailover.

@Test
public void testAutomaticFailover() throws YarnException, InterruptedException, IOException {
    conf.set(YarnConfiguration.RM_CLUSTER_ID, "yarn-test-cluster");
    conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
    conf.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, 2000);
    cluster.init(conf);
    cluster.start();
    assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
    verifyConnections();
    failover();
    verifyConnections();
    failover();
    verifyConnections();
    // Make the current Active handle an RMFatalEvent,
    // so it transitions to standby.
    ResourceManager rm = cluster.getResourceManager(cluster.getActiveRMIndex());
    rm.handleTransitionToStandByInNewThread();
    int maxWaitingAttempts = 2000;
    while (maxWaitingAttempts-- > 0) {
        if (rm.getRMContext().getHAServiceState() == HAServiceState.STANDBY) {
            break;
        }
        Thread.sleep(1);
    }
    Assert.assertFalse("RM didn't transition to Standby ", maxWaitingAttempts == 0);
    verifyConnections();
}
Also used : ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) Test(org.junit.Test)

Example 5 with ResourceManager

use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.

the class TestResourceManagerAdministrationProtocolPBClientImpl method setUpResourceManager.

/**
   * Start resource manager server
   */
@BeforeClass
public static void setUpResourceManager() throws IOException, InterruptedException {
    Configuration.addDefaultResource("config-with-security.xml");
    Configuration configuration = new YarnConfiguration();
    resourceManager = new ResourceManager() {

        @Override
        protected void doSecureLogin() throws IOException {
        }
    };
    // a reliable way to wait for resource manager to fully start
    final CountDownLatch rmStartedSignal = new CountDownLatch(1);
    ServiceStateChangeListener rmStateChangeListener = new ServiceStateChangeListener() {

        @Override
        public void stateChanged(Service service) {
            if (service.getServiceState() == STATE.STARTED) {
                rmStartedSignal.countDown();
            }
        }
    };
    resourceManager.registerServiceListener(rmStateChangeListener);
    resourceManager.init(configuration);
    new Thread() {

        public void run() {
            resourceManager.start();
        }
    }.start();
    boolean rmStarted = rmStartedSignal.await(60000L, TimeUnit.MILLISECONDS);
    Assert.assertTrue("ResourceManager failed to start up.", rmStarted);
    LOG.info("ResourceManager RMAdmin address: " + configuration.get(YarnConfiguration.RM_ADMIN_ADDRESS));
    client = new ResourceManagerAdministrationProtocolPBClientImpl(1L, getProtocolAddress(configuration), configuration);
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ServiceStateChangeListener(org.apache.hadoop.service.ServiceStateChangeListener) Service(org.apache.hadoop.service.Service) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) ResourceManagerAdministrationProtocolPBClientImpl(org.apache.hadoop.yarn.server.api.impl.pb.client.ResourceManagerAdministrationProtocolPBClientImpl) BeforeClass(org.junit.BeforeClass)

Aggregations

ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)36 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)18 Test (org.junit.Test)17 Configuration (org.apache.hadoop.conf.Configuration)10 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)10 IOException (java.io.IOException)7 ResourceScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler)6 Binder (com.google.inject.Binder)5 Injector (com.google.inject.Injector)5 Module (com.google.inject.Module)5 RMNodeLabelsManager (org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager)5 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)4 AsyncDispatcher (org.apache.hadoop.yarn.event.AsyncDispatcher)4 ClientRMService (org.apache.hadoop.yarn.server.resourcemanager.ClientRMService)4 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)4 Service (org.apache.hadoop.service.Service)3 Before (org.junit.Before)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2