Kea  1.9.9-git
cql_host_data_source.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
2 // Copyright (C) 2016-2018 Deutsche Telekom AG.
3 //
4 // Author: Andrei Pavel <andrei.pavel@qualitance.com>
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 
18 #ifndef CQL_HOST_DATA_SOURCE_H
19 #define CQL_HOST_DATA_SOURCE_H
20 
21 #include <cql/cql_connection.h>
23 
24 #include <string>
25 #include <vector>
26 
27 namespace isc {
28 namespace dhcp {
29 
31 class CqlHostDataSourceImpl;
32 
57 public:
89  explicit CqlHostDataSource(const db::DatabaseConnection::ParameterMap& parameters);
90 
94  virtual ~CqlHostDataSource();
95 
106  virtual void add(const HostPtr& host) override;
107 
117  virtual bool del(const SubnetID& subnet_id,
118  const asiolink::IOAddress& addr) override;
119 
133  virtual bool del4(const SubnetID& subnet_id,
134  const Host::IdentifierType& identifier_type,
135  const uint8_t* identifier_begin,
136  const size_t identifier_len) override;
137 
151  virtual bool del6(const SubnetID& subnet_id,
152  const Host::IdentifierType& identifier_type,
153  const uint8_t* identifier_begin,
154  const size_t identifier_len) override;
155 
169  virtual ConstHostCollection
170  getAll(const Host::IdentifierType& identifier_type,
171  const uint8_t* identifier_begin,
172  const size_t identifier_len) const override;
173 
182  virtual ConstHostCollection
183  getAll4(const SubnetID& subnet_id) const override;
184 
193  virtual ConstHostCollection
194  getAll6(const SubnetID& subnet_id) const override;
195 
206  virtual ConstHostCollection
207  getAllbyHostname(const std::string& hostname) const override;
208 
218  virtual ConstHostCollection
219  getAllbyHostname4(const std::string& hostname, const SubnetID& subnet_id) const override;
220 
230  virtual ConstHostCollection
231  getAllbyHostname6(const std::string& hostname, const SubnetID& subnet_id) const override;
232 
242  virtual ConstHostCollection
243  getPage4(const SubnetID& subnet_id,
244  size_t& source_index,
245  uint64_t lower_host_id,
246  const HostPageSize& page_size) const override;
247 
257  virtual ConstHostCollection
258  getPage6(const SubnetID& subnet_id,
259  size_t& source_index,
260  uint64_t lower_host_id,
261  const HostPageSize& page_size) const override;
262 
271  virtual ConstHostCollection
272  getPage4(size_t& source_index,
273  uint64_t lower_host_id,
274  const HostPageSize& page_size) const override;
275 
284  virtual ConstHostCollection
285  getPage6(size_t& source_index,
286  uint64_t lower_host_id,
287  const HostPageSize& page_size) const override;
288 
297  virtual ConstHostCollection
298  getAll4(const asiolink::IOAddress& address) const override;
299 
312  virtual ConstHostPtr get4(const SubnetID& subnet_id,
313  const Host::IdentifierType& identifier_type,
314  const uint8_t* identifier_begin,
315  const size_t identifier_len) const override;
316 
327  virtual ConstHostPtr
328  get4(const SubnetID& subnet_id,
329  const asiolink::IOAddress& address) const override;
330 
342  virtual ConstHostCollection
343  getAll4(const SubnetID& subnet_id,
344  const asiolink::IOAddress& address) const override;
345 
356  virtual ConstHostPtr get6(const SubnetID& subnet_id,
357  const Host::IdentifierType& identifier_type,
358  const uint8_t* identifier_begin,
359  const size_t identifier_len) const override;
360 
370  virtual ConstHostPtr get6(const asiolink::IOAddress& prefix,
371  const uint8_t prefix_len) const override;
372 
380  virtual ConstHostPtr
381  get6(const SubnetID& subnet_id,
382  const asiolink::IOAddress& address) const override;
383 
395  virtual ConstHostCollection
396  getAll6(const SubnetID& subnet_id,
397  const asiolink::IOAddress& address) const override;
398 
406  virtual ConstHostCollection
407  getAllHosts() const;
408 
412  virtual std::string getDescription() const;
413 
417  virtual std::string getName() const;
418 
422  virtual std::string getType() const override;
423 
432  virtual db::VersionPair getVersion() const;
433 
437  virtual void commit() override;
438 
442  virtual void rollback() override;
443 
460  virtual bool setIPReservationsUnique(const bool unique) override;
461 
462 private:
464  CqlHostDataSourceImpl* impl_;
465 }; // class CqlHostDataSource
466 
467 } // namespace dhcp
468 } // namespace isc
469 
470 #endif // CQL_HOST_DATA_SOURCE_H
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr) override
Attempts to delete hosts by (subnet-id, address)
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).
Wraps value holding size of the page with host reservations.
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition: host.h:785
virtual ConstHostCollection getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const override
Return all hosts with a hostname in a DHCPv4 subnet.
virtual ConstHostCollection getAll6(const SubnetID &subnet_id) const override
Return all hosts in a DHCPv6 subnet.
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.
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.
virtual bool setIPReservationsUnique(const bool unique) override
Controls whether IP reservations are unique or non-unique.
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:791
Implementation of the CqlHostDataSource.
virtual void commit() override
Commit Transactions.
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.
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).
virtual void rollback() override
Rollback Transactions.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:788
std::pair< uint32_t, uint32_t > VersionPair
Pair containing major and minor versions.
CqlHostDataSource(const db::DatabaseConnection::ParameterMap &parameters)
Constructor.
virtual void add(const HostPtr &host) override
Adds a new host to the collection.
virtual std::string getName() const
Returns the name of the database.
Defines the logger used by the top-level component of kea-dhcp-ddns.
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 iden...
virtual db::VersionPair getVersion() const
Retrieves schema version from the DB.
Base interface for the classes implementing simple data source for host reservations.
virtual std::string getDescription() const
Returns textual description of the backend.
virtual ConstHostCollection getAllbyHostname6(const std::string &hostname, const SubnetID &subnet_id) const override
Return all hosts with a hostname in a DHCPv6 subnet.
IdentifierType
Type of the host identifier.
Definition: host.h:307
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
virtual ~CqlHostDataSource()
Virtual destructor.
virtual std::string getType() const override
Return backend type.
Cassandra host data source.
virtual ConstHostCollection getAllHosts() const
Returns a collection of all the hosts.
virtual ConstHostCollection getAllbyHostname(const std::string &hostname) const override
Return all hosts with a hostname.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const override
Return all hosts in a DHCPv4 subnet.
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.