Package org.jclouds.lifecycle
Class BaseLifeCycle
java.lang.Object
org.jclouds.lifecycle.BaseLifeCycle
// TODO: Adrian: Document this!
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jclouds.lifecycle.LifeCycle
LifeCycle.Status -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicReference<Exception> protected Loggerprotected LifeCycle.Statusprotected final Objectprotected final com.google.common.util.concurrent.ListeningExecutorService -
Constructor Summary
ConstructorsConstructorDescriptionBaseLifeCycle(com.google.common.util.concurrent.ListeningExecutorService userExecutor, LifeCycle... dependencies) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDependency(LifeCycle lifeCycle) protected voidawaitShutdown(long timeout) protected voidawaitStatus(LifeCycle.Status intended, long timeout) protected abstract voidprotected abstract voiddoWork()protected voidprotected voidprotected Exceptionvoidrun()protected booleanvoidshutdown()Requests shutdown of the component.voidshutdown(long waitMs) Requests shutdown, but will only wait @link waitms millisecondsvoidstart()Asynchronously starts the component
-
Field Details
-
logger
-
userExecutor
protected final com.google.common.util.concurrent.ListeningExecutorService userExecutor -
dependencies
-
statusLock
-
status
-
exception
-
-
Constructor Details
-
BaseLifeCycle
public BaseLifeCycle(com.google.common.util.concurrent.ListeningExecutorService userExecutor, LifeCycle... dependencies)
-
-
Method Details
-
addDependency
-
getStatus
-
run
public void run() -
doWork
- Throws:
Exception
-
doShutdown
protected abstract void doShutdown() -
shouldDoWork
protected boolean shouldDoWork()- Returns:
- false if any dependencies are inactive, or we are inactive, or we have a global exception.
-
start
Description copied from interface:LifeCycleAsynchronously starts the component -
exceptionIfDependenciesNotActive
protected void exceptionIfDependenciesNotActive() -
getExceptionFromDependenciesOrNull
-
getException
- Specified by:
getExceptionin interfaceLifeCycle- Returns:
- Exception or null, if there are no fatal Exceptions encountered in the lifecycle of this component.
-
awaitShutdown
- Throws:
InterruptedException
-
awaitStatus
- Throws:
InterruptedException
-
shutdown
Description copied from interface:LifeCycleRequests shutdown of the component. -
shutdown
public void shutdown(long waitMs) Description copied from interface:LifeCycleRequests shutdown, but will only wait @link waitms milliseconds -
exceptionIfNotActive
protected void exceptionIfNotActive()
-