/** * @since 2.1 */ protected boolean isFailed() { return is(State.FAILED); } }
@Override public boolean isStarted() { return super.isStarted(); }
@Override public void close() { Lifecycles.stop(this); }
/** * Start given lifecycle-aware and propagate exceptions. * * @see #start(Lifecycle) */ public static void start(final LifecycleAware component) { checkNotNull(component); start(component.getLifecycle()); }
/** * Stop given lifecycle-aware and propagate exceptions. * * @see #stop(Lifecycle) */ public static void stop(final LifecycleAware component) { checkNotNull(component); stop(component.getLifecycle()); }
/** * Start given component if it implements {@link Lifecycle} or {@link LifecycleAware}. * * @see #start(Lifecycle) * @see #start(LifecycleAware) */ public static void start(final Object component) { if (component instanceof Lifecycle) { start((Lifecycle) component); } else if (component instanceof LifecycleAware) { start((LifecycleAware) component); } else { log.warn("Unable to start component; not a lifecycle: {}", component); } }
public void add(final LifecycleAware... components) { checkNotNull(components); for (LifecycleAware component : components) { add(component.getLifecycle()); } }
public void remove(final LifecycleAware... components) { checkNotNull(components); for (LifecycleAware component : components) { remove(component.getLifecycle()); } }
public void remove(final Lifecycle... components) { checkNotNull(components); for (Lifecycle component : components) { remove(component); } }
public void add(final Lifecycle... components) { checkNotNull(components); for (Lifecycle component : components) { add(component); } }
protected void ensureStopped() { checkState(isStopped(), "Not stopped"); }
protected void doFailed(final String operation, final Throwable cause) throws Exception { logTransitionFailure("Lifecycle operation " + operation + " failed", cause); current = State.FAILED; Throwables.propagateIfPossible(cause, Exception.class); throw Throwables.propagate(cause); }
/** * Stop given lifecycle and propagate exceptions. */ public static void stop(final Lifecycle component) { checkNotNull(component); try { component.stop(); } catch (Exception e) { throw Throwables.propagate(e); } }
/** * Start given lifecycle and propagate exceptions. */ public static void start(final Lifecycle component) { checkNotNull(component); try { component.start(); } catch (Exception e) { throw Throwables.propagate(e); } }
/** * Stop given component if it implements {@link Lifecycle} or {@link LifecycleAware}. * * @see #stop(Lifecycle) * @see #stop(LifecycleAware) */ public static void stop(final Object component) { if (component instanceof Lifecycle) { stop((Lifecycle)component); } else if (component instanceof LifecycleAware) { stop((LifecycleAware) component); } else { log.warn("Unable to stop component; not a lifecycle: {}", component); } } }
@Override public boolean isStarted() { return super.isStarted(); }
protected boolean isStarted() { return is(State.STARTED); }
@Override protected void doStop() throws Exception { Lifecycles.stop(databaseManager.get()); databaseServer.get().stop(); nodeAccess.stop(); }
protected void ensureStarted() { checkState(isStarted(), "Not started"); }
protected boolean isStopped() { return is(State.STOPPED); }