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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStateListener
(InstanceStateListener listener) final void
final void
final void
protected abstract void
doInit()
protected abstract void
doStart()
protected abstract void
doStop()
final Throwable
final YamcsInstanceService
protected final void
notifyFailed
(Throwable cause) Invoke this method to transition the service to theYamcsInstance.InstanceState.FAILED
.protected final void
Implementing classes should invoke this method once their service has been initialized.protected final void
Implementing classes should invoke this method once their service has started.protected final void
Implementing classes should invoke this method once their service has stopped.void
void
removeStateListener
(InstanceStateListener listener) final YamcsInstanceService
state()
final YamcsInstanceService
void
-
Constructor Details
-
YamcsInstanceService
public YamcsInstanceService()
-
-
Method Details
-
doInit
protected abstract void doInit() -
doStart
protected abstract void doStart() -
doStop
protected abstract void doStop() -
state
-
initAsync
-
startAsync
-
stopAsync
-
awaitInitialized
public final void awaitInitialized() -
awaitRunning
public final void awaitRunning() -
awaitOffline
public final void awaitOffline() -
addStateListener
-
removeStateListener
-
notifyInitialized
protected final void notifyInitialized()Implementing classes should invoke this method once their service has been initialized.- Throws:
IllegalStateException
- if the service is notYamcsInstance.InstanceState.STARTING
.
-
notifyStarted
protected final void notifyStarted()Implementing classes should invoke this method once their service has started. It will cause the service to transition fromYamcsInstance.InstanceState.STARTING
toYamcsInstance.InstanceState.RUNNING
.- Throws:
IllegalStateException
- if the service is notYamcsInstance.InstanceState.STARTING
.
-
notifyStopped
protected final void notifyStopped()Implementing classes should invoke this method once their service has stopped. It will cause the service to transition fromYamcsInstance.InstanceState.STOPPING
toYamcsInstance.InstanceState.OFFLINE
.- Throws:
IllegalStateException
- if the service is neitherYamcsInstance.InstanceState.STOPPING
norYamcsInstance.InstanceState.RUNNING
.
-
failureCause
-
notifyFailed
Invoke 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
-