Kea 2.7.4
isc::perfmon::AlarmStore Class Reference

Maintains an in-memory store of alarms. More...

#include <alarm_store.h>

Public Member Functions

 AlarmStore (uint16_t family)
 Constructor.
 
 ~AlarmStore ()=default
 Destructor.
 
AlarmPtr addAlarm (AlarmPtr alarm)
 Adds an alarm to the store.
 
AlarmPtr addAlarm (DurationKeyPtr key, const Duration &low_water, const Duration &high_water, bool enabled=true)
 Creates a new alarm and adds it to the store.
 
AlarmPtr checkDurationSample (DurationKeyPtr key, const Duration &sample, const Duration &report_interval)
 Checks a sample against an alarm.
 
void clear ()
 Removes all alarms from the store.
 
void deleteAlarm (DurationKeyPtr key)
 Removes the alarm from the store.
 
AlarmPtr getAlarm (DurationKeyPtr key)
 Fetches a duration from the store for a given key.
 
AlarmCollectionPtr getAll ()
 Fetches all of the alarms (in order by target)
 
uint16_t getFamily ()
 Get protocol family.
 
void updateAlarm (AlarmPtr &alarm)
 Updates an alarm in the store.
 

Detailed Description

Maintains an in-memory store of alarms.

Provides essential CRUD functions for managing a collection of alarms. Additionally there are finders that can return durations by DurationKey (others are TBD). All finders return copies of the durations found, rather than the stored duration itself.

Definition at line 74 of file alarm_store.h.

Constructor & Destructor Documentation

◆ AlarmStore()

isc::perfmon::AlarmStore::AlarmStore ( uint16_t family)
explicit

Constructor.

Parameters
familyprotocol family AF_INET or AF_INET6

Definition at line 19 of file alarm_store.cc.

References isc_throw.

◆ ~AlarmStore()

isc::perfmon::AlarmStore::~AlarmStore ( )
default

Destructor.

Member Function Documentation

◆ addAlarm() [1/2]

AlarmPtr isc::perfmon::AlarmStore::addAlarm ( AlarmPtr alarm)

Adds an alarm to the store.

Returns
pointer to a copy of the alarm added.

Definition at line 76 of file alarm_store.cc.

References isc_throw.

◆ addAlarm() [2/2]

AlarmPtr isc::perfmon::AlarmStore::addAlarm ( DurationKeyPtr key,
const Duration & low_water,
const Duration & high_water,
bool enabled = true )

Creates a new alarm and adds it to the store.

Parameters
keykey value of the alarm to create.
low_waterthreshold below which the mean duration must fall to clear the alarm
high_waterthreshold above which the mean duration must rise to trigger the alarm.
enabledtrue sets state to CLEAR, otherwise DISABLED, defaults to true.
Returns
pointer to the newly created alarm.
Exceptions
DuplicateAlarmif a duration for the given key already exists in the store.

Definition at line 89 of file alarm_store.cc.

References addAlarm(), isc_throw, and isc::Exception::what().

Referenced by addAlarm().

+ Here is the call graph for this function:

◆ checkDurationSample()

AlarmPtr isc::perfmon::AlarmStore::checkDurationSample ( DurationKeyPtr key,
const Duration & sample,
const Duration & report_interval )

Checks a sample against an alarm.

If the alarm exists in the store for the duration key, then Alarm::checkSample() is invoked on the in-store alarm. If this returns true, indicating an alarm state change, then a copy of the in-store alarm is returned, otherwise an empty pointer is returned.

If no alarm exists in the store, then it simply returns an empty pointer.

This function does not/must not modify any index keys.

Parameters
keykey value of the alarm to check.
sampleduration value to check.
report_intervalamount of time that must elapse between high water reports.
Returns
A copy of the updated alarm if it should be reported, an empty pointer otherwise.

Definition at line 43 of file alarm_store.cc.

References isc_throw.

◆ clear()

void isc::perfmon::AlarmStore::clear ( )

Removes all alarms from the store.

Definition at line 160 of file alarm_store.cc.

◆ deleteAlarm()

void isc::perfmon::AlarmStore::deleteAlarm ( DurationKeyPtr key)

Removes the alarm from the store.

If the alarm does not exist in the store, it simply returns.

Parameters
keykey value of the alarm to delete.

Definition at line 132 of file alarm_store.cc.

◆ getAlarm()

AlarmPtr isc::perfmon::AlarmStore::getAlarm ( DurationKeyPtr key)

Fetches a duration from the store for a given key.

Parameters
keykey value of the alarm to fetch.
Returns
Pointer the desired alarm or an empty pointer.

Definition at line 105 of file alarm_store.cc.

◆ getAll()

AlarmCollectionPtr isc::perfmon::AlarmStore::getAll ( )

Fetches all of the alarms (in order by target)

Returns
a collection of all alarms in the store.

Definition at line 148 of file alarm_store.cc.

◆ getFamily()

uint16_t isc::perfmon::AlarmStore::getFamily ( )
inline

Get protocol family.

Returns
uint16_t containing the family (AF_INET or AF_INET6)

Definition at line 157 of file alarm_store.h.

◆ updateAlarm()

void isc::perfmon::AlarmStore::updateAlarm ( AlarmPtr & alarm)

Updates an alarm in the store.

The alarm is assumed to already exist in the store.

Parameters
alarmalarm to update.
Exceptions
InvalidOperationif the alarm does not exist in the store.

Definition at line 116 of file alarm_store.cc.

References isc_throw.


The documentation for this class was generated from the following files: