List of usage examples for org.apache.hadoop.service Service registerServiceListener
void registerServiceListener(ServiceStateChangeListener listener);
From source file:org.apache.hoya.yarn.service.CompoundService.java
License:Apache License
/** * Add a service, and register it//from w w w. j a v a 2 s.c o m * @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 void addService(Service service) { service.registerServiceListener(this); super.addService(service); }
From source file:org.apache.hoya.yarn.service.SequenceService.java
License:Apache License
/** * Start the next service in the list./*from www. java2s . co m*/ * Return false if there are no more services to run, or this * service has stopped * @return true if a service was started * @throws RuntimeException from any init or start failure * @throws ServiceStateException if this call is made before * the service is started */ public synchronized boolean startNextService() { if (isInState(STATE.STOPPED)) { //downgrade to a failed log.debug("Not starting next service -{} is stopped", this); return false; } if (!isInState(STATE.STARTED)) { //reject attempts to start a service too early throw new ServiceStateException("Cannot start a child service when not started"); } if (serviceList.isEmpty()) { //nothing left to run return false; } if (currentService != null && currentService.getFailureCause() != null) { //did the last service fail? Is this caused by some premature callback? log.debug("Not starting next service due to a failure of {}", currentService); return false; } //bear in mind that init & start can fail, which //can trigger re-entrant calls into the state change listener. //by setting the current service to null //the start-next-service logic is skipped. //now, what does that mean w.r.t exit states? currentService = null; Service head = serviceList.remove(0); try { head.init(getConfig()); head.registerServiceListener(this); head.start(); } catch (RuntimeException e) { noteFailure(e); throw e; } //at this point the service must have explicitly started & not failed, //else an exception would have been raised currentService = head; return true; }
From source file:org.apache.slider.server.services.utility.EndOfServiceWaiter.java
License:Apache License
/** * Wait for a service//from www. jav a 2s . c om * @param name name for messages * @param service service */ public EndOfServiceWaiter(String name, Service service) { this.name = name; this.service = service; service.registerServiceListener(this); }
From source file:org.apache.slider.server.services.workflow.EndOfServiceWaiter.java
License:Apache License
public EndOfServiceWaiter(Service svc) { svc.registerServiceListener(this); }
From source file:org.apache.slider.server.services.workflow.WorkflowCompositeService.java
License:Apache License
/** * Add a service, and register it//from w w w .j a v a 2s.c om * @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); }
From source file:org.apache.slider.server.services.workflow.WorkflowSequenceService.java
License:Apache License
/** * Start the next service in the list.//from w w w. j a v a2s. c o m * Return false if there are no more services to run, or this * service has stopped * @return true if a service was started * @throws RuntimeException from any init or start failure * @throws ServiceStateException if this call is made before * the service is started */ public synchronized boolean startNextService() { if (isInState(STATE.STOPPED)) { //downgrade to a failed LOG.debug("Not starting next service -{} is stopped", this); return false; } if (!isInState(STATE.STARTED)) { //reject attempts to start a service too early throw new ServiceStateException("Cannot start a child service when not started"); } if (serviceList.isEmpty()) { //nothing left to run return false; } if (activeService != null && activeService.getFailureCause() != null) { //did the last service fail? Is this caused by some premature callback? LOG.debug("Not starting next service due to a failure of {}", activeService); return false; } //bear in mind that init & start can fail, which //can trigger re-entrant calls into the state change listener. //by setting the current service to null //the start-next-service logic is skipped. //now, what does that mean w.r.t exit states? activeService = null; Service head = serviceList.remove(0); try { head.init(getConfig()); head.registerServiceListener(this); head.start(); } catch (RuntimeException e) { noteFailure(e); throw e; } //at this point the service must have explicitly started & not failed, //else an exception would have been raised activeService = head; return true; }
From source file:org.apache.tez.dag.app.DAGAppMaster.java
License:Apache License
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); }/* w ww. jav a 2 s. c om*/ }