public final class AlertMonitor extends NotificationBroadcasterSupport implements AlertMonitorMXBean
Manage the process of accumulating and logging abnormal events such as
IOExceptions and measurements outside of expected thresholds. This class
notifies agents by (a) writing log messages and (b) sending JMX
Notification
s.
This mechanism is designed to organize events generated by background
threads, sometimes very frequently. For example, if a disk fails, the
JOURNAL_FLUSHER thread may receive many IOExceptions per second. These are
treated as Events in this class, and log messages are written periodically
but far less frequently. But in addition, this class is also capable of
sending a Notification
to a management client which may be
useful in making the problem known in a timely fashion
Events are collated by category names. For each category value there
is a separate AlertMonitor.History
of events pertaining to that category. By
separately aggregating events of different categories this class avoids
discarding important, but older events belonging to one category when
receiving new events in a different category. For example, IOExceptions
generated frequently by the JOURNAL_FLUSHER do not overwrite previous events
indicating that the JOURNAL_COPIER has fallen behind.
Modifier and Type | Class and Description |
---|---|
static class |
AlertMonitor.AlertLevel
Severity of an event
|
static class |
AlertMonitor.AlertRecord |
static class |
AlertMonitor.Event
Holder for event data including the event arguments and the time the
event was posted.
|
class |
AlertMonitor.History
Aggregation of
AlertMonitor.Event s in a category. |
Modifier and Type | Field and Description |
---|---|
protected static String |
AGGREGATION_FORMAT |
protected static String |
EVENT_FORMAT |
protected static String |
EXTRA_FORMAT |
CLEANUP_CATEGORY, EXTEND_VOLUME_CATEGORY, FLUSH_STATISTICS_CATEGORY, JOURNAL_CATEGORY, MANY_JOURNAL_FILES, MISSING_VOLUME_CATEGORY, MXBEAN_NAME, READ_PAGE_CATEGORY, WRITE_PAGE_CATEGORY
Modifier and Type | Method and Description |
---|---|
String |
getAlertLevel()
Current maximum AlertLevel in this monitor as a String: one of NORMAL,
WARN or ERROR
|
AlertMonitor.AlertRecord[] |
getAlertRecordArray()
Generate a list of event data suitable for the Akiban Server in-memory
tables implementation.
|
String |
getDetailedHistory(String select)
Return a detailed description, including first and recent occurrences of
events within the History for the specified category.
|
long |
getErrorLogTimeInterval() |
AlertMonitor.History |
getHistory(String name) |
int |
getHistoryLength() |
SortedMap<String,AlertMonitor.History> |
getHistoryMap() |
MBeanNotificationInfo[] |
getNotificationInfo() |
String |
getSummary()
Return a summary of this AlertMonitor's current state.
|
long |
getWarnLogTimeInterval() |
void |
poll(boolean force)
Called periodically to issue any pending log messages or notifications.
|
void |
post(AlertMonitor.Event event,
String category)
Post an event.
|
void |
reset()
Restore this alert monitor to level
AlertMonitor.AlertLevel.NORMAL with and
remove all histories for all categories. |
void |
setErrorLogTimeInterval(long errorLogTimeInterval)
Set the interval between successive log entries for this monitor when its
AlertMonitor.AlertLevel.ERROR . |
void |
setHistoryLength(int historyLength)
Set the number of
Event s per category to keep in the
History . |
void |
setWarnLogTimeInterval(long warnLogTimeInterval)
Set the interval between successive log entries for this monitor when its
AlertMonitor.AlertLevel.WARN . |
String |
toString() |
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
protected static final String EVENT_FORMAT
protected static final String AGGREGATION_FORMAT
protected static final String EXTRA_FORMAT
public final void post(AlertMonitor.Event event, String category)
AlertMonitor.History
for the specified
category and then add the event to it. Subsequently, poll the
History
to cause any pending notifications or log messages
to be emitted.event
- A Event object describing what happenedcategory
- A String describing the nature of the event. A separate
event-history is maintained for each unique category.public void reset()
AlertMonitor.AlertLevel.NORMAL
with and
remove all histories for all categories. The logging time intervals and
history length are not changed.reset
in interface AlertMonitorMXBean
public long getWarnLogTimeInterval()
getWarnLogTimeInterval
in interface AlertMonitorMXBean
AlertMonitor.AlertLevel.WARN
.public void setWarnLogTimeInterval(long warnLogTimeInterval)
AlertMonitor.AlertLevel.WARN
.setWarnLogTimeInterval
in interface AlertMonitorMXBean
warnLogTimeInterval
- the interval in millisecondspublic long getErrorLogTimeInterval()
getErrorLogTimeInterval
in interface AlertMonitorMXBean
AlertMonitor.AlertLevel.ERROR
.public void setErrorLogTimeInterval(long errorLogTimeInterval)
AlertMonitor.AlertLevel.ERROR
.setErrorLogTimeInterval
in interface AlertMonitorMXBean
errorLogTimeInterval
- the interval in millisecondspublic int getHistoryLength()
getHistoryLength
in interface AlertMonitorMXBean
History
per
category.setHistoryLength(int)
public AlertMonitor.History getHistory(String name)
name
- Category nameHistory
for that category or null
if the specified category has no History
.public SortedMap<String,AlertMonitor.History> getHistoryMap()
public void setHistoryLength(int historyLength)
Event
s per category to keep in the
History
. Once the number of events exceeds this count,
earlier events are removed when new events are added. (However, the first
Event
added is retained and get accessed via
AlertMonitor.History.getFirstEvent()
even when subsequent Event
s
are removed.) The default value is 10.setHistoryLength
in interface AlertMonitorMXBean
historyLength
- the historyLength to setpublic AlertMonitor.AlertRecord[] getAlertRecordArray()
public void poll(boolean force)
poll
in interface AlertMonitorMXBean
force
- Indicates whether to issue pending log messages and
notifications prior to expiration of their respective
notification time intervals.public String toString()
public String getSummary()
AlertMonitorMXBean
getSummary
in interface AlertMonitorMXBean
History
instances.toString()
public String getDetailedHistory(String select)
AlertMonitorMXBean
null
.getDetailedHistory
in interface AlertMonitorMXBean
select
- The category name(s) to include, optionally with wildcards '*'
and '?'public String getAlertLevel()
AlertMonitorMXBean
getAlertLevel
in interface AlertMonitorMXBean
AlertMonitor.AlertLevel
among
all categories being maintainedpublic MBeanNotificationInfo[] getNotificationInfo()
getNotificationInfo
in interface NotificationBroadcaster
getNotificationInfo
in class NotificationBroadcasterSupport
Copyright © 2025 Open Identity Platform Community. All rights reserved.