Package org.yamcs
Class YamcsInstanceService
- java.lang.Object
-
- org.yamcs.YamcsInstanceService
-
- Direct Known Subclasses:
YamcsServerInstance
public abstract class YamcsInstanceService extends Object
Inspired from Guava services, this class offers the following states:- OFFLINE
- INITIALIZING
- INITIALIZED
- STARTING
- RUNNING
- STOPPING
- FAILED
-
-
Constructor Summary
Constructors Constructor Description YamcsInstanceService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addStateListener(InstanceStateListener listener)
void
awaitInitialized()
void
awaitOffline()
void
awaitRunning()
protected abstract void
doInit()
protected abstract void
doStart()
protected abstract void
doStop()
Throwable
failureCause()
YamcsInstanceService
initAsync()
protected void
notifyFailed(Throwable cause)
Invoke this method to transition the service to theYamcsInstance.InstanceState.FAILED
.protected void
notifyInitialized()
Implementing classes should invoke this method once their service has been initialized.protected void
notifyStarted()
Implementing classes should invoke this method once their service has started.protected void
notifyStopped()
Implementing classes should invoke this method once their service has stopped.void
offline(org.yamcs.protobuf.YamcsInstance.InstanceState from)
void
removeStateListener(InstanceStateListener listener)
YamcsInstanceService
startAsync()
org.yamcs.protobuf.YamcsInstance.InstanceState
state()
YamcsInstanceService
stopAsync()
void
stopping(org.yamcs.protobuf.YamcsInstance.InstanceState from)
-
-
-
Method Detail
-
doInit
protected abstract void doInit()
-
doStart
protected abstract void doStart()
-
doStop
protected abstract void doStop()
-
state
public final org.yamcs.protobuf.YamcsInstance.InstanceState state()
-
initAsync
public final YamcsInstanceService initAsync()
-
startAsync
public final YamcsInstanceService startAsync()
-
stopAsync
public final YamcsInstanceService stopAsync()
-
awaitInitialized
public final void awaitInitialized()
-
awaitRunning
public final void awaitRunning()
-
awaitOffline
public final void awaitOffline()
-
addStateListener
public void addStateListener(InstanceStateListener listener)
-
removeStateListener
public void removeStateListener(InstanceStateListener listener)
-
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
public final Throwable failureCause()
-
notifyFailed
protected final void notifyFailed(Throwable cause)
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
public void offline(org.yamcs.protobuf.YamcsInstance.InstanceState from)
-
stopping
public void stopping(org.yamcs.protobuf.YamcsInstance.InstanceState from)
-
-