Search in sources :

Example 1 with ServiceStateChangeListener

use of org.apache.hadoop.service.ServiceStateChangeListener 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 2 with ServiceStateChangeListener

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

Aggregations

IOException (java.io.IOException)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Service (org.apache.hadoop.service.Service)2 ServiceStateChangeListener (org.apache.hadoop.service.ServiceStateChangeListener)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)2 BeforeClass (org.junit.BeforeClass)2 Configuration (org.apache.hadoop.conf.Configuration)1 ResourceManagerAdministrationProtocolPBClientImpl (org.apache.hadoop.yarn.server.api.impl.pb.client.ResourceManagerAdministrationProtocolPBClientImpl)1