18using namespace std::chrono;
25 uint32_t min_echos, uint32_t reply_timeout,
31 context.reset(
new PingContext(lease, query, min_echos, reply_timeout, parking_lot));
32 }
catch (
const std::exception& ex) {
36 context->beginWaitingToSend();
37 auto ret = pings_.insert(context);
38 if (ret.second ==
false) {
50 auto context_iter = index.find(context->getTarget());
51 if (context_iter == index.end()) {
53 << context->getTarget() <<
", not in store");
64 auto context_iter = index.find(context->getTarget());
65 if (context_iter == index.end()) {
71 pings_.erase(context_iter);
78 auto context_iter = index.find(address);
87 auto context_iter = index.find(query);
105 auto context_iter = index.lower_bound(boost::make_tuple(
true,
PingContext::now() + milliseconds(1)));
115 auto upper_limit = index.upper_bound(boost::make_tuple(
true, since));
118 for (
auto context_iter = lower_limit; context_iter != upper_limit; ++context_iter) {
120 collection->push_back(context);
131 for (
auto const& context_iter : 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.
The IOAddress class represents an IP addresses (version agnostic)
Exception thrown when an attempt was made to add a duplicate context.
void clear()
Removes all contexts from the store.
PingContextPtr getContextByQuery(isc::dhcp::Pkt4Ptr &query)
Fetches the context with a given query packet.
PingContextPtr getContextByAddress(const isc::asiolink::IOAddress &address)
Fetches the context with a given target address.
PingContextPtr addContext(isc::dhcp::Lease4Ptr &lease, isc::dhcp::Pkt4Ptr &query, uint32_t min_echos, uint32_t reply_timeout, isc::hooks::ParkingLotHandlePtr &parking_lot=PingContext::EMPTY_LOT())
Creates a new PingContext and adds it to the store.
PingContextCollectionPtr getAll()
Fetches all of the contexts (in order by target)
PingContextCollectionPtr getExpiredSince(const TimeStamp &since=PingContext::now())
Fetches the contexts in WAITING_FOR_REPLY that expired since a given time.
void deleteContext(const PingContextPtr &context)
Removes the context from the store.
PingContextPtr getNextToSend()
Fetches the context in WAITING_TO_SEND with the oldest send wait start time.
PingContextPtr getExpiresNext()
Fetches the context in WAITING_FOR_REPLY with the oldest expiration time that has not already passed ...
void updateContext(const PingContextPtr &context)
Updates a context in the store.
Embodies the life cycle of a ping check test for a single address for a single DHCPDISCOVER.
static const TimeStamp & MIN_TIME()
Fetches the minimum timestamp.
static TimeStamp now()
Fetches the current timestamp (UTC/milliseconds precision)
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
boost::shared_ptr< PingContextCollection > PingContextCollectionPtr
Type for a pointer to a collection of PingContextPtrs.
std::vector< PingContextPtr > PingContextCollection
Type for a collection of PingContextPtrs.
std::chrono::time_point< std::chrono::system_clock > TimeStamp
Specifies the type for time stamps.
boost::shared_ptr< PingContext > PingContextPtr
Defines a shared pointer to a PingContext.
Defines the logger used by the top-level component of kea-lfc.
Tag for index by target address.
Tag for index by expiration time.
Tag for index by send wait start time.
Tag for index by the query packet.
RAII lock object to protect the code in the same scope with a mutex.