schedule = CustomScheduler.this.getNextSchedule(); } catch (Throwable t) { service.notifyFailed(t); return; service.notifyFailed(scheduleFailure);
schedule = CustomScheduler.this.getNextSchedule(); } catch (Throwable t) { service.notifyFailed(t); return; service.notifyFailed(scheduleFailure);
schedule = CustomScheduler.this.getNextSchedule(); } catch (Throwable t) { service.notifyFailed(t); return; service.notifyFailed(scheduleFailure);
public void testNotifyFailedWhenNotStarted() { AbstractService service = new DefaultService(); try { service.notifyFailed(new Exception()); fail(); } catch (IllegalStateException expected) { } }
@CanIgnoreReturnValue @Override public final Service startAsync() { if (monitor.enterIf(isStartable)) { try { snapshot = new StateSnapshot(STARTING); enqueueStartingEvent(); doStart(); } catch (Throwable startupFailure) { notifyFailed(startupFailure); } finally { monitor.leave(); dispatchListenerEvents(); } } else { throw new IllegalStateException("Service " + this + " has already been started"); } return this; }
new IllegalStateException( "Cannot notifyStarted() when the service is " + snapshot.state); notifyFailed(failure); throw failure;
/** * Implementing classes should invoke this method once their service has stopped. It will cause * the service to transition from {@link State#STOPPING} to {@link State#TERMINATED}. * * @throws IllegalStateException if the service is neither {@link State#STOPPING} nor {@link * State#RUNNING}. */ protected final void notifyStopped() { monitor.enter(); try { // We check the internal state of the snapshot instead of state() directly so we don't allow // notifyStopped() to be called while STARTING, even if stop() has already been called. State previous = snapshot.state; if (previous != STOPPING && previous != RUNNING) { IllegalStateException failure = new IllegalStateException("Cannot notifyStopped() when the service is " + previous); notifyFailed(failure); throw failure; } snapshot = new StateSnapshot(TERMINATED); enqueueTerminatedEvent(previous); } finally { monitor.leave(); dispatchListenerEvents(); } }
/** * Implementing classes should invoke this method once their service has stopped. It will cause * the service to transition from {@link State#STOPPING} to {@link State#TERMINATED}. * * @throws IllegalStateException if the service is neither {@link State#STOPPING} nor {@link * State#RUNNING}. */ protected final void notifyStopped() { monitor.enter(); try { // We check the internal state of the snapshot instead of state() directly so we don't allow // notifyStopped() to be called while STARTING, even if stop() has already been called. State previous = snapshot.state; if (previous != STOPPING && previous != RUNNING) { IllegalStateException failure = new IllegalStateException("Cannot notifyStopped() when the service is " + previous); notifyFailed(failure); throw failure; } snapshot = new StateSnapshot(TERMINATED); enqueueTerminatedEvent(previous); } finally { monitor.leave(); dispatchListenerEvents(); } }
@CanIgnoreReturnValue @Override public final Service startAsync() { if (monitor.enterIf(isStartable)) { try { snapshot = new StateSnapshot(STARTING); enqueueStartingEvent(); doStart(); } catch (Throwable startupFailure) { notifyFailed(startupFailure); } finally { monitor.leave(); dispatchListenerEvents(); } } else { throw new IllegalStateException("Service " + this + " has already been started"); } return this; }
@CanIgnoreReturnValue @Override public final Service startAsync() { if (monitor.enterIf(isStartable)) { try { snapshot = new StateSnapshot(STARTING); enqueueStartingEvent(); doStart(); } catch (Throwable startupFailure) { notifyFailed(startupFailure); } finally { monitor.leave(); dispatchListenerEvents(); } } else { throw new IllegalStateException("Service " + this + " has already been started"); } return this; }
new IllegalStateException( "Cannot notifyStarted() when the service is " + snapshot.state); notifyFailed(failure); throw failure;
new IllegalStateException( "Cannot notifyStarted() when the service is " + snapshot.state); notifyFailed(failure); throw failure;
notifyFailed(shutdownFailure); } finally { monitor.leave();
notifyFailed(shutdownFailure); } finally { monitor.leave();
notifyFailed(shutdownFailure); } finally { monitor.leave();
public final Future<State> start() { lock.lock(); try { if (state == State.NEW) { state = State.STARTING; doStart(); } } catch (Throwable startupFailure) { // put the exception in the future, the user can get it via Future.get() notifyFailed(startupFailure); } finally { lock.unlock(); } return startup; }
@Override public final ListenableFuture<State> start() { lock.lock(); try { if (state == State.NEW) { state = State.STARTING; doStart(); } } catch (Throwable startupFailure) { // put the exception in the future, the user can get it via Future.get() notifyFailed(startupFailure); } finally { lock.unlock(); } return startup; }
public void testNotifyFailedWhenNotStarted() { AbstractService service = new DefaultService(); try { service.notifyFailed(new Exception()); fail(); } catch (IllegalStateException expected) {} }
@Deprecated @Override public final ListenableFuture<State> start() { if (monitor.enterIf(isStartable)) { try { snapshot = new StateSnapshot(STARTING); starting(); doStart(); } catch (Throwable startupFailure) { notifyFailed(startupFailure); } finally { monitor.leave(); executeListeners(); } } return startup; }
@Deprecated @Override public final ListenableFuture<State> start() { if (monitor.enterIf(isStartable)) { try { snapshot = new StateSnapshot(STARTING); starting(); doStart(); } catch (Throwable startupFailure) { notifyFailed(startupFailure); } finally { monitor.leave(); executeListeners(); } } return startup; }