public class ServiceAppHolderImpl extends ServiceImpl
A service application holder supports a single service application.
Modifier and Type | Field and Description |
---|---|
static String |
SERVICE_APP_CLASS_PROPERTY
The class of the service application to activate.
|
DEFAULT_JOIN_TIMEOUT, DEFAULT_RESTART_DELAY, DEFAULT_STARTING_EXTEND, DEFAULT_STOPPING_EXTEND, DEPENDENCY_PROPERTY, JOIN_TIMEOUT_PROPERTY, MEMORY_LOG_INTERVAL_PROPERTY, MONITOR_DISABLED_PROPERTY, RESTART_ALLOWED_PROPERTY, RESTART_DELAY_PROPERTY, RESTART_IGNORED_PROPERTY, SERVICE_LOG_ID_PROPERTY, SERVICE_UUID_PROPERTY, STARTING_EXTEND_PROPERTY, STARTUP_DELAY_PROPERTY, STATS_LOG_ENABLED_PROPERTY, STOPPING_EXTEND_PROPERTY, ZOMBIE_ENABLED_PROPERTY
MIDNIGHT_EVENT, PING_SIGNAL, PONG_EVENT, RESTART_NOW_SIGNAL, RESTART_SIGNAL, RESUME_SIGNAL, RESUMED_EVENT, STARTED_EVENT, STOP_NOW_SIGNAL, STOP_SIGNAL, STOPPED_EVENT, SUSPEND_SIGNAL, SUSPENDED_EVENT, WATCHDOG_EVENT, ZOMBIE_EVENT
Constructor and Description |
---|
ServiceAppHolderImpl() |
Modifier and Type | Method and Description |
---|---|
protected ServiceStats |
createStats(StatsOwner statsOwner)
Creates a stats instance.
|
protected boolean |
doPendingActions()
Does pending actions.
|
protected void |
doStart()
Does start.
|
protected void |
doStop()
Does stop.
|
ServiceApp |
getServiceApp()
Gets the service application.
|
protected ClassDef |
getServiceAppClassDef()
Gets the service application class definition.
|
protected ServiceApp |
newServiceApp()
Creates a new service application.
|
boolean |
onAlert(Optional<Alert> alert)
Called on alert.
|
protected boolean |
onEvent(Event event)
Called when a event has been received.
|
protected void |
onServicesNotReady()
Acts when some services are not ready.
|
protected boolean |
onSignal(Signal signal)
Called when a signal has been received.
|
protected boolean |
setUp()
Sets up the service thread.
|
protected void |
tearDown()
Tears down what has been set up.
|
addAlertListener, cancelRestarters, disableSuspend, doRun, enableSuspend, exportAgent, fail, getAlerter, getConfig, getDataDir, getEntityName, getJoinTimeout, getMutex, getOptionalSourceUUID, getServiceActivator, getServiceUUID, getSourceUUID, isJMXRegistrationEnabled, isRunning, isStarted, isStopped, isStopping, isWait, isZombie, monitorService, onServiceStartFailure, registerServer, removeAlertListener, restart, restoreConfigState, restoreMonitored, resume, run, saveConfigState, saveMonitored, sendAlert, sendEvent, sendSignal, setRestartEnabled, setRestartSignaled, setSourceUUID, starting, stopping, suspend, tearDownConfig, trySuspend, unregisterServer
addStats, closeSnoozeAlarm, getLogID, getServiceActivatorBase, getServiceName, getStats, getThisLogger, getThread, getTimer, getVersion, interrupt, isCurrentThread, isThreadStarted, join, logStats, scheduleMidnightLogger, setLogID, setServiceActivatorBase, setServiceName, snooze, starting, startThread, startTimer, stopping, stopTimer, toString, uncaughtException, updateStats, wakeUp
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addStats, getServiceName, getStats, getTimer, snooze, starting, stopping, wakeUp
public static final String SERVICE_APP_CLASS_PROPERTY
@Nonnull @CheckReturnValue public ServiceApp getServiceApp()
public boolean onAlert(Optional<Alert> alert)
onAlert
in interface Alerter.Listener
onAlert
in class ServiceImpl
alert
- The alert (empty on failure).protected ServiceStats createStats(StatsOwner statsOwner)
createStats
in class ServiceImpl
statsOwner
- The stats owner.protected boolean doPendingActions() throws InterruptedException, ServiceNotAvailableException
Caution: this is called while synchronized on mutex.
doPendingActions
in class ServiceImpl
InterruptedException
- When the service is stopped.ServiceNotAvailableException
- When the service is not available.protected void doStart() throws Exception
doStart
in class ServiceImpl
Exception
- Handled by ServiceImpl.run()
.protected void doStop() throws Exception
doStop
in class ServiceImpl
Exception
- Handled by ServiceImpl.run()
.@Nullable @CheckReturnValue protected ClassDef getServiceAppClassDef()
@Nullable @CheckReturnValue protected ServiceApp newServiceApp()
protected boolean onEvent(Event event)
Caution: this is called while synchronized on mutex.
onEvent
in class ServiceImpl
event
- The signal.protected void onServicesNotReady()
Caution: this is called while synchronized on mutex.
This is called by the pending actions processing when it not known if all registered services are ready. This may be used by a service thread to trigger some state refresh when the pending actions processing are completed; at that time, all the registered services will be ready.
onServicesNotReady
in class ServiceImpl
protected boolean onSignal(Signal signal)
Caution: this is called while synchronized on mutex.
onSignal
in class ServiceImpl
signal
- The signal.protected boolean setUp()
Overriding subclasses must call this with success before proceeding.
setUp
in class ServiceImpl
protected void tearDown()
tearDown
in class ServiceImpl
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.