![]() |
Kea
1.5.0
|
Cassandra host data source. More...
#include <cql_host_data_source.h>
Inheritance diagram for isc::dhcp::CqlHostDataSource: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 a host 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 asiolink::IOAddress &address) const override |
| Returns a collection of hosts using the specified IPv4 address. 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 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... | |
Public Member Functions inherited from isc::dhcp::BaseHostDataSource | |
| virtual | ~BaseHostDataSource () |
| Default destructor implementation. 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 database:
For details regarding those paraemters, 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 2053 of file cql_host_data_source.cc.
|
virtual |
Virtual destructor.
Releases prepared CQL statements used by the backend.
Definition at line 2057 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 2062 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::insertOrDelete(), and LOG_DEBUG.
Here is the call graph for this function:
|
overridevirtual |
Commit Transactions.
Commits all pending database operations (no-op for Cassandra)
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 2182 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.
|
overridevirtual |
Attempts to delete a host by (subnet-id, address)
This method supports both v4 and v6.
| subnet_id | subnet identfier. |
| addr | specified address. |
| various | exceptions in case of errors |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 2069 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::get4(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDelete().
Here is the call graph for this function:
|
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 2076 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::get4(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDelete().
Here is the call graph for this function:
|
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 2085 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::get6(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDelete().
Here is the call graph for this function:
|
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 2110 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get4(), and LOG_DEBUG.
Here is the call graph for this function:
|
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 2121 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get4(), and LOG_DEBUG.
Here is the call graph for this function:
|
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 2129 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get6(), and LOG_DEBUG.
Here is the call graph for this function:
|
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 2139 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get6(), and LOG_DEBUG.
Here is the call graph for this function:
|
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 2147 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::get6(), and LOG_DEBUG.
Here is the call graph for this function:
|
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 2094 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAll(), and LOG_DEBUG.
Here is the call graph for this function:
|
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 2103 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getAll4(), and LOG_DEBUG.
Here is the call graph for this function:
|
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 2155 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::getAllHosts().
Here is the call graph for this function:
|
virtual |
Returns textual description of the backend.
Definition at line 2170 of file cql_host_data_source.cc.
|
virtual |
Returns the name of the database.
Definition at line 2165 of file cql_host_data_source.cc.
References isc::dhcp::CqlHostDataSourceImpl::getName().
Here is the call graph for this function:
|
overridevirtual |
Return backend type.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 2160 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 2175 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::CqlHostDataSourceImpl::getVersion(), and LOG_DEBUG.
Here is the call graph for this function:
|
overridevirtual |
Rollback Transactions.
Rolls back all pending database operations (no-op for Cassandra)
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 2187 of file cql_host_data_source.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.