Search in sources :

Example 1 with Service

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

the class TestServiceLifecycle method testStartInInitService.

@Test
public void testStartInInitService() throws Throwable {
    Service service = new StartInInitService();
    BreakableStateChangeListener listener = new BreakableStateChangeListener();
    service.registerServiceListener(listener);
    service.init(new Configuration());
    assertServiceInState(service, Service.STATE.STARTED);
    assertEventCount(listener, 1);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) AbstractService(org.apache.hadoop.service.AbstractService) Service(org.apache.hadoop.service.Service) Test(org.junit.Test)

Example 2 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 3 with Service

use of org.apache.hadoop.service.Service 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)

Example 4 with Service

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

the class TestGetGroups method setUpResourceManager.

@BeforeClass
public static void setUpResourceManager() throws InterruptedException {
    conf = new YarnConfiguration();
    resourceManager = new ResourceManager() {

        @Override
        protected void doSecureLogin() throws IOException {
        }

        ;
    };
    // a reliable way to wait for resource manager to start
    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(conf);
    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: " + conf.get(YarnConfiguration.RM_ADMIN_ADDRESS));
}
Also used : 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) BeforeClass(org.junit.BeforeClass)

Example 5 with Service

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

the class AuxServices method serviceStop.

@Override
public void serviceStop() throws Exception {
    try {
        synchronized (serviceMap) {
            for (Service service : serviceMap.values()) {
                if (service.getServiceState() == Service.STATE.STARTED) {
                    service.unregisterServiceListener(this);
                    service.stop();
                }
            }
            serviceMap.clear();
            serviceMetaData.clear();
        }
    } finally {
        super.serviceStop();
    }
}
Also used : AbstractService(org.apache.hadoop.service.AbstractService) Service(org.apache.hadoop.service.Service) AuxiliaryService(org.apache.hadoop.yarn.server.api.AuxiliaryService)

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