List of usage examples for org.apache.hadoop.service Service start
void start();
From source file:MRAppMaster.CompositeService.java
License:Apache License
protected void serviceStart() throws Exception { List<Service> services = getServices(); if (LOG.isDebugEnabled()) { LOG.debug(getName() + ": starting services, size=" + services.size()); }/* ww w .java 2s . co m*/ for (Service service : services) { // start the service. If this fails that service // will be stopped and an exception raised service.start(); } super.serviceStart(); }
From source file:org.apache.hoya.yarn.service.CompoundLaunchedService.java
License:Apache License
/** * Run a child service -initing and starting it if this * service has already passed those parts of its own lifecycle * @param service the service to start/*from ww w .j av a 2 s . c om*/ */ protected void runChildService(Service service) { service.init(getConfig()); if (isInState(STATE.STARTED)) { service.start(); } addService(service); }
From source file:org.apache.hoya.yarn.service.SequenceService.java
License:Apache License
/** * Start the next service in the list.//from www .j av a 2 s . 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.LaunchedWorkflowCompositeService.java
License:Apache License
/** * Run a child service -initing and starting it if this * service has already passed those parts of its own lifecycle * @param service the service to start/* www .ja v a2s . co m*/ */ protected boolean deployChildService(Service service) { service.init(getConfig()); addService(service); if (isInState(STATE.STARTED)) { service.start(); return true; } return false; }
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 . ja v a 2 s .c om * 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; }