public interface AlertMonitorListener extends RuleBaseMonitorListener
This interface has two event handler methods onAlertMonitorEvent()
and onRetransmittedAlert()
which are both typed to receive object
of type AlertMonitorEvent. However, this is an abstract class so these methods will
only receive instances of the concrete subclasses PostAlertEvent (alerts) and
ClearAlerEvent (clears).
(See
AlertMonitorEvent
,
PostAlertEvent
,
ClearAlertEvent
)
If an AlertMonitorListener is registered with the console, it will receive
these alert and clear events for all agents known to the console.
The agents these event pertain to can be determined from their AgentInstance source.
(See
MonitorListener
for important information pertaining to all MonitorListener interfaces)
Monitoring Alert States
Changes to the alert states of all agents and their rulebases can be ascertained by monitoring the alerts and clears with this interface. What is referred to as the agent's alert state is more accurately described as the state of its rulebase engine. The rulebase engine's state is defined as the highest alert state of all the currently loaded and active rulebases. The alert state of a rulebase is the highest alert state of all of its still active (i.e. not cleared) posted alerts.
Only AlertMonitorEvent objects may change the state of a rulebase and thus the rulebase engine of an agent. A PostAlertEvent can potentially increase the alert state of a rulebase. A ClearAlertEvent can potentially decrease the alert state of a rulebase.
Each AlertMonitorEvent is associated with an alert id and a rulebase.
It can be examined upon delivery to determine the alert id, the name of its rulebase,
the states of both its rulebase and the rulebase engine after the event was generated,
and whether it caused a change in either of those states. All states may be mapped
with the constants defined in
AlertState
,
If the event is a PostAlertEvent, it will also contain an alert state of its own.
A PostAlertEvent with alert state of AlerState.NO_ALERT
is also called
a notification. Rulebases may generate notifications to report on a condition
or deliver a message that should not be interpreted as representing a problem.
Here is a code fragment which illustrates:
public void onAlertMonitorEvent(AlertMonitorEvent e) { ... // Available to all MonitorEvents AgentInstance myAgentInstance = e.getAgentInstance(); // same as e.(AgentInstance)getSource(); String myAgentName = myAgentInstance.getAgentID().getName(); ... // Available to AlertMonitorEvents long myAlertID = e.getAlertID(); String ruleBaseName = e.getRuleBaseStatus().getName(); int ruleBaseState = e.getRuleBaseStatus().getState(); int ruleBaseEngineState = e.getRuleBaseEngineState(); boolean changedRBState = e.ruleBaseStateChanged(); boolean changedEngineState = e.ruleBaseEngineStateChanged(); ... if (e instanceof PostAlertEvent) { int myAlertState = ((PostAlertEvent)e).getAlertState(); boolean isNotification = (myAlertState==AlertState.NO_ALERT)?true:false; // store it away or report it to the user ... else if (e instanceof ClearAlertEvent) { // look at stored alerts to see which, if any, are now cleared ... } }
All AlertMonitorEvent object are delivered to onAlertMonitorEvent()
in the order in which an agent generates corresponding alerts and clears. They are
also delivered in a timely manner soon after the agent generates them.
It is therefore possible, within this handler, to determine the current
alert states and when they change. A typical use of this interface together with
the AgentMonitorListener interface is:
AgentMonitorListener.onAgentAlive()
,
extract the current states from the delivered AgentInstance object
onAlertMonitorEvent()
handler of this interface
AgentMonitorListener.onAgentExpired()
is called for this agent, mark
all states and non-cleared alerts to be in a "cleared" or "unknown" state.
AgentMonitorListener.onAgentAlive()
or after AgentMonitorListener.onAgentExpired()
is called for that
AgentInstance
onRetransmittedAlert()
handler receives
retransmitted PostAlertEvent objects whose state accessor
methods (ruleBaseStateChanged(), ruleBaseEngineStateChanged(),
and getRuleBaseEngineState(),
etc.) reflect the state of the agent
at some point in the past, i.e., at the time the corresponding alert was actually
generated by the agent. Thus, the state accessor methods of these events
can not be used to determine the current state of the agent. (More on
retransmitted alerts below.)
If your application maintains alerts
If your application maintains PostAlertEvent objects received through this interface,
then it may also want to be able to know when the alert conditions they represent
have cleared. This can be accomplished by matching ClearAlertEvents to previously
received PostAlertEvents. The ClearAlertEvent method match()
may be used for this purpose.
(See
match()
) A single ClearAlertEvent may match multiple previously received
PostAlertEvent objects if they represent duplicate alerts. Once a ClearAlertEvent
has been received for a particular AgentInstance, no more PostAlertEvent objects
will be received with the same alert id. If the alert condition represented by the
PostAlertEvent is cleared but then reoccurs, the reoccurrence will be represented
by separate PostAlertEvent with a different alert id.
Because events will no longer be delivered for a particular AgentInstance once it is
declared expired, it is recommended that applications that use this interface
also make use of the
AgentMonitorListener
interface in order to determine when an agent expires.
When an AgentInstance expires any active (non-cleared) PostAlertEvent object your application
maintains for that AgentInstance should be considered to be in an "unknown" state because,
from that point on, you have no way to know the current status of those alert conditions.
It is possible to receive a ClearAlertEvent that doesn't match any previously delivered PostAlertEvent. This would happen if the matching PostAlertEvent was delivered by the agent prior to when your application was started or initialized. These alerts may be retrieved as retransmitted alerts.
Duplicate alerts
Duplicate alerts are represented by PostAlertEvent obects that have the same alert id and
the same AgentInstance source. It is possible to receive duplicate alerts
because a rulebase may be constructed to periodically re-issue an alert while some
alert condition exists. As a result, there may be multiple duplicate alerts. Not all attributes
of PostAlertEvent objects representing duplicate alerts will be the same, so you
must rely on only their alert id and
AgentInstance source in order to identify them as duplicates. For example, the text message
in duplicate alerts may differ because of variable substitution which is performed
in the rulebase engine. As another example, the value returned by
ruleBaseStateChanged()
or
ruleBaseStateChanged()
may be different because the first instance of this duplicate caused the sates
to change, not the second.
Note: A duplicate alert may also be a retransmitted alert. Some applications may want to process retransmitted alerts differently that non-retransmitted alerts. All PostAlertEvents may be tested with the isRetransmittedAlert() methods to detect whether or not they are retransmitted alerts.
Retransmitted alerts
A retransmitted alert is defined as a PostAlertEvent whose isRetransmittedAlert()
method
returns true. A retransmitted alert may also be a duplicate if other PostAlertEvent
objects are received before or after it, bearing the same alert id and AgentInstance source.
This listener may receive a retransmitted alert only after your application has invoked
the method retransmitAlerts()
of the AgentInstance class. This method results in a request to the agent
to retransmit one or more of it's currently active (non-cleared) alerts. It returns
immediately and any resulting retransmitted alerts are returned asynchronously
to this listener shortly thereafter.
(See
retransmitAlerts()
for more information.)
Modifier and Type | Method and Description |
---|---|
void |
onAlertMonitorEvent(AlertMonitorEvent e)
This handler will receive retransmitted PostAlertEvent objects
representing alerts and ClearAlertEvent objects representing
clears.
|
void |
onRetransmittedAlert(AlertMonitorEvent e)
This handler will only receive retransmitted PostAlertEvent objects
|
void onAlertMonitorEvent(AlertMonitorEvent e)
void onRetransmittedAlert(AlertMonitorEvent e)
Copyright © 2000-2019 TIBCO Inc. All Rights Reserved.