Search in sources :

Example 21 with ResourceManager

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

the class TestZKRMStateStorePerf method initStore.

private void initStore(String hostPort) {
    Optional<String> optHostPort = Optional.fromNullable(hostPort);
    RMContext rmContext = mock(RMContext.class);
    conf = new YarnConfiguration();
    conf.set(YarnConfiguration.RM_ZK_ADDRESS, optHostPort.or((curatorTestingServer == null) ? "" : curatorTestingServer.getConnectString()));
    conf.set(YarnConfiguration.ZK_RM_STATE_STORE_PARENT_PATH, workingZnode);
    store = new ZKRMStateStore();
    store.setResourceManager(new ResourceManager());
    store.init(conf);
    store.start();
    when(rmContext.getStateStore()).thenReturn(store);
    appTokenMgr = new AMRMTokenSecretManager(conf, rmContext);
    appTokenMgr.start();
    clientToAMTokenMgr = new ClientToAMTokenSecretManagerInRM();
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) ClientToAMTokenSecretManagerInRM(org.apache.hadoop.yarn.server.resourcemanager.security.ClientToAMTokenSecretManagerInRM) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) AMRMTokenSecretManager(org.apache.hadoop.yarn.server.resourcemanager.security.AMRMTokenSecretManager)

Example 22 with ResourceManager

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

the class TestRedirectionErrorPage method testAppBlockRenderWithNullCurrentAppAttempt.

@Test
public void testAppBlockRenderWithNullCurrentAppAttempt() throws Exception {
    ApplicationId appId = ApplicationId.newInstance(1234L, 0);
    Injector injector;
    // initialize RM Context, and create RMApp, without creating RMAppAttempt
    final RMContext rmContext = TestRMWebApp.mockRMContext(15, 1, 2, 8);
    injector = WebAppTests.createMockInjector(RMContext.class, rmContext, new Module() {

        @Override
        public void configure(Binder binder) {
            try {
                ResourceManager rm = TestRMWebApp.mockRm(rmContext);
                binder.bind(ResourceManager.class).toInstance(rm);
                binder.bind(ApplicationBaseProtocol.class).toInstance(rm.getClientRMService());
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    });
    ErrorBlock instance = injector.getInstance(ErrorBlock.class);
    instance.set(YarnWebParams.APPLICATION_ID, appId.toString());
    instance.set(YarnWebParams.ERROR_MESSAGE, "This is an error");
    instance.render();
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) Binder(com.google.inject.Binder) ApplicationBaseProtocol(org.apache.hadoop.yarn.api.ApplicationBaseProtocol) Injector(com.google.inject.Injector) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) IOException(java.io.IOException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Module(com.google.inject.Module) Test(org.junit.Test)

Example 23 with ResourceManager

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

the class TestSchedulerHealth method setup.

public void setup() {
    resourceManager = new ResourceManager() {

        @Override
        protected RMNodeLabelsManager createNodeLabelManager() {
            RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
            mgr.init(getConfig());
            return mgr;
        }
    };
    YarnConfiguration conf = new YarnConfiguration();
    conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class);
    resourceManager.init(conf);
    resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey();
    resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey();
    ((AsyncDispatcher) resourceManager.getRMContext().getDispatcher()).start();
}
Also used : AsyncDispatcher(org.apache.hadoop.yarn.event.AsyncDispatcher) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) NullRMNodeLabelsManager(org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NullRMNodeLabelsManager) RMNodeLabelsManager(org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager) NullRMNodeLabelsManager(org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NullRMNodeLabelsManager)

Example 24 with ResourceManager

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

the class MiniYARNCluster method restartResourceManager.

@InterfaceAudience.Private
@VisibleForTesting
public synchronized void restartResourceManager(int index) throws InterruptedException {
    if (resourceManagers[index] != null) {
        resourceManagers[index].stop();
        resourceManagers[index] = null;
    }
    resourceManagers[index] = new ResourceManager();
    initResourceManager(index, getConfig());
    startResourceManager(index);
}
Also used : ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 25 with ResourceManager

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

the class MiniYARNCluster method waitForNodeManagersToConnect.

/**
   * Wait for all the NodeManagers to connect to the ResourceManager.
   *
   * @param timeout Time to wait (sleeps in 10 ms intervals) in milliseconds.
   * @return true if all NodeManagers connect to the (Active)
   * ResourceManager, false otherwise.
   * @throws YarnException if there is no active RM
   * @throws InterruptedException if any thread has interrupted
   * the current thread
   */
public boolean waitForNodeManagersToConnect(long timeout) throws YarnException, InterruptedException {
    GetClusterMetricsRequest req = GetClusterMetricsRequest.newInstance();
    for (int i = 0; i < timeout / 10; i++) {
        ResourceManager rm = getResourceManager();
        if (rm == null) {
            throw new YarnException("Can not find the active RM.");
        } else if (nodeManagers.length == rm.getClientRMService().getClusterMetrics(req).getClusterMetrics().getNumNodeManagers()) {
            LOG.info("All Node Managers connected in MiniYARNCluster");
            return true;
        }
        Thread.sleep(10);
    }
    LOG.info("Node Managers did not connect within 5000ms");
    return false;
}
Also used : GetClusterMetricsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

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