Search in sources :

Example 6 with ResourceTrackerService

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

the class TestAbstractYarnScheduler method testNodemanagerReconnect.

/**
   * Test the behavior of the scheduler when a node reconnects
   * with changed capabilities. This test is to catch any race conditions
   * that might occur due to the use of the RMNode object.
   * @throws Exception
   */
@Test(timeout = 60000)
public void testNodemanagerReconnect() throws Exception {
    configureScheduler();
    Configuration conf = getConf();
    MockRM rm = new MockRM(conf);
    try {
        rm.start();
        conf.setBoolean(Dispatcher.DISPATCHER_EXIT_ON_ERROR_KEY, false);
        DrainDispatcher privateDispatcher = new DrainDispatcher();
        SleepHandler sleepHandler = new SleepHandler();
        ResourceTrackerService privateResourceTrackerService = getPrivateResourceTrackerService(privateDispatcher, rm, sleepHandler);
        // Register node1
        String hostname1 = "localhost1";
        Resource capability = BuilderUtils.newResource(4096, 4);
        RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
        RegisterNodeManagerRequest request1 = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
        NodeId nodeId1 = NodeId.newInstance(hostname1, 0);
        request1.setNodeId(nodeId1);
        request1.setHttpPort(0);
        request1.setResource(capability);
        privateResourceTrackerService.registerNodeManager(request1);
        privateDispatcher.await();
        Resource clusterResource = rm.getResourceScheduler().getClusterResource();
        Assert.assertEquals("Initial cluster resources don't match", capability, clusterResource);
        Resource newCapability = BuilderUtils.newResource(1024, 1);
        RegisterNodeManagerRequest request2 = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
        request2.setNodeId(nodeId1);
        request2.setHttpPort(0);
        request2.setResource(newCapability);
        // hold up the disaptcher and register the same node with lower capability
        sleepHandler.sleepFlag = true;
        privateResourceTrackerService.registerNodeManager(request2);
        privateDispatcher.await();
        Assert.assertEquals("Cluster resources don't match", newCapability, rm.getResourceScheduler().getClusterResource());
        privateResourceTrackerService.stop();
    } finally {
        rm.stop();
    }
}
Also used : DrainDispatcher(org.apache.hadoop.yarn.event.DrainDispatcher) RegisterNodeManagerRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest) RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Resource(org.apache.hadoop.yarn.api.records.Resource) NodeId(org.apache.hadoop.yarn.api.records.NodeId) MockRM(org.apache.hadoop.yarn.server.resourcemanager.MockRM) ResourceTrackerService(org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService) Test(org.junit.Test)

Aggregations

ResourceTrackerService (org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService)6 Configuration (org.apache.hadoop.conf.Configuration)5 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)4 NMLivelinessMonitor (org.apache.hadoop.yarn.server.resourcemanager.NMLivelinessMonitor)4 NodesListManager (org.apache.hadoop.yarn.server.resourcemanager.NodesListManager)4 RMContextImpl (org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl)4 NMTokenSecretManagerInRM (org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM)4 RMContainerTokenSecretManager (org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager)4 InlineDispatcher (org.apache.hadoop.yarn.event.InlineDispatcher)3 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)3 Before (org.junit.Before)3 Resource (org.apache.hadoop.yarn.api.records.Resource)2 Dispatcher (org.apache.hadoop.yarn.event.Dispatcher)2 RegisterNodeManagerRequest (org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest)2 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)2 NodeEventDispatcher (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.NodeEventDispatcher)2 Service (org.apache.hadoop.service.Service)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)1 Event (org.apache.hadoop.yarn.event.Event)1