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);
}
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);
}
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);
}
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));
}
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();
}
}
Aggregations