7#ifndef MONITORED_DURATION_STORE_H
8#define MONITORED_DURATION_STORE_H
13#include <boost/multi_index/indexed_by.hpp>
14#include <boost/multi_index/member.hpp>
15#include <boost/multi_index/mem_fun.hpp>
16#include <boost/multi_index/ordered_index.hpp>
17#include <boost/multi_index_container.hpp>
18#include <boost/multi_index/composite_key.hpp>
19#include <boost/multi_index/sequenced_index.hpp>
20#include <boost/multi_index/identity.hpp>
21#include <boost/scoped_ptr.hpp>
51typedef boost::multi_index_container<
54 boost::multi_index::indexed_by<
57 boost::multi_index::ordered_unique<
58 boost::multi_index::tag<DurationKeyTag>,
59 boost::multi_index::composite_key<
62 boost::multi_index::const_mem_fun<
DurationKey, uint8_t,
65 boost::multi_index::const_mem_fun<
DurationKey, uint8_t,
68 boost::multi_index::const_mem_fun<
DurationKey, std::string,
71 boost::multi_index::const_mem_fun<
DurationKey, std::string,
81 boost::multi_index::ordered_non_unique<
82 boost::multi_index::tag<IntervalStartTag>,
201 void validateKey(
const std::string& label,
DurationKeyPtr key)
const;
214 const boost::scoped_ptr<std::mutex> mutex_;
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static boost::posix_time::ptime now()
Fetch the current UTC system time, microsecond precision.
Exception thrown when an attempt was made to add a duplicate duration to the store.
DuplicateDurationKey(const char *file, size_t line, const char *what)
Houses the composite key that uniquely identifies a duration:
std::string getStartEventLabel() const
Get the start event label.
std::string getStopEventLabel() const
Get the end event label.
uint8_t getResponseType() const
Get the response packet type.
dhcp::SubnetID getSubnetId() const
Get the subnet id.
uint8_t getQueryType() const
Get the query packet type.
Maintains an in-memory store of durations.
MonitoredDurationCollectionPtr getOverdueReports(const Timestamp &since=dhcp::PktEvent::now())
Fetches all durations that are overdue to report.
void deleteDuration(DurationKeyPtr key)
Removes the duration from the store.
~MonitoredDurationStore()=default
Destructor.
MonitoredDurationPtr addDuration(DurationKeyPtr key)
Creates a new duration and adds it to the store.
MonitoredDurationStore(uint16_t family, const Duration &interval_duration)
Constructor.
MonitoredDurationCollectionPtr getAll()
Fetches all of the durations (in order by target)
void clear()
Removes all durations from the store.
MonitoredDurationPtr getReportsNext()
Fetches the duration which is due to report next.
uint16_t getFamily()
Get protocol family.
MonitoredDurationPtr getDuration(DurationKeyPtr key)
Fetches a duration from the store for a given key.
MonitoredDurationPtr addDurationSample(DurationKeyPtr key, const Duration &sample)
Adds a sample to a duration in-place.
void updateDuration(MonitoredDurationPtr &duration)
Updates a duration in the store.
Timestamp getCurrentIntervalStart() const
Get the current interval start time.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::posix_time::time_duration Duration
boost::shared_ptr< MonitoredDurationCollection > MonitoredDurationCollectionPtr
Type for a pointer to a collection of MonitoredDurationPtrs.
boost::shared_ptr< DurationKey > DurationKeyPtr
Defines a pointer to a DurationKey instance.
boost::shared_ptr< MonitoredDurationStore > MonitoredDurationStorePtr
boost::multi_index_container< MonitoredDurationPtr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< DurationKeyTag >, boost::multi_index::composite_key< MonitoredDuration, boost::multi_index::const_mem_fun< DurationKey, uint8_t, &DurationKey::getQueryType >, boost::multi_index::const_mem_fun< DurationKey, uint8_t, &DurationKey::getResponseType >, boost::multi_index::const_mem_fun< DurationKey, std::string, &DurationKey::getStartEventLabel >, boost::multi_index::const_mem_fun< DurationKey, std::string, &DurationKey::getStopEventLabel >, boost::multi_index::const_mem_fun< DurationKey, dhcp::SubnetID, &DurationKey::getSubnetId > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< IntervalStartTag >, boost::multi_index::const_mem_fun< MonitoredDuration, Timestamp, &MonitoredDuration::getCurrentIntervalStart > > > > MonitoredDurationContainer
A multi index container holding pointers to durations.
boost::posix_time::ptime Timestamp
boost::shared_ptr< MonitoredDuration > MonitoredDurationPtr
std::vector< MonitoredDurationPtr > MonitoredDurationCollection
Type for a collection of MonitoredDurationPtrs.
Defines the logger used by the top-level component of kea-lfc.
Tag for index by primary key (DurationKey).
Tag for index by interval start time.