Package org.yamcs
Class YamcsInstanceService
java.lang.Object
org.yamcs.YamcsInstanceService
- Direct Known Subclasses:
- YamcsServerInstance
Inspired from Guava services, this class offers the following states:
 
- OFFLINE
- INITIALIZING
- INITIALIZED
- STARTING
- RUNNING
- STOPPING
- FAILED
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddStateListener(InstanceStateListener listener) final voidfinal voidfinal voidprotected abstract voiddoInit()protected abstract voiddoStart()protected abstract voiddoStop()final Throwablefinal YamcsInstanceServiceprotected final voidnotifyFailed(Throwable cause) Invoke this method to transition the service to theYamcsInstance.InstanceState.FAILED.protected final voidImplementing classes should invoke this method once their service has been initialized.protected final voidImplementing classes should invoke this method once their service has started.protected final voidImplementing classes should invoke this method once their service has stopped.voidvoidremoveStateListener(InstanceStateListener listener) final YamcsInstanceServicestate()final YamcsInstanceServicevoid
- 
Constructor Details- 
YamcsInstanceServicepublic YamcsInstanceService()
 
- 
- 
Method Details- 
doInitprotected abstract void doInit()
- 
doStartprotected abstract void doStart()
- 
doStopprotected abstract void doStop()
- 
state
- 
initAsync
- 
startAsync
- 
stopAsync
- 
awaitInitializedpublic final void awaitInitialized()
- 
awaitRunningpublic final void awaitRunning()
- 
awaitOfflinepublic final void awaitOffline()
- 
addStateListener
- 
removeStateListener
- 
notifyInitializedprotected final void notifyInitialized()Implementing classes should invoke this method once their service has been initialized.- Throws:
- IllegalStateException- if the service is not- YamcsInstance.InstanceState.STARTING.
 
- 
notifyStartedprotected final void notifyStarted()Implementing classes should invoke this method once their service has started. It will cause the service to transition fromYamcsInstance.InstanceState.STARTINGtoYamcsInstance.InstanceState.RUNNING.- Throws:
- IllegalStateException- if the service is not- YamcsInstance.InstanceState.STARTING.
 
- 
notifyStoppedprotected final void notifyStopped()Implementing classes should invoke this method once their service has stopped. It will cause the service to transition fromYamcsInstance.InstanceState.STOPPINGtoYamcsInstance.InstanceState.OFFLINE.- Throws:
- IllegalStateException- if the service is neither- YamcsInstance.InstanceState.STOPPINGnor- YamcsInstance.InstanceState.RUNNING.
 
- 
failureCause
- 
notifyFailedInvoke this method to transition the service to theYamcsInstance.InstanceState.FAILED. The service will not be stopped if it is running. Invoke this method when a service has failed critically or otherwise cannot be started nor stopped.
- 
offline
- 
stopping
 
-