19 const ClassCountMap& leases_by_class = getConstCountMap(ltype);
20 auto it = leases_by_class.find(client_class);
21 if (it == leases_by_class.end()) {
33 leases_by_class[client_class] = count;
40 auto it = leases_by_class.find(client_class);
41 if (it == leases_by_class.end()) {
43 leases_by_class[client_class] = offset < 0 ? 0 : offset;
45 size_t new_count = it->second + offset;
46 if (offset < 0 && (new_count > it->second)) {
50 it->second = new_count;
63 auto ctx = lease->getContext();
66 classes = ctx->find(
"ISC/client-classes");
71 }
catch (
const std::exception& ex) {
86 for (
int i = 0; i < classes->size(); ++i) {
87 std::string class_name = classes->get(i)->stringValue();
121 uint32_t new_state = new_lease->state_;
124 uint32_t old_state = old_lease->state_;
130 if ((old_state != new_state) || (old_classes != new_classes)) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void adjustClassCounts(data::ConstElementPtr classes, int offset, const Lease::Type <ype=Lease::TYPE_V4)
Adjust the count for a list of classes for a lease type by a signed offset.
void addLease(LeasePtr lease)
Increment the counts for all of a lease's classes by one.
void removeLease(LeasePtr lease)
Decrement the counts for all of a lease's classes by one.
static data::ConstElementPtr getLeaseClientClasses(LeasePtr lease)
Fetches the list of classes from the lease's user-context.
void updateLease(LeasePtr new_lease, LeasePtr old_lease)
Adjust class lease counts given a new and old version of a lease.
void setClassCount(const ClientClass &client_class, size_t count, const Lease::Type <ype=Lease::TYPE_V4)
Sets the lease count for the given class and lease type to a value.
size_t getClassCount(const ClientClass &client_class, const Lease::Type <ype=Lease::TYPE_V4) const
Fetches the lease count for the given class and lease type.
void adjustClassCount(const ClientClass &client_class, int offset, const Lease::Type <ype=Lease::TYPE_V4)
Adjust the count for a given class and lease type by a signed offset.
std::unordered_map< ClientClass, size_t > ClassCountMap
Defines ClassCountMap as an unordered map of counts.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
boost::shared_ptr< const Element > ConstElementPtr
std::string ClientClass
Defines a single class name.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
Defines the logger used by the top-level component of kea-lfc.
static const uint32_t STATE_DEFAULT
A lease in the default state.
Type
Type of lease or pool.