29 #include <boost/make_shared.hpp>
38 static constexpr
size_t HOSTNAME_MAX_LEN = 255u;
39 static constexpr
size_t ADDRESS6_TEXT_MAX_LEN = 39u;
40 static constexpr
char NULL_USER_CONTEXT[] =
"";
55 : connection_(connection), valid_lifetime_(0), expire_(0),
56 current_expire_(0), subnet_id_(0), fqdn_fwd_(cass_false),
57 fqdn_rev_(cass_false), state_(0), user_context_(NULL_USER_CONTEXT) {
77 virtual boost::any retrieve()
override = 0;
167 void createBindForDelete(
const Lease4Ptr &lease,
183 virtual boost::any retrieve()
override;
208 void getExpiredLeases(
const size_t &max_leases,
Lease4Collection &expired_leases);
228 static constexpr
StatementTag GET_LEASE4_CLIENTID =
"GET_LEASE4_CLIENTID";
230 static constexpr
StatementTag GET_LEASE4_CLIENTID_SUBID =
"GET_LEASE4_CLIENTID_SUBID";
234 static constexpr
StatementTag GET_LEASE4_HWADDR_SUBID =
"GET_LEASE4_HWADDR_SUBID";
242 static constexpr
StatementTag GET_LEASE4_HOSTNAME =
"GET_LEASE4_HOSTNAME";
250 cass_int32_t address_;
255 constexpr
StatementTag CqlLease4Exchange::INSERT_LEASE4;
256 constexpr
StatementTag CqlLease4Exchange::UPDATE_LEASE4;
257 constexpr
StatementTag CqlLease4Exchange::DELETE_LEASE4;
258 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_EXPIRE;
260 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_ADDR;
261 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_CLIENTID;
262 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_CLIENTID_SUBID;
263 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_HWADDR;
264 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_HWADDR_SUBID;
265 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_LIMIT;
266 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_PAGE;
267 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_SUBID;
268 constexpr
StatementTag CqlLease4Exchange::GET_LEASE4_HOSTNAME;
275 "INSERT INTO lease4( "
276 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
277 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
279 "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "
291 "valid_lifetime = ?, "
305 "DELETE FROM lease4 "
314 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
315 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
318 "AND valid_lifetime < 4294967295 "
328 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
329 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
337 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
338 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
344 {GET_LEASE4_CLIENTID,
345 {GET_LEASE4_CLIENTID,
347 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
348 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
350 "WHERE client_id = ? "
355 {GET_LEASE4_CLIENTID_SUBID,
356 {GET_LEASE4_CLIENTID_SUBID,
358 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
359 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
361 "WHERE client_id = ? "
370 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
371 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
378 {GET_LEASE4_HWADDR_SUBID,
379 {GET_LEASE4_HWADDR_SUBID,
381 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
382 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
393 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
394 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
404 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
405 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
407 "WHERE TOKEN(address) > TOKEN(?) "
416 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
417 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
419 "WHERE subnet_id = ? "
420 "ALLOW FILTERING "}},
423 {GET_LEASE4_HOSTNAME,
424 {GET_LEASE4_HOSTNAME,
426 "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
427 "fqdn_fwd, fqdn_rev, hostname, state, user_context "
429 "WHERE hostname = ? "
442 "Lease4 object is NULL");
453 address_ =
static_cast<cass_int32_t
>(lease->addr_.toUint32());
456 if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
460 << lease_->hwaddr_->toText() <<
" of length "
461 << lease_->hwaddr_->hwaddr_.size()
462 <<
" exceeds maximum allowed length of "
465 hwaddr_ = lease_->hwaddr_->hwaddr_;
471 if (lease_->client_id_ && lease_->client_id_->getClientId().size() > 0) {
472 client_id_ = lease_->client_id_->getClientId();
490 subnet_id_ =
static_cast<cass_int32_t
>(lease_->subnet_id_);
493 fqdn_fwd_ = lease_->fqdn_fwd_ ? cass_true : cass_false;
496 fqdn_rev_ = lease_->fqdn_rev_ ? cass_true : cass_false;
499 if (lease_->hostname_.size() > HOSTNAME_MAX_LEN) {
501 "hostname " << lease_->hostname_ <<
" of length "
502 << lease_->hostname_.size()
503 <<
" exceeds maximum allowed length of "
504 << HOSTNAME_MAX_LEN);
509 state_ =
static_cast<cass_int32_t
>(lease_->state_);
523 data.
add(&client_id_);
535 "could not create bind array from Lease4: " << lease_->addr_.toText()
536 <<
", reason: " << ex.
what());
545 "Lease4 object is NULL");
556 address_ =
static_cast<cass_int32_t
>(lease->addr_.toUint32());
559 if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
563 << lease_->hwaddr_->toText() <<
" of length "
564 << lease_->hwaddr_->hwaddr_.size()
565 <<
" exceeds maximum allowed length of "
568 hwaddr_ = lease_->hwaddr_->hwaddr_;
574 if (lease_->client_id_ && lease_->client_id_->getClientId().size() > 0) {
575 client_id_ = lease_->client_id_->getClientId();
593 subnet_id_ =
static_cast<cass_int32_t
>(lease_->subnet_id_);
596 fqdn_fwd_ = lease_->fqdn_fwd_ ? cass_true : cass_false;
599 fqdn_rev_ = lease_->fqdn_rev_ ? cass_true : cass_false;
602 if (lease_->hostname_.size() > HOSTNAME_MAX_LEN) {
604 "hostname " << lease_->hostname_ <<
" of length "
605 << lease_->hostname_.size()
606 <<
" exceeds maximum allowed length of "
607 << HOSTNAME_MAX_LEN);
612 state_ =
static_cast<cass_int32_t
>(lease_->state_);
625 data.
add(&client_id_);
637 lease_->current_valid_lft_,
642 "CqlLease4Exchange::createBindUpdate(): "
643 "could not create bind array from Lease4: "
644 << lease_->addr_.toText() <<
", reason: " << ex.
what());
653 "Lease4 object is NULL");
662 address_ =
static_cast<cass_int32_t
>(lease_->addr_.toUint32());
669 lease_->current_valid_lft_,
674 "CqlLease4Exchange::createBindForDelete(): "
675 "could not create bind array from Lease4: "
676 << lease_->addr_.toText() <<
", reason: " << ex.
what());
692 data.
add(&client_id_);
727 <<
" of length " <<
hwaddr_.size()
728 <<
" exceeds maximum allowed length of "
733 "client ID " <<
ClientId(client_id_).toText()
734 <<
" of length " << client_id_.size()
735 <<
" exceeds maximum allowed length of "
738 if (
hostname_.size() > HOSTNAME_MAX_LEN) {
742 <<
" exceeds maximum allowed length of "
743 << HOSTNAME_MAX_LEN);
751 uint32_t addr4 =
static_cast<uint32_t
>(address_);
756 if (!ctx || (ctx->getType() != Element::map)) {
758 <<
"' is not a JSON map");
762 Lease4Ptr result(boost::make_shared<Lease4>(addr4, hwaddr, client_id_.data(),
770 result->setContext(ctx);
776 "CqlLease4Exchange::retrieve(): "
777 "could not convert data to Lease4, reason: "
788 for (boost::any &element : collection) {
789 result.push_back(boost::any_cast<Lease4Ptr>(element));
802 const size_t collection_size = collection.size();
803 if (collection_size >= 2u) {
805 "CqlLease4Exchange::getLease(): multiple records were found in "
806 "the database where only one was expected for statement "
808 }
else if (collection_size == 0u) {
811 result = *collection.begin();
820 cass_int64_t timestamp =
static_cast<cass_int64_t
>(time(NULL));
824 cass_int32_t limit = max_leases > 0u ?
static_cast<cass_int32_t
>(max_leases) :
825 std::numeric_limits<cass_int32_t>::max();
829 if (state == keep_state) {
835 data.
add(×tamp);
843 for (
Lease4Ptr &lease : temp_collection) {
844 expired_leases.push_back(lease);
917 virtual boost::any
retrieve()
override;
968 std::string address_;
971 cass_int64_t pref_lifetime_;
980 cass_int32_t lease_type_;
983 cass_int32_t prefix_len_;
986 cass_int32_t hwtype_;
989 cass_int32_t hwaddr_source_;
1009 "INSERT INTO lease6("
1010 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1011 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1012 "hwaddr_source, state, user_context "
1014 "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?"
1022 "UPDATE lease6 SET "
1023 "valid_lifetime = ?, "
1025 "pref_lifetime = ?, "
1036 "hwaddr_source = ?, "
1039 "WHERE address = ? "
1046 "DELETE FROM lease6 "
1047 "WHERE address = ? "
1055 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1056 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1057 "hwaddr_source, state, user_context "
1060 "AND valid_lifetime < 4294967295 "
1070 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1071 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1072 "hwaddr_source, state, user_context "
1074 "WHERE address = ? "
1075 "AND lease_type = ? "
1083 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1084 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1085 "hwaddr_source, state, user_context "
1092 {GET_LEASE6_DUID_IAID,
1093 {GET_LEASE6_DUID_IAID,
1095 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1096 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1097 "hwaddr_source, state, user_context "
1099 "WHERE duid = ? AND iaid = ? "
1100 "AND lease_type = ? "
1105 {GET_LEASE6_DUID_IAID_SUBID,
1106 {GET_LEASE6_DUID_IAID_SUBID,
1108 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1109 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1110 "hwaddr_source, state, user_context "
1112 "WHERE duid = ? AND iaid = ? "
1113 "AND lease_type = ? "
1114 "AND subnet_id = ? "
1122 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1123 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1124 "hwaddr_source, state, user_context "
1134 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1135 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1136 "hwaddr_source, state, user_context "
1138 "WHERE TOKEN(address) > TOKEN(?) "
1144 {GET_LEASE6_HOSTNAME,
1145 {GET_LEASE6_HOSTNAME,
1147 "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
1148 "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
1149 "hwaddr_source, state, user_context "
1151 "WHERE hostname = ? "
1157 :
CqlLeaseExchange(connection), pref_lifetime_(0), iaid_(0), lease_type_(0),
1158 prefix_len_(0), hwtype_(0), hwaddr_source_(0) {
1165 "Lease6 object is NULL");
1174 address_ = lease_->addr_.toText();
1175 if (address_.size() > ADDRESS6_TEXT_MAX_LEN) {
1177 <<
" exceeds maximum allowed length of " << ADDRESS6_TEXT_MAX_LEN);
1193 subnet_id_ =
static_cast<cass_int32_t
>(lease_->subnet_id_);
1196 pref_lifetime_ =
static_cast<cass_int64_t
>(lease_->preferred_lft_);
1199 if (!lease_->duid_) {
1201 <<
" is missing mandatory duid");
1203 duid_ = lease_->duid_->getDuid();
1206 iaid_ =
static_cast<cass_int32_t
>(lease_->iaid_);
1209 lease_type_ =
static_cast<cass_int32_t
>(lease_->type_);
1212 prefix_len_ =
static_cast<cass_int32_t
>(lease_->prefixlen_);
1215 fqdn_fwd_ = lease_->fqdn_fwd_ ? cass_true : cass_false;
1218 fqdn_rev_ = lease_->fqdn_rev_ ? cass_true : cass_false;
1221 if (lease_->hostname_.size() > HOSTNAME_MAX_LEN) {
1223 << lease_->hostname_.size() <<
" exceeds maximum allowed length of "
1224 << HOSTNAME_MAX_LEN);
1229 if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
1232 <<
" of length " << lease_->hwaddr_->hwaddr_.size()
1235 hwaddr_ = lease_->hwaddr_->hwaddr_;
1241 if (lease_->hwaddr_) {
1242 hwtype_ =
static_cast<cass_int32_t
>(lease_->hwaddr_->htype_);
1248 if (lease_->hwaddr_) {
1249 hwaddr_source_ =
static_cast<cass_int32_t
>(lease_->hwaddr_->source_);
1255 state_ =
static_cast<cass_int32_t
>(lease_->state_);
1269 data.
add(&address_);
1273 data.
add(&pref_lifetime_);
1276 data.
add(&lease_type_);
1277 data.
add(&prefix_len_);
1283 data.
add(&hwaddr_source_);
1289 "could not create bind array from Lease6: " << lease_->addr_.toText()
1290 <<
", reason: " << ex.
what());
1299 "Lease6 object is NULL");
1308 address_ = lease_->addr_.toText();
1309 if (address_.size() > ADDRESS6_TEXT_MAX_LEN) {
1311 "address " << address_ <<
" of length " << address_.size()
1312 <<
" exceeds maximum allowed length of "
1313 << ADDRESS6_TEXT_MAX_LEN);
1329 subnet_id_ =
static_cast<cass_int32_t
>(lease_->subnet_id_);
1332 pref_lifetime_ =
static_cast<cass_int64_t
>(lease_->preferred_lft_);
1335 if (!lease_->duid_) {
1337 "lease6 with address " << address_
1338 <<
" is missing mandatory duid");
1340 duid_ = lease_->duid_->getDuid();
1343 iaid_ =
static_cast<cass_int32_t
>(lease_->iaid_);
1346 lease_type_ =
static_cast<cass_int32_t
>(lease_->type_);
1349 prefix_len_ =
static_cast<cass_int32_t
>(lease_->prefixlen_);
1352 fqdn_fwd_ = lease_->fqdn_fwd_ ? cass_true : cass_false;
1355 fqdn_rev_ = lease_->fqdn_rev_ ? cass_true : cass_false;
1358 if (lease_->hostname_.size() > HOSTNAME_MAX_LEN) {
1360 "hostname" << lease_->hostname_ <<
" of length "
1361 << lease_->hostname_.size()
1362 <<
" exceeds maximum allowed length of "
1363 << HOSTNAME_MAX_LEN);
1368 if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
1372 << lease_->hwaddr_->toText() <<
" of length "
1373 << lease_->hwaddr_->hwaddr_.size()
1374 <<
" exceeds maximum allowed length of "
1377 hwaddr_ = lease_->hwaddr_->hwaddr_;
1383 if (lease_->hwaddr_) {
1384 hwtype_ =
static_cast<cass_int32_t
>(lease_->hwaddr_->htype_);
1390 if (lease_->hwaddr_) {
1391 hwaddr_source_ =
static_cast<cass_int32_t
>(lease_->hwaddr_->source_);
1397 state_ =
static_cast<cass_int32_t
>(lease_->state_);
1413 data.
add(&pref_lifetime_);
1417 data.
add(&lease_type_);
1418 data.
add(&prefix_len_);
1424 data.
add(&hwaddr_source_);
1427 data.
add(&address_);
1430 lease_->current_valid_lft_,
1435 "CqlLease6Exchange::createBindForUpdate(): "
1436 "could not create bind array from Lease6: "
1437 << lease_->addr_.toText() <<
", reason: " << ex.
what());
1446 "Lease6 object is NULL");
1455 address_ = lease_->addr_.toText();
1456 if (address_.size() > ADDRESS6_TEXT_MAX_LEN) {
1458 "address " << address_ <<
" of length " << address_.size()
1459 <<
" exceeds maximum allowed length of "
1460 << ADDRESS6_TEXT_MAX_LEN);
1465 data.
add(&address_);
1468 lease_->current_valid_lft_,
1473 "CqlLease6Exchange::createBindForDelete(): "
1474 "could not create bind array from Lease6: "
1475 << lease_->addr_.toText() <<
", reason: " << ex.
what());
1485 data.
add(&address_);
1497 data.
add(&pref_lifetime_);
1506 data.
add(&lease_type_);
1509 data.
add(&prefix_len_);
1527 data.
add(&hwaddr_source_);
1540 if (address_.size() > ADDRESS6_TEXT_MAX_LEN) {
1542 "address " << address_ <<
" of length " << address_.size()
1543 <<
" exceeds maximum allowed length of "
1544 << ADDRESS6_TEXT_MAX_LEN);
1548 "duid " <<
DUID(duid_).toText() <<
" of length "
1550 <<
" exceeds maximum allowed length of "
1556 "invalid lease type "
1557 << lease_type_ <<
" for lease with address "
1558 << address_ <<
". Expected 0, 1 or 2.");
1560 if (
hostname_.size() > HOSTNAME_MAX_LEN) {
1562 "hostname " <<
hostname_ <<
" of length "
1564 <<
" exceeds maximum allowed length of "
1565 << HOSTNAME_MAX_LEN);
1570 <<
" of length " <<
hwaddr_.size()
1571 <<
" exceeds maximum allowed length of "
1577 DuidPtr duid(boost::make_shared<DUID>(duid_));
1581 hwaddr = boost::make_shared<HWAddr>(
hwaddr_, hwtype_);
1582 hwaddr->source_ = hwaddr_source_;
1588 if (!ctx ||(ctx->getType() != Element::map)) {
1590 <<
"' is not a JSON map");
1596 Lease6Ptr result(boost::make_shared<Lease6>(static_cast<Lease::Type>(lease_type_), addr, duid,
1599 hwaddr, prefix_len_));
1604 result->cltt_ = cltt;
1605 result->current_cltt_ = cltt;
1610 result->setContext(ctx);
1616 "CqlLease6Exchange::retrieve(): "
1617 "could not convert data to Lease6, reason: "
1629 for (boost::any &lease : collection) {
1630 result.push_back(boost::any_cast<Lease6Ptr>(lease));
1643 const size_t collection_size = collection.size();
1644 if (collection_size >= 2u) {
1646 "CqlLease6Exchange::getLease(): multiple records were found in "
1647 "the database where only one was expected for statement "
1649 }
else if (collection_size == 0u) {
1652 result = *collection.begin();
1661 cass_int64_t timestamp =
static_cast<cass_int64_t
>(time(NULL));
1665 cass_int32_t limit = max_leases > 0u ?
static_cast<cass_int32_t
>(max_leases) :
1666 std::numeric_limits<cass_int32_t>::max();
1670 if (state == keep_state) {
1676 data.
add(×tamp);
1684 for (
Lease6Ptr &lease : temp_collection) {
1685 expired_leases.push_back(lease);
1707 const bool fetch_type)
1708 : conn_(conn), statement_(statement), fetch_type_(fetch_type),
1709 cumulative_rows_(), next_row_(cumulative_rows_.begin()),
1710 subnet_id_(0), lease_type_(0), state_(0) {
1723 const bool fetch_type,
const SubnetID& subnet_id)
1725 fetch_type_(fetch_type), cumulative_rows_(),
1726 next_row_(cumulative_rows_.begin()),
1727 subnet_id_(0), lease_type_(0), state_(0) {
1742 const bool fetch_type,
const SubnetID& first_subnet_id,
1745 statement_(statement), fetch_type_(fetch_type), cumulative_rows_(),
1746 next_row_(cumulative_rows_.begin()),
1747 subnet_id_(0), lease_type_(0), state_(0) {
1846 std::map<LeaseStatsRow, int> cumulative_rows_;
1849 std::map<LeaseStatsRow, int>::iterator next_row_;
1852 cass_int32_t subnet_id_;
1855 cass_int32_t lease_type_;
1858 cass_int32_t state_;
1878 {SUBNET_LEASE4_STATS,
1879 {SUBNET_LEASE4_STATS,
1883 "WHERE subnet_id = ? "
1887 {SUBNET_RANGE_LEASE4_STATS,
1888 {SUBNET_RANGE_LEASE4_STATS,
1892 "WHERE subnet_id >= ? and subnet_id <= ? "
1900 "subnet_id, lease_type, state "
1905 {SUBNET_LEASE6_STATS,
1906 {SUBNET_LEASE6_STATS,
1908 "subnet_id, lease_type, state "
1910 "WHERE subnet_id = ? "
1914 {SUBNET_RANGE_LEASE6_STATS,
1915 {SUBNET_RANGE_LEASE6_STATS,
1917 "subnet_id, lease_type, state "
1919 "WHERE subnet_id >= ? and subnet_id <= ? "
1928 cass_int32_t first_subnet_id_data;
1929 cass_int32_t last_subnet_id_data;
1932 data.
add(&first_subnet_id_data);
1936 data.
add(&last_subnet_id_data);
1946 next_row_ = cumulative_rows_.begin();
1952 if (next_row_ == cumulative_rows_.end()) {
1957 row.
subnet_id_ = next_row_->first.subnet_id_;
1972 data.
add(&subnet_id_);
1974 data.
add(&lease_type_);
1984 CassStatement* statement = NULL;
1985 CassFuture* future = NULL;
1989 StatementMap::const_iterator it = connection.
statements_.find(statement_tag);
1992 "CqlLeastStatsQuery::executeSelect(): Statement "
1993 << statement_tag <<
"has not been prepared.");
1998 if (tagged_statement.
is_raw_) {
2000 std::string* query = boost::any_cast<std::string*>(local_data.back());
2001 local_data.pop_back();
2002 statement = cass_statement_new(query->c_str(), local_data.size());
2007 "CqlLeaseStatsQuery::executeSelect(): unable to bind statement "
2008 << tagged_statement.
name_);
2014 rc = cass_statement_set_consistency(statement, connection.
consistency_);
2015 if (rc != CASS_OK) {
2016 cass_statement_free(statement);
2018 "CqlLeaseStatsQuery::executeSelect(): unable to set statement "
2019 "consistency for statement "
2020 << tagged_statement.
name_
2021 <<
", Cassandra error code: " << cass_error_desc(rc));
2025 if (rc != CASS_OK) {
2026 cass_statement_free(statement);
2028 "CqlExchange::executeSelect(): unable to set statement "
2029 "serial consistency for statement "
2030 << tagged_statement.
name_
2031 <<
", Cassandra error code: " << cass_error_desc(rc));
2039 future = cass_session_execute(connection.
session_, statement);
2041 cass_statement_free(statement);
2043 "CqlLeaseStatsQuery::executeSelect(): no CassFuture for statement "
2044 << tagged_statement.
name_);
2048 cass_future_wait(future);
2050 "CqlLeaseStatsQuery::executeSelect(): cass_session_execute() != CASS_OK",
2051 future, statement_tag);
2052 rc = cass_future_error_code(future);
2053 if (rc != CASS_OK) {
2054 cass_future_free(future);
2055 cass_statement_free(statement);
2060 const CassResult* result_collection = cass_future_get_result(future);
2070 CassIterator* rows = cass_iterator_from_result(result_collection);
2071 while (cass_iterator_next(rows)) {
2072 const CassRow* row = cass_iterator_get_row(rows);
2081 LeaseStatsRow raw_row(subnet_id_, static_cast<Lease::Type>(lease_type_),
2084 auto cum_row = cumulative_rows_.find(raw_row);
2085 if (cum_row != cumulative_rows_.end()) {
2086 cumulative_rows_[raw_row] = cum_row->second + 1;
2088 cumulative_rows_.insert(std::make_pair(raw_row, 1));
2093 cass_iterator_free(rows);
2094 cass_result_free(result_collection);
2095 cass_future_free(future);
2096 cass_statement_free(statement);
2101 : parameters_(parameters), dbconn_(parameters) {
2105 std::pair<uint32_t, uint32_t> db_version =
getVersion();
2106 if (code_version != db_version) {
2108 << code_version.first <<
"." << code_version.second
2109 <<
" found version: " << db_version.first <<
"."
2110 << db_version.second);
2129 std::stringstream tmp;
2132 tmp <<
", library cassandra";
2139 .arg(lease->addr_.toText());
2144 exchange4->createBindForInsert(lease, data);
2146 exchange4->executeMutation(dbconn_, data, CqlLease4Exchange::INSERT_LEASE4);
2149 .arg(exception.
what());
2155 lease->updateCurrentExpirationTime();
2163 .arg(lease->addr_.toText());
2168 exchange6->createBindForInsert(lease, data);
2170 exchange6->executeMutation(dbconn_, data, CqlLease6Exchange::INSERT_LEASE6);
2173 .arg(exception.
what());
2179 lease->updateCurrentExpirationTime();
2192 cass_int32_t addr4 =
static_cast<cass_int32_t
>(addr.
toUint32());
2199 exchange4->getLease(CqlLease4Exchange::GET_LEASE4_ADDR, data, result);
2213 data.
add(&hwaddr_data);
2218 exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_HWADDR, data, result);
2234 data.
add(&hwaddr_data);
2236 cass_int32_t subnet_id_data =
static_cast<cass_int32_t
>(subnet_id);
2237 data.
add(&subnet_id_data);
2242 exchange4->getLease(CqlLease4Exchange::GET_LEASE4_HWADDR_SUBID, data, result);
2256 data.
add(&client_id_data);
2261 exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_CLIENTID, data, result);
2276 data.
add(&client_id_data);
2278 cass_int32_t subnet_id_data =
static_cast<cass_int32_t
>(subnet_id);
2279 data.
add(&subnet_id_data);
2284 exchange4->getLease(CqlLease4Exchange::GET_LEASE4_CLIENTID_SUBID, data, result);
2297 cass_int32_t subnet_id_data =
static_cast<cass_int32_t
>(subnet_id);
2298 data.
add(&subnet_id_data);
2303 exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_SUBID, data, result);
2316 std::string hostname_data(hostname);
2317 data.
add(&hostname_data);
2322 exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_HOSTNAME, data, result);
2337 exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4, data, result);
2346 if (!lower_bound_address.
isV4()) {
2348 "retrieving leases from the lease database, got "
2349 << lower_bound_address);
2356 if (page_size.
page_size_ > std::numeric_limits<uint32_t>::max()) {
2358 << std::numeric_limits<uint32_t>::max());
2363 .arg(lower_bound_address.
toText());
2367 cass_int32_t address_data = 0;
2368 if (!lower_bound_address.
isV4Zero()) {
2369 address_data =
static_cast<cass_int32_t
>(lower_bound_address.
toUint32());
2370 data.
add(&address_data);
2373 cass_int32_t page_size_data =
static_cast<cass_int32_t
>(page_size.
page_size_);
2374 data.
add(&page_size_data);
2379 exchange4->getLeaseCollection(lower_bound_address.
isV4Zero() ?
2380 CqlLease4Exchange::GET_LEASE4_LIMIT :
2389 std::string addr_data = addr.
toText();
2397 if (addr_data.size() > ADDRESS6_TEXT_MAX_LEN) {
2399 "CqlLeaseMgr::getLease6(): "
2401 << addr_data <<
" of length " << addr_data.size()
2402 <<
" exceeds maximum allowed length of "
2403 << ADDRESS6_TEXT_MAX_LEN);
2405 data.
add(&addr_data);
2407 cass_int32_t lease_type_data =
static_cast<cass_int32_t
>(lease_type);
2408 data.
add(&lease_type_data);
2412 exchange6->getLease(CqlLease6Exchange::GET_LEASE6_ADDR, data, result);
2425 data.
add(&duid_data);
2430 exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID,
2447 cass_int32_t iaid_data =
static_cast<cass_int32_t
>(iaid);
2449 data.
add(&duid_data);
2450 data.
add(&iaid_data);
2452 cass_int32_t lease_type_data =
static_cast<cass_int32_t
>(lease_type);
2453 data.
add(&lease_type_data);
2458 exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID, data, result);
2476 cass_int32_t iaid_data =
static_cast<cass_int32_t
>(iaid);
2478 data.
add(&duid_data);
2479 data.
add(&iaid_data);
2481 cass_int32_t lease_type_data =
static_cast<cass_int32_t
>(lease_type);
2482 data.
add(&lease_type_data);
2484 cass_int32_t subnet_id_data =
static_cast<cass_int32_t
>(subnet_id);
2485 data.
add(&subnet_id_data);
2490 exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID_SUBID, data, result);
2508 std::string hostname_data(hostname);
2509 data.
add(&hostname_data);
2514 exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_HOSTNAME, data, result);
2528 if (!lower_bound_address.
isV6()) {
2530 "retrieving leases from the lease database, got "
2531 << lower_bound_address);
2538 if (page_size.
page_size_ > std::numeric_limits<uint32_t>::max()) {
2540 << std::numeric_limits<uint32_t>::max());
2545 .arg(lower_bound_address.
toText());
2549 std::string lb_address_data;
2550 if (!lower_bound_address.
isV6Zero()) {
2551 lb_address_data = lower_bound_address.
toText();
2552 if (lb_address_data.size() > ADDRESS6_TEXT_MAX_LEN) {
2554 "CqlLeaseMgr::getLeases6(lower_bound_address, page_size): "
2556 << lb_address_data <<
" of length " << lb_address_data.size()
2557 <<
" exceeds maximum allowed length of "
2558 << ADDRESS6_TEXT_MAX_LEN);
2560 data.
add(&lb_address_data);
2563 cass_int32_t page_size_data =
static_cast<cass_int32_t
>(page_size.
page_size_);
2564 data.
add(&page_size_data);
2569 exchange6->getLeaseCollection(lower_bound_address.
isV6Zero() ?
2570 CqlLease6Exchange::GET_LEASE6_LIMIT :
2579 const size_t max_leases)
const {
2584 exchange4->getExpiredLeases(max_leases, expired_leases);
2589 const size_t max_leases)
const {
2594 exchange6->getExpiredLeases(max_leases, expired_leases);
2600 .arg(lease->addr_.toText());
2606 exchange4->createBindForUpdate(lease, data, CqlLease4Exchange::UPDATE_LEASE4);
2607 exchange4->executeMutation(dbconn_, data, CqlLease4Exchange::UPDATE_LEASE4);
2613 lease->updateCurrentExpirationTime();
2619 .arg(lease->addr_.toText());
2625 exchange6->createBindForUpdate(lease, data, CqlLease6Exchange::UPDATE_LEASE6);
2626 exchange6->executeMutation(dbconn_, data, CqlLease6Exchange::UPDATE_LEASE6);
2632 lease->updateCurrentExpirationTime();
2638 std::string addr_data = addr.
toText();
2645 std::unique_ptr<CqlLease4Exchange> exchange4(
2649 exchange4->createBindForDelete(lease, data, CqlLease4Exchange::DELETE_LEASE4);
2650 exchange4->executeMutation(dbconn_, data, CqlLease4Exchange::DELETE_LEASE4);
2653 .arg(exception.
what());
2662 std::string addr_data = addr.
toText();
2669 std::unique_ptr<CqlLease6Exchange> exchange6(
2673 exchange6->createBindForDelete(lease, data, CqlLease6Exchange::DELETE_LEASE6);
2674 exchange6->executeMutation(dbconn_, data, CqlLease6Exchange::DELETE_LEASE6);
2677 .arg(exception.
what());
2689 uint64_t deleted = 0u;
2690 cass_int32_t limit = 1024;
2697 cass_int64_t expiration =
static_cast<cass_int64_t
>(time(NULL) -
static_cast<time_t
>(secs));
2698 data.
add(&expiration);
2705 exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_EXPIRE, data, leases);
2720 uint64_t deleted = 0u;
2721 cass_int32_t limit = 1024;
2728 cass_int64_t expiration =
static_cast<cass_int64_t
>(time(NULL) -
static_cast<time_t
>(secs));
2729 data.
add(&expiration);
2736 exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_EXPIRE, data, leases);
2768 false, first_subnet_id, last_subnet_id));
2796 true, first_subnet_id, last_subnet_id));
2815 std::string name =
"";
2826 return std::string(
"Cassandra Database");
Database statement not applied.
void createBindForInsert(const Lease4Ptr &lease, AnyArray &data)
Create CQL_BIND objects for Lease4 Pointer.
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
virtual void createBindForSelect(AnyArray &data, StatementTag statement_tag=NULL) override
Create BIND array to receive data.
void createBindForDelete(const Lease4Ptr &lease, AnyArray &data, StatementTag statement_tag=NULL)
Create CQL_BIND objects for Lease4 Pointer.
const isc::log::MessageID DHCPSRV_CQL_COMMIT
static constexpr StatementTag GET_LEASE6_DUID_IAID
boost::shared_ptr< DUID > DuidPtr
const CqlConnection & connection_
Database connection.
StatementMap statements_
Pointer to external array of tagged statements containing statement name, array of names of bind para...
bool deleteLease(const Lease4Ptr &lease) overridefinal
Deletes an IPv4 lease.
uint32_t toUint32() const
Converts IPv4 address to uint32_t.
virtual void rollback() override
Rollback Transactions.
static std::pair< uint32_t, uint32_t > getVersion(const ParameterMap ¶meters)
Get the schema version.
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv6 leases.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
cass_bool_t fqdn_rev_
Has reverse DNS update been performed?
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs) override
Deletes all expired and reclaimed DHCPv4 leases.
CqlLeaseExchange(const CqlConnection &connection)
Constructor.
void start()
Creates the lease statistical data result set.
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
Base CQL derivation of the statistical lease data query.
A generic exception that is thrown when a function is not implemented.
static const uint32_t STATE_EXPIRED_RECLAIMED
Expired and reclaimed lease.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4() override
Creates and runs the IPv4 lease stats query.
SelectMode getSelectMode() const
Returns the selection criteria mode The value returned is based upon the constructor variant used and...
virtual void createBindForSelect(AnyArray &data, StatementTag statement_tag=NULL) override
Create BIND array to receive data.
const isc::log::MessageID DHCPSRV_CQL_DELETE_EXPIRED_RECLAIMED4
Structure used to bind C++ input values to dynamic CQL parameters.
virtual boost::any retrieve() override
Retrieves the Lease4 object in Kea format.
static constexpr StatementTag GET_LEASE6_LIMIT
StatementTag name_
Short description of the query.
virtual void commit()
Commit Transactions.
const isc::log::MessageID DHCPSRV_CQL_DELETE_ADDR
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override
Creates and runs the IPv4 lease stats query for a single subnet.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
const CassPrepared * prepared_statement_
Internal Cassandra object representing the prepared statement.
const isc::log::MessageID DHCPSRV_CQL_GET_VERSION
virtual bool addLease(const Lease4Ptr &lease) override
Adds an IPv4 lease.
const isc::log::MessageID DHCPSRV_CQL_GET4
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
static const size_t MAX_CLIENT_ID_LEN
Maximum size of a client ID.
static const size_t MAX_HWADDR_LEN
Maximum size of a hardware address.
bool force_consistency_
CQL consistency enabled.
Attempt to update lease that was not there.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
void prepareStatements(StatementMap &statements)
Prepare statements.
CassBlob hwaddr_
Hardware address.
void openDatabase()
Open database.
the lease contains IPv6 prefix (for prefix delegation)
static void getData(const CassRow *row, AnyArray &data)
Retrieves data returned by Cassandra.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs) override
Deletes all expired and reclaimed DHCPv6 leases.
std::vector< uint8_t > hwaddr_
const isc::log::MessageID DHCPSRV_CQL_GET_IAID_DUID
virtual void rollback()
Rollback Transactions.
Base class for fulfilling a statistical lease data query.
std::string toText(bool include_htype=true) const
Returns textual representation of a hardware address (e.g.
const isc::log::MessageID DHCPSRV_CQL_GET_PAGE6
Exchange Lease4 information between Kea and CQL.
Exchange Lease6 information between Kea and CQL.
const isc::log::MessageID DHCPSRV_CQL_LEASE_EXCEPTION_THROWN
void createBindForInsert(const Lease6Ptr &lease, AnyArray &data)
Create CQL_BIND objects for Lease6 Pointer.
const isc::log::MessageID DHCPSRV_CQL_GET_ADDR4
bool isV4() const
Convenience function to check for an IPv4 address.
const isc::log::MessageID DHCPSRV_CQL_ADD_ADDR6
static StatementMap tagged_statements_
Cassandra statements.
Holds DUID (DHCPv6 Unique Identifier)
static constexpr StatementTag GET_LEASE6_DUID_IAID_SUBID
Exception thrown on failure to open database.
char const *const StatementTag
Statement index representing the statement name.
virtual void updateLease6(const Lease6Ptr &lease6) override
Updates IPv6 lease.
const isc::log::MessageID DHCPSRV_CQL_GET_EXPIRED4
bool getNextRow(LeaseStatsRow &row)
Fetches the next row in the result set.
Multiple lease records found where one expected.
static constexpr StatementTag GET_LEASE6_EXPIRE
const isc::log::MessageID DHCPSRV_CQL_UPDATE_ADDR4
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id) override
Creates and runs the IPv4 lease stats query for a single subnet.
virtual Lease4Collection getLeases4() const override
Returns all IPv4 leases.
const size_t page_size_
Holds page size.
Defines a single statement or query.
virtual ~CqlLeaseStatsQuery()
Destructor.
static constexpr StatementTag SUBNET_RANGE_LEASE4_STATS
Return lease4 lease statistics for a range of subnets.
CqlLeaseStatsQuery(CqlConnection &conn, StatementTag &statement, const bool fetch_type)
Constructor to query for all subnets' stats.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
void add(const boost::any &value)
Add a value at the end of the vector.
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
virtual size_t wipeLeases4(const SubnetID &subnet_id) override
Removes specified IPv4 leases.
static void convertToDatabaseTime(const time_t &cltt, const uint32_t &valid_lifetime, cass_int64_t &expire)
CassConsistency consistency_
CQL consistency.
SubnetID last_subnet_id_
Last subnet_id in the selection criteria when a range is given.
const isc::log::MessageID DHCPSRV_CQL_GET_ADDR6
static constexpr StatementTag INSERT_LEASE6
Statement tags definitions.
std::vector< cass_byte_t > CassBlob
Host identifier converted to Cassandra data type.
CassSession * session_
CQL session handle.
const std::vector< uint8_t > & getClientId() const
Returns reference to the client-id data.
SubnetID subnet_id_
The subnet ID to which this data applies.
static std::string getDBVersion()
Local version of getDBVersion() class method.
cass_int64_t valid_lifetime_
Lease timer.
const isc::log::MessageID DHCPSRV_CQL_GET_CLIENTID
virtual void updateLease4(const Lease4Ptr &lease4) override
Updates IPv4 lease.
virtual ~CqlLeaseMgr()
Destructor (closes database)
const isc::log::MessageID DHCPSRV_CQL_GET_EXPIRED6
virtual size_t wipeLeases6(const SubnetID &subnet_id) override
Removed specified IPv6 leases.
boost::shared_ptr< const Element > ConstElementPtr
virtual VersionPair getVersion() const override
Returns backend version.
void createBindForUpdate(const Lease4Ptr &lease, AnyArray &data, StatementTag statement_tag=NULL)
Create CQL_BIND objects for Lease4 Pointer.
std::string user_context_
User context.
std::pair< uint32_t, uint32_t > VersionPair
Pair containing major and minor versions.
void createBindForDelete(const Lease6Ptr &lease, AnyArray &data, StatementTag statement_tag=NULL)
Create CQL_BIND objects for Lease4 Pointer.
CqlLeaseStatsQuery(CqlConnection &conn, StatementTag &statement, const bool fetch_type, const SubnetID &subnet_id)
Constructor to query for a single subnet's stats.
static constexpr StatementTag GET_LEASE6_PAGE
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
the lease contains temporary IPv6 address
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
virtual boost::any retrieve() override
Retrieves the Lease6 object in Kea format.
static constexpr StatementTag GET_LEASE6_HOSTNAME
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
void getExpiredLeases(const size_t &max_leases, Lease4Collection &expired_leases)
Returns expired leases.
virtual std::string getDescription() const override
Returns description of the backend.
cass_int64_t expire_
Lease expiry time.
the lease contains non-temporary IPv6 address
const isc::log::MessageID DHCPSRV_CQL_ROLLBACK
Invalid address family used as input to Lease Manager.
CqlLeaseStatsQuery(CqlConnection &conn, StatementTag &statement, const bool fetch_type, const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Constructor to query for the stats for a range of subnets.
void createBindForUpdate(const Lease6Ptr &lease, AnyArray &data, StatementTag statement_tag=NULL)
Create CQL_BIND objects for Lease6 Pointer.
This is a base class for exceptions thrown from the DNS library module.
constexpr uint32_t CQL_SCHEMA_VERSION_MAJOR
Define CQL schema version: 5.0.
Defines the logger used by the top-level component of kea-dhcp-ddns.
const isc::log::MessageID DHCPSRV_CQL_GET_SUBID_HWADDR
static void convertFromDatabaseTime(const cass_int64_t &expire, const cass_int64_t &valid_lifetime, time_t &cltt)
Converts time from Cassandra format.
CqlLeaseMgr(const db::DatabaseConnection::ParameterMap ¶meters)
Constructor.
static constexpr StatementTag SUBNET_LEASE6_STATS
Return lease6 lease statistics for a single subnet.
virtual void createBindForSelect(AnyArray &data, StatementTag statement_tag=NULL)
Create BIND array to receive C++ data.
std::string getParameter(const std::string &name) const
Returns value of a connection parameter.
void getExpiredLeases(const size_t &max_leases, Lease6Collection &expired_leases)
Returns expired leases.
std::string hostname_
Client hostname.
static const size_t MAX_DUID_LEN
maximum duid size As defined in RFC 8415, section 11.1
const isc::log::MessageID DHCPSRV_CQL_GET_HOSTNAME6
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const override
Returns existing IPv6 lease for a given IPv6 address.
uint32_t lease_state_
The lease_state to which the count applies.
Type
Type of lease or pool.
Holds Client identifier or client IPv4 address.
const isc::log::MessageID DHCPSRV_CQL_GET_SUBID_CLIENTID
static void bindData(const AnyArray &data, CassStatement *statement)
Assigns values to every column of an INSERT or an UPDATE statement.
void getLease(StatementTag &statement_tag, AnyArray &data, Lease4Ptr &result)
Retrieves one IPv4 lease.
static StatementMap tagged_statements_
Cassandra statements.
std::unordered_map< StatementTag, CqlTaggedStatement, StatementTagHash, StatementTagEqual > StatementMap
A container for all statements.
cass_int64_t current_expire_
Expiration time of lease before update.
CassConsistency serial_consistency_
CQL serial consistency.
const isc::log::MessageID DHCPSRV_CQL_GET_PAGE4
AnyArray executeSelect(const CqlConnection &connection, const AnyArray &where_values, StatementTag statement_tag, const bool &single=false)
Executes SELECT statements.
constexpr uint32_t CQL_SCHEMA_VERSION_MINOR
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
std::string toText() const
Convert the address to a string.
Hardware type that represents information from DHCPv4 packet.
static constexpr StatementTag DELETE_LEASE6
static StatementMap tagged_statements_
Cassandra statements.
static const uint32_t STATE_DEFAULT
A lease in the default state.
SubnetID first_subnet_id_
First (or only) subnet_id in the selection criteria.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
const isc::log::MessageID DHCPSRV_CQL_GET_HWADDR
static constexpr StatementTag GET_LEASE6_ADDR
static constexpr StatementTag ALL_LEASE6_STATS
virtual LeaseStatsQueryPtr startLeaseStatsQuery6() override
Creates and runs the IPv6 lease stats query.
int64_t state_count_
state_count The count of leases in the lease state
cass_int32_t state_
Lease state.
bool isV6() const
Convenience function to check for an IPv6 address.
cass_int32_t subnet_id_
Subnet identifier.
const isc::log::MessageID DHCPSRV_CQL_UPDATE_ADDR6
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
static const uint32_t STATE_DECLINED
Declined lease.
Contains a single row of lease statistical data.
Wraps value holding size of the page with leases.
void getLeaseCollection(StatementTag &statement_tag, AnyArray &data, Lease6Collection &result)
Retrieves zero or more IPv6 leases.
virtual std::string getName() const override
Returns name of the database.
Lease::Type lease_type_
The lease_type to which the count applies.
Common CQL connector pool.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
static constexpr StatementTag SUBNET_LEASE4_STATS
Return lease4 lease statistics for a single subnet.
static constexpr StatementTag SUBNET_RANGE_LEASE6_STATS
Return lease6 lease statistics for a range of subnets.
The IOAddress class represents an IP addresses (version agnostic)
const isc::log::MessageID DHCPSRV_CQL_DELETE_EXPIRED_RECLAIMED6
const isc::log::MessageID DHCPSRV_CQL_GET_HOSTNAME4
static constexpr StatementTag UPDATE_LEASE6
static const std::string checkFutureError(const std::string &what, CassFuture *future, StatementTag statement_tag=NULL)
Check for errors.
void getLease(StatementTag &statement_tag, AnyArray &data, Lease6Ptr &result)
Retrieves one IPv6 lease.
void getLeaseCollection(StatementTag &statement_tag, AnyArray &data, Lease4Collection &result)
Retrieves zero or more IPv4 leases.
static constexpr StatementTag GET_LEASE6_DUID
cass_bool_t fqdn_fwd_
Has forward DNS update been performed?
static constexpr StatementTag GET_LEASE4_PAGE
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Common CQL and Lease Data Methods.
virtual void commit() override
Commit Transactions.
static constexpr StatementTag ALL_LEASE4_STATS
Statement tags definitions.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const override
Basic lease access methods.
Exception thrown on failure to execute a database function.
const isc::log::MessageID DHCPSRV_CQL_GET_IAID_SUBID_DUID
void executeSelect(const CqlConnection &connection, const AnyArray &data, StatementTag statement_tag)
Executes protocol specific lease query SELECT statement.
bool is_raw_
Should the statement be executed raw or with binds?
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv4 leases.
virtual Lease6Collection getLeases6() const override
Returns all IPv6 leases.
const isc::log::MessageID DHCPSRV_CQL_ADD_ADDR4
const isc::log::MessageID DHCPSRV_CQL_GET_SUBID4
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
CqlLease6Exchange(const CqlConnection &connection)
Constructor.