Search in sources :

Example 6 with Service

use of org.apache.hadoop.service.Service in project hadoop by apache.

the class TestAbstractYarnScheduler method getPrivateResourceTrackerService.

private ResourceTrackerService getPrivateResourceTrackerService(Dispatcher privateDispatcher, ResourceManager rm, SleepHandler sleepHandler) {
    Configuration conf = getConf();
    RMContext privateContext = new RMContextImpl(privateDispatcher, null, null, null, null, null, null, null, null, null);
    privateContext.setNodeLabelManager(Mockito.mock(RMNodeLabelsManager.class));
    privateDispatcher.register(SchedulerEventType.class, sleepHandler);
    privateDispatcher.register(SchedulerEventType.class, rm.getResourceScheduler());
    privateDispatcher.register(RMNodeEventType.class, new ResourceManager.NodeEventDispatcher(privateContext));
    ((Service) privateDispatcher).init(conf);
    ((Service) privateDispatcher).start();
    NMLivelinessMonitor nmLivelinessMonitor = new NMLivelinessMonitor(privateDispatcher);
    nmLivelinessMonitor.init(conf);
    nmLivelinessMonitor.start();
    NodesListManager nodesListManager = new NodesListManager(privateContext);
    nodesListManager.init(conf);
    RMContainerTokenSecretManager containerTokenSecretManager = new RMContainerTokenSecretManager(conf);
    containerTokenSecretManager.start();
    NMTokenSecretManagerInRM nmTokenSecretManager = new NMTokenSecretManagerInRM(conf);
    nmTokenSecretManager.start();
    ResourceTrackerService privateResourceTrackerService = new ResourceTrackerService(privateContext, nodesListManager, nmLivelinessMonitor, containerTokenSecretManager, nmTokenSecretManager);
    privateResourceTrackerService.init(conf);
    privateResourceTrackerService.start();
    rm.getResourceScheduler().setRMContext(privateContext);
    return privateResourceTrackerService;
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceTrackerService(org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService) Service(org.apache.hadoop.service.Service) ResourceTrackerService(org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) NMLivelinessMonitor(org.apache.hadoop.yarn.server.resourcemanager.NMLivelinessMonitor) RMContainerTokenSecretManager(org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager) NodesListManager(org.apache.hadoop.yarn.server.resourcemanager.NodesListManager) NMTokenSecretManagerInRM(org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM) RMContextImpl(org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl) RMNodeLabelsManager(org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager)

Example 7 with Service

use of org.apache.hadoop.service.Service in project hadoop by apache.

the class CapacitySchedulerPreemptionTestBase method getSchedulingEditPolicy.

SchedulingEditPolicy getSchedulingEditPolicy(MockRM rm) {
    ResourceManager.RMActiveServices activeServices = rm.getRMActiveService();
    SchedulingMonitor mon = null;
    for (Service service : activeServices.getServices()) {
        if (service instanceof SchedulingMonitor) {
            mon = (SchedulingMonitor) service;
            break;
        }
    }
    if (mon != null) {
        return mon.getSchedulingEditPolicy();
    }
    return null;
}
Also used : SchedulingMonitor(org.apache.hadoop.yarn.server.resourcemanager.monitor.SchedulingMonitor) Service(org.apache.hadoop.service.Service) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)

Example 8 with Service

use of org.apache.hadoop.service.Service in project hadoop by apache.

the class ResourceManager method resetDispatcher.

private void resetDispatcher() {
    Dispatcher dispatcher = setupDispatcher();
    ((Service) dispatcher).init(this.conf);
    ((Service) dispatcher).start();
    removeService((Service) rmDispatcher);
    // Need to stop previous rmDispatcher before assigning new dispatcher
    // otherwise causes "AsyncDispatcher event handler" thread leak
    ((Service) rmDispatcher).stop();
    rmDispatcher = dispatcher;
    addIfService(rmDispatcher);
    rmContext.setDispatcher(rmDispatcher);
}
Also used : Service(org.apache.hadoop.service.Service) CompositeService(org.apache.hadoop.service.CompositeService) AsyncDispatcher(org.apache.hadoop.yarn.event.AsyncDispatcher) Dispatcher(org.apache.hadoop.yarn.event.Dispatcher) EventDispatcher(org.apache.hadoop.yarn.event.EventDispatcher)

Example 9 with Service

use of org.apache.hadoop.service.Service in project hadoop by apache.

the class TestJobHistoryEvents method testJobHistoryEventHandlerIsFirstServiceToStop.

@Test
public void testJobHistoryEventHandlerIsFirstServiceToStop() {
    MRApp app = new MRAppWithSpecialHistoryHandler(1, 0, true, this.getClass().getName(), true);
    Configuration conf = new Configuration();
    app.init(conf);
    Service[] services = app.getServices().toArray(new Service[0]);
    // Verifying that it is the last to be added is same as verifying that it is
    // the first to be stopped. CompositeService related tests already validate
    // this.
    Assert.assertEquals("JobHistoryEventHandler", services[services.length - 1].getName());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Service(org.apache.hadoop.service.Service) MRApp(org.apache.hadoop.mapreduce.v2.app.MRApp) Test(org.junit.Test)

Example 10 with Service

use of org.apache.hadoop.service.Service in project hadoop by apache.

the class TestAuxServices method testAuxServices.

@Test
public void testAuxServices() {
    Configuration conf = new Configuration();
    conf.setStrings(YarnConfiguration.NM_AUX_SERVICES, new String[] { "Asrv", "Bsrv" });
    conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Asrv"), ServiceA.class, Service.class);
    conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Bsrv"), ServiceB.class, Service.class);
    final AuxServices aux = new AuxServices();
    aux.init(conf);
    int latch = 1;
    for (Service s : aux.getServices()) {
        assertEquals(INITED, s.getServiceState());
        if (s instanceof ServiceA) {
            latch *= 2;
        } else if (s instanceof ServiceB) {
            latch *= 3;
        } else
            fail("Unexpected service type " + s.getClass());
    }
    assertEquals("Invalid mix of services", 6, latch);
    aux.start();
    for (Service s : aux.getServices()) {
        assertEquals(STARTED, s.getServiceState());
    }
    aux.stop();
    for (Service s : aux.getServices()) {
        assertEquals(STOPPED, s.getServiceState());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) AuxiliaryService(org.apache.hadoop.yarn.server.api.AuxiliaryService) Service(org.apache.hadoop.service.Service) Test(org.junit.Test)

Aggregations

Service (org.apache.hadoop.service.Service)17 Configuration (org.apache.hadoop.conf.Configuration)9 Test (org.junit.Test)9 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)6 AbstractService (org.apache.hadoop.service.AbstractService)5 IOException (java.io.IOException)4 AuxiliaryService (org.apache.hadoop.yarn.server.api.AuxiliaryService)4 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)4 CountDownLatch (java.util.concurrent.CountDownLatch)2 MRApp (org.apache.hadoop.mapreduce.v2.app.MRApp)2 ServiceStateChangeListener (org.apache.hadoop.service.ServiceStateChangeListener)2 SchedulingMonitor (org.apache.hadoop.yarn.server.resourcemanager.monitor.SchedulingMonitor)2 BeforeClass (org.junit.BeforeClass)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ByteBuffer (java.nio.ByteBuffer)1 MRClientProtocol (org.apache.hadoop.mapreduce.v2.api.MRClientProtocol)1 GetDiagnosticsRequest (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDiagnosticsRequest)1 GetDiagnosticsResponse (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDiagnosticsResponse)1 GetTaskAttemptCompletionEventsRequest (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetTaskAttemptCompletionEventsRequest)1 GetTaskAttemptCompletionEventsResponse (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetTaskAttemptCompletionEventsResponse)1