16using namespace boost::posix_time;
23 uint8_t response_type,
24 const std::string& start_event_label,
25 const std::string& stop_event_label,
30 :
DurationKey(family, query_type, response_type, start_event_label, stop_event_label, subnet_id),
31 low_water_(low_water),
32 high_water_(high_water),
33 state_(enabled ? CLEAR : DISABLED),
35 last_high_water_report_(
PktEvent::EMPTY_TIME()) {
36 if (low_water >= high_water_) {
38 <<
", must be less than high water: " << high_water_);
47 low_water_(low_water),
48 high_water_(high_water),
49 state_(enabled ? CLEAR : DISABLED),
51 last_high_water_report_(
PktEvent::EMPTY_TIME()) {
52 if (low_water >= high_water_) {
54 <<
", must be less than high water: " << high_water_);
60 if (low_water >= high_water_) {
62 <<
", must be less than high water: " << high_water_);
65 low_water_ = low_water;
70 if (high_water <= low_water_) {
72 <<
", must be greater than low water: " << low_water_);
75 high_water_ = high_water;
99 "- should not be called when alarm is DISABLED");
103 if (sample < low_water_) {
116 if (sample > high_water_) {
128 ((now - last_high_water_report_) > report_interval)) {
129 last_high_water_report_ = now;
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.
Describes an event during the life cycle of a packet.
static boost::posix_time::ptime now()
Fetch the current UTC system time, microsecond precision.
static boost::posix_time::ptime & EMPTY_TIME()
Fetch an empty timestamp, used for logic comparisons.
void setHighWater(const Duration &high_water)
Set the high water threshold.
void clear()
Sets the alarm back to the CLEAR state.
void setState(State state)
Sets the alarm state.
bool checkSample(const Duration &sample, const Duration &report_interval)
Checks a duration against the high and low water thresholds and calls the appropriate event handler.
void disable()
Disables the alarm by setting the state to DISABLED.
void setLowWater(const Duration &low_water)
Set the low water threshold.
Alarm(uint16_t family, uint8_t query_type, uint8_t response_type, const std::string &start_event_label, const std::string &stop_event_label, dhcp::SubnetID subnet_id, const Duration &low_water, const Duration &high_water, bool enabled=true)
Constructor.
State
Defines Alarm states.
Houses the composite key that uniquely identifies a duration:
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::posix_time::time_duration Duration
Defines the logger used by the top-level component of kea-lfc.