/** * Wait for a service * @param name name for messages * @param service service */ public EndOfServiceWaiter(String name, Service service) { this.name = name; this.service = service; service.registerServiceListener(this); }
/** * Wait for a service * @param name name for messages * @param service service */ public EndOfServiceWaiter(String name, Service service) { this.name = name; this.service = service; service.registerServiceListener(this); }
protected void addIfServiceDependency(Object object, Object dependency) { if (object instanceof Service && dependency instanceof Service) { Service service = (Service) object; Service dependencyService = (Service) dependency; ServiceWithDependency sd = services.get(service); sd.dependencies.add(dependencyService); dependencyService.registerServiceListener(sd); } }
/** * Add a service, and register it * @param service the {@link Service} to be added. * Important: do not add a service to a parent during your own serviceInit/start, * in Hadoop 2.2; you will trigger a ConcurrentModificationException. */ @Override public synchronized void addService(Service service) { Preconditions.checkArgument(service != null, "null service argument"); service.registerServiceListener(this); super.addService(service); }
/** * Add a service, and register it * @param service the {@link Service} to be added. * Important: do not add a service to a parent during your own serviceInit/start, * in Hadoop 2.2; you will trigger a ConcurrentModificationException. */ @Override public synchronized void addService(Service service) { Preconditions.checkArgument(service != null, "null service argument"); service.registerServiceListener(this); super.addService(service); }
head.registerServiceListener(this); head.start(); } catch (RuntimeException e) {
head.registerServiceListener(this); head.start(); } catch (RuntimeException e) {
@Test public void testStopInInitService() throws Throwable { Service service = new StopInInitService(); BreakableStateChangeListener listener = new BreakableStateChangeListener(); service.registerServiceListener(listener); service.init(new Configuration()); assertServiceInState(service, Service.STATE.STOPPED); assertEventCount(listener, 1); }
@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); }
@Test public void testStopInInitService() throws Throwable { Service service = new StopInInitService(); BreakableStateChangeListener listener = new BreakableStateChangeListener(); service.registerServiceListener(listener); service.init(new Configuration()); assertServiceInState(service, Service.STATE.STOPPED); assertEventCount(listener, 1); }
@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); }