@ThreadSafe public abstract static class Alerter.Abstract extends Object implements Alerter
Implements basic functionalities and common constants for
Alerter
implementations.
Alerter.Abstract, Alerter.Factory, Alerter.Listener, Alerter.SharedContext
Modifier and Type | Field and Description |
---|---|
static String |
CONNECTION_RETRY_DELAY_PROPERTY
The time in millis before an alerter topic connect retry.
|
static ElapsedTime |
DEFAULT_CONNECTION_RETRY_DELAY
Default connection retry delay.
|
static ElapsedTime |
DEFAULT_WATCHDOG_PERIOD
Default watchdog period in milliseconds.
|
static ElapsedTime |
DEFAULT_WATCHDOG_TRIGGER
Default watchdog periods.
|
static String |
EMBEDDED_PROPERTY
Embeds the alerter topic server within the service.
|
static String |
SHARED_PROPERTY
Tries to share the alerter.
|
static String |
STEALTH_PROPERTY
Disables response to 'Ping' signals.
|
static String |
WATCHDOG_PERIOD_PROPERTY
Watchdog period property.
|
static String |
WATCHDOG_TRIGGER_PROPERTY
Watchdog trigger property.
|
Modifier | Constructor and Description |
---|---|
protected |
Abstract()
Constructs an instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addListener(Alerter.Listener listener)
Adds a listener.
|
protected abstract void |
doSend(Alert alert)
Does send an alert.
|
protected abstract boolean |
doSetUp()
Does set up the alerter.
|
protected void |
doStart()
Does start.
|
protected void |
doStop()
Does stop.
|
protected abstract void |
doTearDown()
Does tear down what has been set up.
|
Optional<Alerter> |
getActiveInstance()
Gets the active instance.
|
KeyedGroups |
getAlerterProperties()
Gets the alerter properties.
|
Config |
getConfig()
Gets the config.
|
KeyedGroups |
getConfigProperties()
Gets the configuration properties.
|
Object |
getOwner()
Gets the owner.
|
Optional<Service> |
getService()
Gets the service.
|
Logger |
getThisLogger()
Gets the logger.
|
boolean |
isEmbedded()
Asks if this alerter is embedded.
|
boolean |
isShared()
Gets the shared indicator.
|
boolean |
isStealth()
Gets the stealth indicator.
|
protected void |
notifyListeners(Optional<Alert> alert)
Notifies listeners.
|
boolean |
removeListener(Alerter.Listener listener)
Removes a listener.
|
void |
send(Alert alert)
Sends an alert.
|
boolean |
setUp(Config config,
KeyedGroups alerterProperties,
Thread.UncaughtExceptionHandler owner)
Sets up the alerter.
|
protected abstract Alerter.SharedContext |
sharedContext()
Returns the shared context.
|
void |
start()
Starts.
|
void |
stop()
Stops.
|
void |
tearDown()
Tears down what has been set up.
|
public static final String CONNECTION_RETRY_DELAY_PROPERTY
public static final ElapsedTime DEFAULT_CONNECTION_RETRY_DELAY
public static final ElapsedTime DEFAULT_WATCHDOG_PERIOD
public static final ElapsedTime DEFAULT_WATCHDOG_TRIGGER
public static final String EMBEDDED_PROPERTY
public static final String SHARED_PROPERTY
public static final String STEALTH_PROPERTY
public static final String WATCHDOG_PERIOD_PROPERTY
public static final String WATCHDOG_TRIGGER_PROPERTY
public final boolean addListener(Alerter.Listener listener)
addListener
in interface Alerter
listener
- The listener to be added.public final Optional<Alerter> getActiveInstance()
getActiveInstance
in interface Alerter
@Nonnull @CheckReturnValue public final KeyedGroups getAlerterProperties()
@Nonnull @CheckReturnValue public final Config getConfig()
@Nonnull @CheckReturnValue public final KeyedGroups getConfigProperties()
@Nonnull @CheckReturnValue public final Object getOwner()
@Nonnull @CheckReturnValue public final Optional<Service> getService()
@Nonnull @CheckReturnValue public final Logger getThisLogger()
public boolean isEmbedded()
isEmbedded
in interface Alerter
public final boolean isShared()
public boolean isStealth()
public final boolean removeListener(Alerter.Listener listener)
removeListener
in interface Alerter
listener
- The listener to be removed.public final void send(Alert alert) throws InterruptedException, ServiceNotAvailableException
send
in interface Alerter
alert
- The alert.InterruptedException
- When the service is stopped.ServiceNotAvailableException
- When the service is not available.public final boolean setUp(Config config, KeyedGroups alerterProperties, Thread.UncaughtExceptionHandler owner)
public final void start() throws InterruptedException
public final void tearDown()
protected abstract void doSend(@Nonnull Alert alert) throws InterruptedException, ServiceNotAvailableException
alert
- The alert.InterruptedException
- When the service is stopped.ServiceNotAvailableException
- When the service is not
available.@CheckReturnValue protected abstract boolean doSetUp()
protected void doStart() throws InterruptedException
InterruptedException
- When interrupted.protected void doStop()
protected abstract void doTearDown()
protected final void notifyListeners(@Nonnull Optional<Alert> alert)
alert
- An alert (empty on failure).@Nonnull @CheckReturnValue protected abstract Alerter.SharedContext sharedContext()
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.