22      mutex_(new std::mutex) {
 
   23    if (family_ != AF_INET && family_ != AF_INET6) {
 
   25                            << family_ << 
", must be AF_INET or AF_INET6");
 
 
   30AlarmStore::validateKey(
const std::string& label, 
DurationKeyPtr key)
 const {
 
   35    if (key->getFamily() != family_) {
 
   37                            << 
" - family mismatch, key is " << (family_ == AF_INET ?
 
   38                            "v6, store is v4" : 
"v4, store is v6"));
 
   45    validateKey(
"checkDurationSample", key);
 
   49    auto alarm_iter = index.find(*key);
 
   53    if (alarm_iter != index.end()) {
 
   54        bool should_report = 
false;
 
   55        bool modified = index.modify(alarm_iter,
 
   56                                     [sample, report_interval, &should_report](
AlarmPtr alarm) {
 
   57            should_report = alarm->checkSample(sample, report_interval);
 
   62            isc_throw(
Unexpected, 
"AlarmStore::checkDurationSample - modify failed for: " << key->getLabel());
 
 
   78    auto ret = alarms_.insert(alarm);
 
   79    if (ret.second == 
false) {
 
   81                  << alarm->getLabel());
 
 
   90                     const Duration& high_water, 
bool enabled ) {
 
   91    validateKey(
"addAlarm", key);
 
   96        alarm.reset(
new Alarm(*key, low_water, high_water, enabled));
 
   97    } 
catch (
const std::exception& ex) {
 
 
  106    validateKey(
"getAlarm", key);
 
  110    auto alarm_iter = index.find(*key);
 
  111    return (alarm_iter == index.end() ? 
AlarmPtr()
 
 
  117    validateKey(
"updateAlarm", alarm);
 
  121    auto alarm_iter = index.find(*alarm);
 
  122    if (alarm_iter == index.end()) {
 
  124                  << alarm->getLabel());
 
 
  133    validateKey(
"deleteAlarm", key);
 
  137    auto alarm_iter = index.find(*key);
 
  138    if (alarm_iter == index.end()) {
 
  144    alarms_.erase(alarm_iter);
 
 
  152    for (
auto const& alarm : index) {
 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown when an unexpected error condition occurs.
AlarmStore(uint16_t family)
Constructor.
AlarmPtr checkDurationSample(DurationKeyPtr key, const Duration &sample, const Duration &report_interval)
Checks a sample against an alarm.
void updateAlarm(AlarmPtr &alarm)
Updates an alarm in the store.
void deleteAlarm(DurationKeyPtr key)
Removes the alarm from the store.
AlarmCollectionPtr getAll()
Fetches all of the alarms (in order by target)
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 getAlarm(DurationKeyPtr key)
Fetches a duration from the store for a given key.
void clear()
Removes all alarms from the store.
Defines an alarm for a duration.
Exception thrown when an attempt was made to add a duplicate key to either the duration or alarm stor...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::posix_time::time_duration Duration
boost::shared_ptr< DurationKey > DurationKeyPtr
Defines a pointer to a DurationKey instance.
std::vector< AlarmPtr > AlarmCollection
Type for a collection of AlarmPtrs.
boost::shared_ptr< AlarmCollection > AlarmCollectionPtr
Type for a pointer to a collection of AlarmPtrs.
boost::shared_ptr< Alarm > AlarmPtr
Defines a pointer to an Alarm instance.
Defines the logger used by the top-level component of kea-lfc.
Tag for index by primary key (DurationKey).
RAII lock object to protect the code in the same scope with a mutex.