doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
snapshot = new StateSnapshot(STOPPING); enqueueStoppingEvent(RUNNING); doStop(); break; case STOPPING:
snapshot = new StateSnapshot(STOPPING); enqueueStoppingEvent(RUNNING); doStop(); break; case STOPPING:
snapshot = new StateSnapshot(STOPPING); enqueueStoppingEvent(RUNNING); doStop(); break; case STOPPING:
public final Future<State> stop() { lock.lock(); try { if (state == State.NEW) { state = State.TERMINATED; startup.transitionSucceeded(State.TERMINATED); shutdown.transitionSucceeded(State.TERMINATED); } else if (state == State.STARTING) { shutdownWhenStartupFinishes = true; startup.transitionSucceeded(State.STOPPING); } else if (state == State.RUNNING) { state = State.STOPPING; doStop(); } } catch (Throwable shutdownFailure) { // put the exception in the future, the user can get it via Future.get() notifyFailed(shutdownFailure); } finally { lock.unlock(); } return shutdown; }
@Override public final ListenableFuture<State> stop() { lock.lock(); try { if (state == State.NEW) { state = State.TERMINATED; startup.set(State.TERMINATED); shutdown.set(State.TERMINATED); } else if (state == State.STARTING) { shutdownWhenStartupFinishes = true; startup.set(State.STOPPING); } else if (state == State.RUNNING) { state = State.STOPPING; doStop(); } } catch (Throwable shutdownFailure) { // put the exception in the future, the user can get it via Future.get() notifyFailed(shutdownFailure); } finally { lock.unlock(); } return shutdown; }
/** * Implementing classes should invoke this method once their service has started. It will cause * the service to transition from {@link State#STARTING} to {@link State#RUNNING}. * * @throws IllegalStateException if the service is not {@link State#STARTING}. */ protected final void notifyStarted() { lock.lock(); try { if (snapshot.state != State.STARTING) { IllegalStateException failure = new IllegalStateException( "Cannot notifyStarted() when the service is " + snapshot.state); notifyFailed(failure); throw failure; } if (snapshot.shutdownWhenStartupFinishes) { snapshot = new StateSnapshot(State.STOPPING); // We don't call listeners here because we already did that when we set the // shutdownWhenStartupFinishes flag. doStop(); } else { snapshot = new StateSnapshot(State.RUNNING); running(); } } finally { lock.unlock(); executeListeners(); } }
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
doStop(); } else { snapshot = new StateSnapshot(RUNNING);
snapshot = new StateSnapshot(STOPPING); stopping(RUNNING); doStop(); break; case STOPPING:
snapshot = new StateSnapshot(STOPPING); enqueueStoppingEvent(RUNNING); doStop(); break; case STOPPING: