Kea
1.9.9-git
|
Cassandra host data source. More...
#include <cql_host_data_source.h>
Public Member Functions | |
CqlHostDataSource (const db::DatabaseConnection::ParameterMap ¶meters) | |
Constructor. More... | |
virtual | ~CqlHostDataSource () |
Virtual destructor. More... | |
virtual void | add (const HostPtr &host) override |
Adds a new host to the collection. More... | |
virtual void | commit () override |
Commit Transactions. More... | |
virtual bool | del (const SubnetID &subnet_id, const asiolink::IOAddress &addr) override |
Attempts to delete hosts by (subnet-id, address) More... | |
virtual bool | del4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) override |
Attempts to delete a host by (subnet-id4, identifier-type, identifier). More... | |
virtual bool | del6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) override |
Attempts to delete a host by (subnet-id6, identifier-type, identifier). More... | |
virtual ConstHostPtr | get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const override |
Retrieves a Host connected to an IPv4 subnet. More... | |
virtual ConstHostPtr | get4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const override |
Retrieves a Host connected to an IPv4 subnet. More... | |
virtual ConstHostPtr | get6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const override |
Returns a Host connected to an IPv6 subnet. More... | |
virtual ConstHostPtr | get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const override |
Returns a Host with the specified reservation prefix. More... | |
virtual ConstHostPtr | get6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const override |
Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or prefix. More... | |
virtual ConstHostCollection | getAll (const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const override |
Return all hosts connected to any subnet for which reservations have been made using a specified identifier. More... | |
virtual ConstHostCollection | getAll4 (const SubnetID &subnet_id) const override |
Return all hosts in a DHCPv4 subnet. More... | |
virtual ConstHostCollection | getAll4 (const asiolink::IOAddress &address) const override |
Returns a collection of hosts using the specified IPv4 address. More... | |
virtual ConstHostCollection | getAll4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const override |
Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address. More... | |
virtual ConstHostCollection | getAll6 (const SubnetID &subnet_id) const override |
Return all hosts in a DHCPv6 subnet. More... | |
virtual ConstHostCollection | getAll6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const override |
Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease). More... | |
virtual ConstHostCollection | getAllbyHostname (const std::string &hostname) const override |
Return all hosts with a hostname. More... | |
virtual ConstHostCollection | getAllbyHostname4 (const std::string &hostname, const SubnetID &subnet_id) const override |
Return all hosts with a hostname in a DHCPv4 subnet. More... | |
virtual ConstHostCollection | getAllbyHostname6 (const std::string &hostname, const SubnetID &subnet_id) const override |
Return all hosts with a hostname in a DHCPv6 subnet. More... | |
virtual ConstHostCollection | getAllHosts () const |
Returns a collection of all the hosts. More... | |
virtual std::string | getDescription () const |
Returns textual description of the backend. More... | |
virtual std::string | getName () const |
Returns the name of the database. More... | |
virtual ConstHostCollection | getPage4 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const override |
Returns range of hosts in a DHCPv4 subnet. More... | |
virtual ConstHostCollection | getPage4 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const override |
Returns range of hosts. More... | |
virtual ConstHostCollection | getPage6 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const override |
Returns range of hosts in a DHCPv6 subnet. More... | |
virtual ConstHostCollection | getPage6 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const override |
Returns range of hosts. More... | |
virtual std::string | getType () const override |
Return backend type. More... | |
virtual db::VersionPair | getVersion () const |
Retrieves schema version from the DB. More... | |
virtual void | rollback () override |
Rollback Transactions. More... | |
virtual bool | setIPReservationsUnique (const bool unique) override |
Controls whether IP reservations are unique or non-unique. More... | |
Public Member Functions inherited from isc::dhcp::BaseHostDataSource | |
virtual | ~BaseHostDataSource () |
Default destructor implementation. More... | |
virtual isc::db::DatabaseConnection::ParameterMap | getParameters () const |
Return backend parameters. More... | |
virtual bool | isUnusable () |
Flag which indicates if the host manager has at least one unusable connection. More... | |
Additional Inherited Members | |
Public Types inherited from isc::dhcp::BaseHostDataSource | |
enum | IdType { ID_HWADDR = 0, ID_DUID = 1 } |
Specifies the type of an identifier. More... | |
Cassandra host data source.
Implements isc::dhcp::BaseHostDataSource interface customized to Cassandra. Use of this backend implies that a Cassandra database is available and that the Kea schema has been created within it.
The database schema is radically different than the MySQL and the PostgreSQL schemas. Rather than creating a different table for hosts, reservations, DHCPv4 options and DHCPv6 options respectively, the data is denormalized into a single table to benefit from Cassandra's non-relational nature. To make up for the lack of relations, on insertion, the reservations and options are matched against hosts on the server and merged into database entries. When retrieving, each database row is split into the corresponding host, reservation and options.
There can be an inconsistency in the database due to the order of the changes e.g. if you insert a host with no reservations and no options followed by the same host with one reservation will result in 2 entries versus inserting the host with reservation from the beginning which will result in a single entry. In spite of this, retrieving the host will give you the attached reservation in both cases.
Definition at line 56 of file cql_host_data_source.h.
|
explicit |
Constructor.
Uses the following keywords in the parameters passed to it to connect to the Cassandra cluster (if omitted, defaults specified in parentheses):
For details regarding those parameters, see isc::db::CqlConnection::openDatabase.
Finally, all the CQL commands are pre-compiled.
parameters | a data structure relating keywords and values concerned with the database. |
isc::db::NoDatabaseName | Mandatory database name not given |
isc::db::DbOpenError | Error opening the database or if the schema version is invalid. |
isc::db::DbOperationError | An operation on the open database has failed. |
Definition at line 3450 of file cql_host_data_source.cc.
|
virtual |
Virtual destructor.
Releases prepared CQL statements used by the backend.
Definition at line 3454 of file cql_host_data_source.cc.
|
overridevirtual |
Adds a new host to the collection.
The implementations of this method should guard against duplicate reservations for the same Host, where possible. For example, when the reservation for the same HWAddr and SubnetID is added twice, add() should throw a db::DuplicateEntry exception. Note, that usually it is impossible to guard against adding duplicated Host, where one instance is identified by different identifier types.
host | pointer to the new Host being added. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3459 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_ADD, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::insertOrDelete(), and LOG_DEBUG.
|
overridevirtual |
Commit Transactions.
Commits all pending database operations (no-op for Cassandra)
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 3676 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_COMMIT, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.
|
overridevirtual |
Attempts to delete hosts by (subnet-id, address)
This method supports both v4 and v6.
subnet_id | subnet identifier. |
addr | specified address. |
various | exceptions in case of errors |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3466 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::get4(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDelete().
|
overridevirtual |
Attempts to delete a host by (subnet-id4, identifier-type, identifier).
This method supports v4 hosts only.
subnet_id | IPv4 Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
various | exceptions in case of errors |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3473 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::get4(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDelete().
|
overridevirtual |
Attempts to delete a host by (subnet-id6, identifier-type, identifier).
This method supports v6 hosts only.
subnet_id | IPv6 Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
various | exceptions in case of errors |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3482 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::get6(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDelete().
|
overridevirtual |
Retrieves a Host connected to an IPv4 subnet.
The host is identified by specific identifier.
subnet_id | subnet identifier to filter by |
identifier_type | identifier type to filter by |
identifier_begin | pointer to the beginning of a buffer containing a host identifier to filter by |
identifier_len | length of the host identifier buffer |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3582 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get4(), and LOG_DEBUG.
Referenced by getAll4().
|
overridevirtual |
Retrieves a Host connected to an IPv4 subnet.
The host is identifier by specified IPv4 address.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
BadValue | if address in not a valid IPv4address |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3593 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get4(), and LOG_DEBUG.
|
overridevirtual |
Returns a Host connected to an IPv6 subnet.
subnet_id | subnet identifier to filter by |
identifier_type | identifier type to filter by |
identifier_begin | pointer to the beginning of a buffer containing a host identifier to filter by |
identifier_len | length of the host identifier buffer |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3612 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get6(), and LOG_DEBUG.
Referenced by getAll6().
|
overridevirtual |
Returns a Host with the specified reservation prefix.
prefix | IPv6 prefix for which the Host object is searched. |
prefix_len | IPv6 prefix length. |
MultipleRecords | if two or more rows are returned from the Cassandra database |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3622 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get6(), and LOG_DEBUG.
|
overridevirtual |
Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or prefix.
subnet_id | Subnet identifier. |
address | reserved IPv6 address/prefix. |
Host
object using a specified IPv6 address/prefix. Implements isc::dhcp::BaseHostDataSource.
Definition at line 3630 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get6(), and LOG_DEBUG.
|
overridevirtual |
Return all hosts connected to any subnet for which reservations have been made using a specified identifier.
This method returns all Host objects which represent reservations for a specified identifier. This method may return multiple hosts because a particular client may have reservations in multiple subnets.
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3491 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAll(), and LOG_DEBUG.
|
overridevirtual |
Return all hosts in a DHCPv4 subnet.
This method returns all Host objects which represent reservations in a specified subnet.
subnet_id | subnet identifier to filter by |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3500 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAll4(), and LOG_DEBUG.
|
overridevirtual |
Returns a collection of hosts using the specified IPv4 address.
This method may return multiple Host objects if they are connected to different subnets.
address | IPv4 address for which the Host object is searched. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3575 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAll4(), and LOG_DEBUG.
|
overridevirtual |
Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address.
This backend does not support a configuration in which multiple reservations can be created for a single IPv4 address, so it always returns 1 or 0 hosts.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 3601 of file cql_host_data_source.cc.
References get4().
|
overridevirtual |
Return all hosts in a DHCPv6 subnet.
This method returns all Host objects which represent reservations in a specified subnet.
subnet_id | subnet identifier to filter by |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3507 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAll6(), and LOG_DEBUG.
|
overridevirtual |
Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease).
This backend does not support a configuration in which multiple reservations can be created for a single IPv6 address, so it always returns 1 or 0 hosts.
subnet_id | Subnet identifier. |
address | reserved IPv6 address. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 3638 of file cql_host_data_source.cc.
References get6().
|
overridevirtual |
Return all hosts with a hostname.
This method returns all Host
objects which represent reservations using a specified hostname.
Cassandra uses the new indexed lower_case_hostname column.
hostname | The lower case hostname. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 3514 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAllbyHostname(), and LOG_DEBUG.
|
overridevirtual |
Return all hosts with a hostname in a DHCPv4 subnet.
This method returns all Host
objects which represent reservations using a specified hostname in a specified subnet.
hostname | The lower case hostname. |
subnet_id | Subnet identifier. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 3521 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAllbyHostname4(), and LOG_DEBUG.
|
overridevirtual |
Return all hosts with a hostname in a DHCPv6 subnet.
This method returns all Host
objects which represent reservations using a specified hostname in a specified subnet.
hostname | The lower case hostname. |
subnet_id | Subnet identifier. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 3529 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAllbyHostname6(), and LOG_DEBUG.
|
virtual |
Returns a collection of all the hosts.
This method may return multiple Host objects. It is only used in testing. It may be very slow when running on a production server with lots of hosts.
Definition at line 3649 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::getAllHosts().
|
virtual |
Returns textual description of the backend.
Definition at line 3664 of file cql_host_data_source.cc.
|
virtual |
Returns the name of the database.
Definition at line 3659 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::getName().
|
overridevirtual |
Returns range of hosts in a DHCPv4 subnet.
subnet_id | Subnet identifier. |
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects (may be empty). Implements isc::dhcp::BaseHostDataSource.
Definition at line 3537 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getPage4(), and LOG_DEBUG.
|
overridevirtual |
Returns range of hosts.
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects (may be empty). Implements isc::dhcp::BaseHostDataSource.
Definition at line 3557 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getPage4(), and LOG_DEBUG.
|
overridevirtual |
Returns range of hosts in a DHCPv6 subnet.
subnet_id | Subnet identifier. |
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects (may be empty). Implements isc::dhcp::BaseHostDataSource.
Definition at line 3547 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getPage6(), and LOG_DEBUG.
|
overridevirtual |
Returns range of hosts.
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects (may be empty). Implements isc::dhcp::BaseHostDataSource.
Definition at line 3566 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_GET_ALL, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getPage6(), and LOG_DEBUG.
|
overridevirtual |
Return backend type.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3654 of file cql_host_data_source.cc.
|
virtual |
Retrieves schema version from the DB.
isc::db::DbOperationError | An operation on the open database has failed. |
Definition at line 3669 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_HOST_DB_GET_VERSION, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getVersion(), and LOG_DEBUG.
|
overridevirtual |
Rollback Transactions.
Rolls back all pending database operations (no-op for Cassandra)
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 3681 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_CQL_ROLLBACK, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.
|
overridevirtual |
Controls whether IP reservations are unique or non-unique.
In a typical case, the IP reservations are unique and backends verify prior to adding a host reservation to the database that the reservation for a given IP address does not exist. In some cases it may be required to allow non-unique IP reservations, e.g. in the case when a host has several interfaces and independently of which interface is used by this host to communicate with the DHCP server the same IP address should be assigned. In this case the unique
value should be set to false to disable the checks for uniqueness on the backend side.
unique | boolean flag indicating if the IP reservations must be unique within the subnet or can be non-unique. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 3686 of file cql_host_data_source.cc.