Kea  1.9.9-git
isc::dhcp::CqlLeaseMgr Class Reference

Cassandra Lease Manager. More...

#include <cql_lease_mgr.h>

+ Inheritance diagram for isc::dhcp::CqlLeaseMgr:

Public Member Functions

 CqlLeaseMgr (const db::DatabaseConnection::ParameterMap &parameters)
 Constructor. More...
 
virtual ~CqlLeaseMgr ()
 Destructor (closes database) More...
 
virtual bool addLease (const Lease4Ptr &lease) override
 Adds an IPv4 lease. More...
 
virtual bool addLease (const Lease6Ptr &lease) override
 Adds an IPv6 lease. More...
 
virtual void commit () override
 Commit Transactions. More...
 
virtual uint64_t deleteExpiredReclaimedLeases4 (const uint32_t secs) override
 Deletes all expired and reclaimed DHCPv4 leases. More...
 
virtual uint64_t deleteExpiredReclaimedLeases6 (const uint32_t secs) override
 Deletes all expired and reclaimed DHCPv6 leases. More...
 
bool deleteLease (const Lease4Ptr &lease) overridefinal
 Deletes an IPv4 lease. More...
 
bool deleteLease (const Lease6Ptr &lease) overridefinal
 Deletes an IPv6 lease. More...
 
virtual std::string getDescription () const override
 Returns description of the backend. More...
 
virtual std::string getName () const override
 Returns name of the database. More...
 
virtual std::string getType () const override
 Return backend type. More...
 
virtual VersionPair getVersion () const override
 Returns backend version. More...
 
virtual void rollback () override
 Rollback Transactions. More...
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery4 () override
 Creates and runs the IPv4 lease stats query. More...
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery6 () override
 Creates and runs the IPv6 lease stats query. More...
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4 (const SubnetID &subnet_id) override
 Creates and runs the IPv4 lease stats query for a single subnet. More...
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6 (const SubnetID &subnet_id) override
 Creates and runs the IPv6 lease stats query for a single subnet. More...
 
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. More...
 
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. More...
 
virtual void updateLease4 (const Lease4Ptr &lease4) override
 Updates IPv4 lease. More...
 
virtual void updateLease6 (const Lease6Ptr &lease6) override
 Updates IPv6 lease. More...
 
virtual size_t wipeLeases4 (const SubnetID &subnet_id) override
 Removes specified IPv4 leases. More...
 
virtual size_t wipeLeases6 (const SubnetID &subnet_id) override
 Removed specified IPv6 leases. More...
 
virtual Lease4Ptr getLease4 (const isc::asiolink::IOAddress &addr) const override
 Basic lease access methods. More...
 
virtual Lease4Collection getLease4 (const isc::dhcp::HWAddr &hwaddr) const override
 Returns existing IPv4 leases for specified hardware address. More...
 
virtual Lease4Ptr getLease4 (const isc::dhcp::HWAddr &hwaddr, SubnetID subnet_id) const override
 Returns existing IPv4 leases for specified hardware address and a subnet. More...
 
virtual Lease4Collection getLease4 (const ClientId &clientid) const override
 Returns existing IPv4 leases for specified client-id. More...
 
virtual Lease4Ptr getLease4 (const ClientId &clientid, SubnetID subnet_id) const override
 Returns existing IPv4 lease for specified client-id. More...
 
virtual Lease4Collection getLeases4 (SubnetID subnet_id) const override
 Returns all IPv4 leases for the particular subnet identifier. More...
 
virtual Lease4Collection getLeases4 (const std::string &hostname) const override
 Returns all IPv4 leases for the particular hostname. More...
 
virtual Lease4Collection getLeases4 () const override
 Returns all IPv4 leases. More...
 
virtual Lease4Collection getLeases4 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const override
 Returns range of IPv4 leases using paging. More...
 
virtual Lease6Ptr getLease6 (Lease::Type type, const isc::asiolink::IOAddress &addr) const override
 Returns existing IPv6 lease for a given IPv6 address. More...
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid) const override
 Returns existing IPv6 leases for a given DUID+IA combination. More...
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const override
 Returns existing IPv6 lease for a given DUID+IA combination. More...
 
virtual Lease6Collection getLeases6 (SubnetID subnet_id) const override
 Returns all IPv6 leases for the particular subnet identifier. More...
 
virtual Lease6Collection getLeases6 (const std::string &hostname) const override
 Returns all IPv6 leases for the particular hostname. More...
 
virtual Lease6Collection getLeases6 () const override
 Returns all IPv6 leases. More...
 
virtual Lease6Collection getLeases6 (const DUID &duid) const override
 Returns all IPv6 leases. More...
 
virtual Lease6Collection getLeases6 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const override
 Returns range of IPv6 leases using paging. More...
 
virtual void getExpiredLeases4 (Lease4Collection &expired_leases, const size_t max_leases) const override
 Returns a collection of expired DHCPv4 leases. More...
 
virtual void getExpiredLeases6 (Lease6Collection &expired_leases, const size_t max_leases) const override
 Returns a collection of expired DHCPv6 leases. More...
 
- Public Member Functions inherited from isc::dhcp::LeaseMgr
 LeaseMgr ()
 Constructor. More...
 
virtual ~LeaseMgr ()
 Destructor. More...
 
Lease6Ptr getLease6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const
 returns zero or one IPv6 lease for a given duid+iaid+subnet_id More...
 
void recountLeaseStats4 ()
 Recalculates per-subnet and global stats for IPv4 leases. More...
 
void recountLeaseStats6 ()
 Recalculates per-subnet and global stats for IPv6 leases. More...
 

Static Public Member Functions

static std::string getDBVersion ()
 Local version of getDBVersion() class method. More...
 
- Static Public Member Functions inherited from isc::dhcp::LeaseMgr
static std::string getDBVersion ()
 Class method to return extended version info This class method must be redeclared and redefined in derived classes. More...
 
static isc::asiolink::IOServicePtrgetIOService ()
 Returns pointer to the IO service. More...
 
static void setIOService (const isc::asiolink::IOServicePtr &io_service)
 Sets IO service to be used by the Lease Manager. More...
 

Detailed Description

Cassandra Lease Manager.

This class provides the isc::dhcp::LeaseMgr interface to the Cassandra database. Use of this backend implies that a CQL database is available and that the Kea schema has been created within it.

Definition at line 42 of file cql_lease_mgr.h.

Constructor & Destructor Documentation

isc::dhcp::CqlLeaseMgr::CqlLeaseMgr ( const db::DatabaseConnection::ParameterMap parameters)
explicit

Constructor.

Uses the following keywords in the parameters passed to it to connect to the Cassandra cluster (if omitted, defaults specified in parentheses):

  • keyspace: name of the database to which to connect (keatest)
  • contact-points: IP addresses of the nodes to connect to (127.0.0.1)
  • consistency: consistency level (quorum)
  • serial-consistency: serial consistency level (serial)
  • port: The TCP port to use (9042)
  • user - credentials to use when connecting (no username)
  • password - credentials to use when connecting (no password)
  • reconnect-wait-time 2000
  • connect-timeout 5000
  • request-timeout 12000
  • tcp-keepalive no
  • tcp-nodelay no

Finally, all the CQL commands are pre-compiled.

Parameters
parametersa data structure relating keywords and values concerned with the database.
Exceptions
isc::db::NoDatabaseNameMandatory database name not given
isc::db::DbOpenErrorError opening the database or the schema version is invalid.
isc::db::DbOperationErrorAn operation on the open database has failed.

Definition at line 2100 of file cql_lease_mgr.cc.

References isc::db::CQL_SCHEMA_VERSION_MAJOR, isc::db::CQL_SCHEMA_VERSION_MINOR, getVersion(), isc_throw, isc::db::CqlConnection::openDatabase(), isc::db::CqlConnection::prepareStatements(), isc::dhcp::CqlLease4Exchange::tagged_statements_, and isc::dhcp::CqlLeaseStatsQuery::tagged_statements_.

+ Here is the call graph for this function:

isc::dhcp::CqlLeaseMgr::~CqlLeaseMgr ( )
virtual

Destructor (closes database)

Definition at line 2122 of file cql_lease_mgr.cc.

Member Function Documentation

bool isc::dhcp::CqlLeaseMgr::addLease ( const Lease4Ptr lease)
overridevirtual

Adds an IPv4 lease.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not (because a lease with the same address was already there).
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2137 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_ADD_ADDR4, isc::dhcp::DHCPSRV_CQL_LEASE_EXCEPTION_THROWN, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, and isc::Exception::what().

+ Here is the call graph for this function:

bool isc::dhcp::CqlLeaseMgr::addLease ( const Lease6Ptr lease)
overridevirtual

Adds an IPv6 lease.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not (because a lease with the same address was already there).
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2161 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_ADD_ADDR6, isc::dhcp::DHCPSRV_CQL_LEASE_EXCEPTION_THROWN, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, and isc::Exception::what().

+ Here is the call graph for this function:

void isc::dhcp::CqlLeaseMgr::commit ( )
overridevirtual

Commit Transactions.

This is a no-op for Cassandra.

Implements isc::dhcp::LeaseMgr.

Definition at line 2837 of file cql_lease_mgr.cc.

References isc::db::CqlConnection::commit(), isc::dhcp::DHCPSRV_CQL_COMMIT, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.

+ Here is the call graph for this function:

uint64_t isc::dhcp::CqlLeaseMgr::deleteExpiredReclaimedLeases4 ( const uint32_t  secs)
overridevirtual

Deletes all expired and reclaimed DHCPv4 leases.

Parameters
secsnumber of seconds since expiration of leases before they can be removed. Leases which have expired later than this time will not be deleted.
Returns
Number of leases deleted.

Implements isc::dhcp::LeaseMgr.

Definition at line 2684 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), deleteLease(), isc::dhcp::DHCPSRV_CQL_DELETE_EXPIRED_RECLAIMED4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, and isc::dhcp::Lease::STATE_EXPIRED_RECLAIMED.

+ Here is the call graph for this function:

uint64_t isc::dhcp::CqlLeaseMgr::deleteExpiredReclaimedLeases6 ( const uint32_t  secs)
overridevirtual

Deletes all expired and reclaimed DHCPv6 leases.

Parameters
secsnumber of seconds since expiration of leases before they can be removed. Leases which have expired later than this time will not be deleted.
Returns
Number of leases deleted.

Implements isc::dhcp::LeaseMgr.

Definition at line 2715 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), deleteLease(), isc::dhcp::DHCPSRV_CQL_DELETE_EXPIRED_RECLAIMED6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, and isc::dhcp::Lease::STATE_EXPIRED_RECLAIMED.

+ Here is the call graph for this function:

bool isc::dhcp::CqlLeaseMgr::deleteLease ( const Lease4Ptr lease)
finaloverridevirtual

Deletes an IPv4 lease.

Parameters
leaseIPv4 lease being deleted.
Returns
true if deletion was successful, false if no such lease exists.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
The DELETE query uses IF expire = ? to delete the lease only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and DELETE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 2636 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_DELETE_ADDR, isc::dhcp::DHCPSRV_CQL_LEASE_EXCEPTION_THROWN, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, isc::asiolink::IOAddress::toText(), and isc::Exception::what().

Referenced by deleteExpiredReclaimedLeases4(), and deleteExpiredReclaimedLeases6().

+ Here is the call graph for this function:

bool isc::dhcp::CqlLeaseMgr::deleteLease ( const Lease6Ptr lease)
finaloverridevirtual

Deletes an IPv6 lease.

Parameters
leaseIPv6 lease being deleted.
Returns
true if deletion was successful, false if no such lease exists.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
The DELETE query uses IF expire = ? to delete the lease only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and DELETE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 2660 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_DELETE_ADDR, isc::dhcp::DHCPSRV_CQL_LEASE_EXCEPTION_THROWN, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, isc::asiolink::IOAddress::toText(), and isc::Exception::what().

+ Here is the call graph for this function:

std::string isc::dhcp::CqlLeaseMgr::getDBVersion ( )
static
std::string isc::dhcp::CqlLeaseMgr::getDescription ( ) const
overridevirtual

Returns description of the backend.

This description may be multiline text that describes the backend.

Returns
Description of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 2825 of file cql_lease_mgr.cc.

void isc::dhcp::CqlLeaseMgr::getExpiredLeases4 ( Lease4Collection expired_leases,
const size_t  max_leases 
) const
overridevirtual

Returns a collection of expired DHCPv4 leases.

This method returns at most max_leases expired leases. The leases returned haven't been reclaimed, i.e. the database query must exclude reclaimed leases from the results returned.

Parameters
[out]expired_leasesA container to which expired leases returned by the database backend are added.
max_leasesA maximum number of leases to be returned. If this value is set to 0, all expired (but not reclaimed) leases are returned.

Implements isc::dhcp::LeaseMgr.

Definition at line 2578 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_GET_EXPIRED4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.

void isc::dhcp::CqlLeaseMgr::getExpiredLeases6 ( Lease6Collection expired_leases,
const size_t  max_leases 
) const
overridevirtual

Returns a collection of expired DHCPv6 leases.

This method returns at most max_leases expired leases. The leases returned haven't been reclaimed, i.e. the database query must exclude reclaimed leases from the results returned.

Parameters
[out]expired_leasesA container to which expired leases returned by the database backend are added.
max_leasesA maximum number of leases to be returned. If this value is set to 0, all expired (but not reclaimed) leases are returned.

Implements isc::dhcp::LeaseMgr.

Definition at line 2588 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_GET_EXPIRED6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.

Lease4Ptr isc::dhcp::CqlLeaseMgr::getLease4 ( const isc::asiolink::IOAddress addr) const
overridevirtual

Basic lease access methods.

Obtain leases from the database using various criteria.Returns an IPv4 lease for specified IPv4 address

This method return a lease that is associated with a given address. For other query types (by hardware addr, by Client ID) there can be several leases in different subnets (e.g. for mobile clients that got address in different subnets). However, for a single address there can be only one lease, so this method returns a pointer to a single lease, not a container of leases.

Parameters
addraddress of the searched lease
Returns
smart pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2185 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_ADDR4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

Lease4Collection isc::dhcp::CqlLeaseMgr::getLease4 ( const isc::dhcp::HWAddr hwaddr) const
overridevirtual

Returns existing IPv4 leases for specified hardware address.

Although in the usual case there will be only one lease, for mobile clients or clients with multiple static/fixed/reserved leases there can be more than one. Thus return type is a container, not a single pointer.

Parameters
hwaddrhardware address of the client
Returns
lease collection
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2205 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_HWADDR, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::HWAddr::hwaddr_, LOG_DEBUG, and isc::dhcp::HWAddr::toText().

+ Here is the call graph for this function:

Lease4Ptr isc::dhcp::CqlLeaseMgr::getLease4 ( const isc::dhcp::HWAddr hwaddr,
SubnetID  subnet_id 
) const
overridevirtual

Returns existing IPv4 leases for specified hardware address and a subnet.

There can be at most one lease for a given HW address in a single subnet, so this method with either return a single lease or NULL.

Parameters
hwaddrhardware address of the client
subnet_ididentifier of the subnet that lease must belong to
Returns
a pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2224 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_SUBID_HWADDR, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::HWAddr::hwaddr_, LOG_DEBUG, and isc::dhcp::HWAddr::toText().

+ Here is the call graph for this function:

Lease4Collection isc::dhcp::CqlLeaseMgr::getLease4 ( const ClientId clientid) const
overridevirtual

Returns existing IPv4 leases for specified client-id.

Although in the usual case there will be only one lease, for mobile clients or clients with multiple static/fixed/reserved leases there can be more than one. Thus return type is a container, not a single pointer.

Parameters
clientidclient identifier
Returns
lease collection
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2248 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_CLIENTID, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::ClientId::getClientId(), LOG_DEBUG, and isc::dhcp::ClientId::toText().

+ Here is the call graph for this function:

Lease4Ptr isc::dhcp::CqlLeaseMgr::getLease4 ( const ClientId clientid,
SubnetID  subnet_id 
) const
overridevirtual

Returns existing IPv4 lease for specified client-id.

There can be at most one lease for a given HW address in a single pool, so this method with either return a single lease or NULL.

Parameters
clientidclient identifier
subnet_ididentifier of the subnet that lease must belong to
Returns
a pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2267 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_SUBID_CLIENTID, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::ClientId::getClientId(), LOG_DEBUG, and isc::dhcp::ClientId::toText().

+ Here is the call graph for this function:

Lease6Ptr isc::dhcp::CqlLeaseMgr::getLease6 ( Lease::Type  type,
const isc::asiolink::IOAddress addr 
) const
overridevirtual

Returns existing IPv6 lease for a given IPv6 address.

For a given address, we assume that there will be only one lease. The assumption here is that there will not be site or link-local addresses used, so there is no way of having address duplication.

Parameters
typespecifies lease type: (NA, TA or PD)
addraddress of the searched lease
Returns
smart pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::BadValuerecord retrieved from database had an invalid lease type field.
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2388 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_ADDR6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc_throw, LOG_DEBUG, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

Lease4Collection isc::dhcp::CqlLeaseMgr::getLeases4 ( SubnetID  subnet_id) const
overridevirtual

Returns all IPv4 leases for the particular subnet identifier.

Parameters
subnet_idsubnet identifier.
Returns
Lease collection (may be empty if no IPv4 lease found).
Exceptions
NotImplementedbecause this method is currently not implemented for this backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 2290 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_SUBID4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.

+ Here is the call graph for this function:

Lease4Collection isc::dhcp::CqlLeaseMgr::getLeases4 ( const std::string &  hostname) const
overridevirtual

Returns all IPv4 leases for the particular hostname.

Parameters
hostnamehostname in lower case.
Returns
Lease collection (may be empty if no IPv4 lease found).

Implements isc::dhcp::LeaseMgr.

Definition at line 2309 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_HOSTNAME4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.

+ Here is the call graph for this function:

Lease4Collection isc::dhcp::CqlLeaseMgr::getLeases4 ( ) const
overridevirtual

Returns all IPv4 leases.

Returns
Lease collection (may be empty if no IPv4 lease found).
Exceptions
NotImplementedbecause this method is currently not implemented for this backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 2328 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_GET4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.

Lease4Collection isc::dhcp::CqlLeaseMgr::getLeases4 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
overridevirtual

Returns range of IPv4 leases using paging.

This method implements paged browsing of the lease database. The first parameter specifies a page size. The second parameter is optional and specifies the starting address of the range. This address is excluded from the returned range. The IPv4 zero address (default) denotes that the first page should be returned. There is no guarantee about the order of returned leases.

The typical usage of this method is as follows:

  • Get the first page of leases by specifying IPv4 zero address as the beginning of the range.
  • Last address of the returned range should be used as a starting address for the next page in the subsequent call.
  • If the number of leases returned is lower than the page size, it indicates that the last page has been retrieved.
  • If there are no leases returned it indicates that the previous page was the last page.
Parameters
lower_bound_addressIPv4 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Lease collection (may be empty if no IPv4 lease found).

Implements isc::dhcp::LeaseMgr.

Definition at line 2343 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_PAGE4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlLease4Exchange::GET_LEASE4_PAGE, isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV4Zero(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

Lease6Collection isc::dhcp::CqlLeaseMgr::getLeases6 ( Lease::Type  type,
const DUID duid,
uint32_t  iaid 
) const
overridevirtual

Returns existing IPv6 leases for a given DUID+IA combination.

Although in the usual case there will be only one lease, for mobile clients or clients with multiple static/fixed/reserved leases there can be more than one. Thus return type is a container, not a single pointer.

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
Returns
smart pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::BadValuerecord retrieved from database had an invalid lease type field.
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2437 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_IAID_DUID, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DUID::getDuid(), LOG_DEBUG, and isc::dhcp::DUID::toText().

+ Here is the call graph for this function:

Lease6Collection isc::dhcp::CqlLeaseMgr::getLeases6 ( Lease::Type  type,
const DUID duid,
uint32_t  iaid,
SubnetID  subnet_id 
) const
overridevirtual

Returns existing IPv6 lease for a given DUID+IA combination.

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
subnet_idsubnet id of the subnet the lease belongs to
Returns
lease collection (may be empty if no lease is found)
Exceptions
isc::BadValuerecord retrieved from database had an invalid lease type field.
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2464 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_IAID_SUBID_DUID, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DUID::getDuid(), LOG_DEBUG, and isc::dhcp::DUID::toText().

+ Here is the call graph for this function:

Lease6Collection isc::dhcp::CqlLeaseMgr::getLeases6 ( SubnetID  subnet_id) const
overridevirtual

Returns all IPv6 leases for the particular subnet identifier.

Parameters
subnet_idsubnet identifier.
Returns
Lease collection (may be empty if no IPv6 lease found).
Exceptions
NotImplementedbecause this method is currently not implemented for this backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 2496 of file cql_lease_mgr.cc.

References isc_throw.

Lease6Collection isc::dhcp::CqlLeaseMgr::getLeases6 ( const std::string &  hostname) const
overridevirtual

Returns all IPv6 leases for the particular hostname.

Parameters
hostnamehostname in lower case.
Returns
Lease collection (may be empty if no IPv6 lease found).

Implements isc::dhcp::LeaseMgr.

Definition at line 2501 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_HOSTNAME6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.

+ Here is the call graph for this function:

Lease6Collection isc::dhcp::CqlLeaseMgr::getLeases6 ( ) const
overridevirtual

Returns all IPv6 leases.

Returns
Lease collection (may be empty if no IPv6 lease found).
Exceptions
NotImplementedbecause this method is currently not implemented for this backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 2520 of file cql_lease_mgr.cc.

References isc_throw.

Lease6Collection isc::dhcp::CqlLeaseMgr::getLeases6 ( const DUID duid) const
overridevirtual

Returns all IPv6 leases.

Returns
Lease collection (may be empty if no IPv6 lease found).

Implements isc::dhcp::LeaseMgr.

Definition at line 2418 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), and isc::dhcp::DUID::getDuid().

+ Here is the call graph for this function:

Lease6Collection isc::dhcp::CqlLeaseMgr::getLeases6 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
overridevirtual

Returns range of IPv6 leases using paging.

This method implements paged browsing of the lease database. The first parameter specifies a page size. The second parameter is optional and specifies the starting address of the range. This address is excluded from the returned range. The IPv6 zero address (default) denotes that the first page should be returned. There is no guarantee about the order of returned leases.

The typical usage of this method is as follows:

  • Get the first page of leases by specifying IPv6 zero address as the beginning of the range.
  • Last address of the returned range should be used as a starting address for the next page in the subsequent call.
  • If the number of leases returned is lower than the page size, it indicates that the last page has been retrieved.
  • If there are no leases returned it indicates that the previous page was the last page.
Parameters
lower_bound_addressIPv6 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Warning
This method is currently not implemented. Cassandra doesn't support conversions from text to inet. Therefore, we're unable to compare the IPv6 addresses to find the desired range. A solution for this might be to store the IPv6 address as INET type rather than text, but this is currently low priority.
Returns
Lease collection (may be empty if no IPv6 lease found).
Exceptions
isc::NotImplemented

Implements isc::dhcp::LeaseMgr.

Definition at line 2525 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::DHCPSRV_CQL_GET_PAGE6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlLease6Exchange::GET_LEASE6_PAGE, isc_throw, isc::asiolink::IOAddress::isV6(), isc::asiolink::IOAddress::isV6Zero(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

std::string isc::dhcp::CqlLeaseMgr::getName ( ) const
overridevirtual

Returns name of the database.

Returns
database name

Implements isc::dhcp::LeaseMgr.

Definition at line 2814 of file cql_lease_mgr.cc.

References isc::db::DatabaseConnection::getParameter().

+ Here is the call graph for this function:

virtual std::string isc::dhcp::CqlLeaseMgr::getType ( ) const
inlineoverridevirtual

Return backend type.

Returns
Type of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 570 of file cql_lease_mgr.h.

VersionPair isc::dhcp::CqlLeaseMgr::getVersion ( ) const
overridevirtual

Returns backend version.

Returns
Version number as a pair of unsigned integers. "first" is the major version number, "second" the minor number.
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2830 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_GET_VERSION, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::db::CqlConnection::getVersion(), and LOG_DEBUG.

Referenced by CqlLeaseMgr().

+ Here is the call graph for this function:

void isc::dhcp::CqlLeaseMgr::rollback ( )
overridevirtual

Rollback Transactions.

This is a no-op for Cassandra.

Implements isc::dhcp::LeaseMgr.

Definition at line 2843 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_ROLLBACK, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, and isc::db::CqlConnection::rollback().

+ Here is the call graph for this function:

LeaseStatsQueryPtr isc::dhcp::CqlLeaseMgr::startLeaseStatsQuery4 ( )
overridevirtual

Creates and runs the IPv4 lease stats query.

It creates an instance of a CqlLeaseStatsQuery4 and then invokes its start method, which fetches its statistical data result set by executing the ALL_LEASE_STATS4 query. The query object is then returned.

Returns
The populated query as a pointer to an LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2746 of file cql_lease_mgr.cc.

LeaseStatsQueryPtr isc::dhcp::CqlLeaseMgr::startLeaseStatsQuery6 ( )
overridevirtual

Creates and runs the IPv6 lease stats query.

It creates an instance of a CqlLeaseStatsQuery and then invokes its start method, which fetches its statistical data result set by executing the ALL_LEASE_STATS6 query. The query object is then returned.

Returns
The populated query as a pointer to an LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2774 of file cql_lease_mgr.cc.

LeaseStatsQueryPtr isc::dhcp::CqlLeaseMgr::startSubnetLeaseStatsQuery4 ( const SubnetID subnet_id)
overridevirtual

Creates and runs the IPv4 lease stats query for a single subnet.

It creates an instance of a CqlLeaseStatsQuery4 for a single subnet query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

Parameters
subnet_idid of the subnet for which stats are desired
Returns
A populated LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2755 of file cql_lease_mgr.cc.

LeaseStatsQueryPtr isc::dhcp::CqlLeaseMgr::startSubnetLeaseStatsQuery6 ( const SubnetID subnet_id)
overridevirtual

Creates and runs the IPv6 lease stats query for a single subnet.

It creates an instance of a CqlLeaseStatsQuery6 for a single subnet query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

Parameters
subnet_idid of the subnet for which stats are desired
Returns
A populated LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2783 of file cql_lease_mgr.cc.

LeaseStatsQueryPtr isc::dhcp::CqlLeaseMgr::startSubnetRangeLeaseStatsQuery4 ( const SubnetID first_subnet_id,
const SubnetID last_subnet_id 
)
overridevirtual

Creates and runs the IPv4 lease stats query for a single subnet.

It creates an instance of a CqlLeaseStatsQuery4 for a subnet range query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

Parameters
first_subnet_idfirst subnet in the range of subnets
last_subnet_idlast subnet in the range of subnets
Returns
A populated LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2764 of file cql_lease_mgr.cc.

LeaseStatsQueryPtr isc::dhcp::CqlLeaseMgr::startSubnetRangeLeaseStatsQuery6 ( const SubnetID first_subnet_id,
const SubnetID last_subnet_id 
)
overridevirtual

Creates and runs the IPv6 lease stats query for a single subnet.

It creates an instance of a CqlLeaseStatsQuery6 for a subnet range query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

Parameters
first_subnet_idfirst subnet in the range of subnets
last_subnet_idlast subnet in the range of subnets
Returns
A populated LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2792 of file cql_lease_mgr.cc.

void isc::dhcp::CqlLeaseMgr::updateLease4 ( const Lease4Ptr lease4)
overridevirtual

Updates IPv4 lease.

Updates the record of the lease in the database (as identified by the address) with the data in the passed lease object.

Parameters
lease4The lease to be updated.
Exceptions
isc::dhcp::NoSuchLeaseAttempt to update a lease that did not exist.
isc::db::DbOperationErrorAn operation on the open database has failed.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
The UPDATE query uses IF expire = ? to update the lease only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and UPDATE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 2598 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_UPDATE_ADDR4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc_throw, LOG_DEBUG, and isc::Exception::what().

+ Here is the call graph for this function:

void isc::dhcp::CqlLeaseMgr::updateLease6 ( const Lease6Ptr lease6)
overridevirtual

Updates IPv6 lease.

Updates the record of the lease in the database (as identified by the address) with the data in the passed lease object.

Parameters
lease6The lease to be updated.
Exceptions
isc::dhcp::NoSuchLeaseAttempt to update a lease that did not
isc::db::DbOperationErrorAn operation on the open database has failed.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
The UPDATE query uses IF expire = ? to update the lease only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and UPDATE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 2617 of file cql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_CQL_UPDATE_ADDR6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc_throw, LOG_DEBUG, and isc::Exception::what().

+ Here is the call graph for this function:

size_t isc::dhcp::CqlLeaseMgr::wipeLeases4 ( const SubnetID subnet_id)
overridevirtual

Removes specified IPv4 leases.

This rather dangerous method is able to remove all leases from specified subnet.

Todo:
: Not implemented yet.
Parameters
subnet_ididentifier of the subnet
Returns
number of leases removed.
Todo:
: Need to implement this, so wipe leases would work.

Implements isc::dhcp::LeaseMgr.

Definition at line 2802 of file cql_lease_mgr.cc.

References isc_throw.

size_t isc::dhcp::CqlLeaseMgr::wipeLeases6 ( const SubnetID subnet_id)
overridevirtual

Removed specified IPv6 leases.

This rather dangerous method is able to remove all leases from specified subnet.

Todo:
: Not implemented yet.
Parameters
subnet_ididentifier of the subnet
Returns
number of leases removed.
Todo:
: Need to implement this, so wipe leases would work.

Implements isc::dhcp::LeaseMgr.

Definition at line 2808 of file cql_lease_mgr.cc.

References isc_throw.


The documentation for this class was generated from the following files: