Kea: bulk_lease_query.h Source File

| Kea 3.2.0-git

bulk_lease_query.h
Go to the documentation of this file.
1// Copyright (C) 2022-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef BULK_LEASE_QUERY_H
8#define BULK_LEASE_QUERY_H
9
10#include <config.h>
11
12#include <blq_msg.h>
13#include <boost/enable_shared_from_this.hpp>
14#include <functional>
15
16namespace isc {
17namespace lease_query {
18
20 typedef std::function<void ()> BlqPostCbArg;
21
23 typedef std::function<void (const BlqPostCbArg&)> BlqPostCb;
24
26 typedef std::function<bool (BlqResponsePtr)> BlqPushToSendCb;
27
29 typedef std::function<void (Xid)> BlqQueryCompleteCb;
30
32class BulkLeaseQuery;
33
35 typedef boost::shared_ptr<BulkLeaseQuery> BulkLeaseQueryPtr;
36
38 class BulkLeaseQuery : public boost::enable_shared_from_this<BulkLeaseQuery> {
39public:
40
48 BulkLeaseQuery(BlqQueryPtr query,
49 const BlqPostCb& post,
50 const BlqPushToSendCb& push_to_send,
51 const BlqQueryCompleteCb& query_complete)
52 : query_(query), post_(post), push_to_send_(push_to_send),
53 query_complete_(query_complete), query_type_(0),
54 started_(false), done_(false) {
55 if (!query) {
56 isc_throw(BadValue, "BulkLeaseQuery query is null");
57 }
58 }
59
61 virtual ~BulkLeaseQuery() {
62 }
63
69 virtual void init() = 0;
70
72 virtual void start() = 0;
73
77 static void processStart(BulkLeaseQueryPtr ptr) {
78 if (!ptr) {
79 // Should not happen.
80 return;
81 }
82 ptr->start();
83 }
84
89 bool isProcessing() const {
90 return (started_);
91 }
92
96 bool isProcessed() const {
97 return (done_);
98 }
99
103 BlqQueryPtr getQuery() {
104 return (query_);
105 }
106
110 uint8_t getQueryType() const {
111 return (query_type_);
112 }
113
117 Xid getXid() const {
118 return (query_->getXid());
119 }
120
121protected:
123 virtual void setDone() {
124 done_ = true;
125 query_complete_(query_->getXid());
126 }
127
129 BlqQueryPtr query_;
130
132 BlqPostCb post_;
133
135 BlqPushToSendCb push_to_send_;
136
138 BlqQueryCompleteCb query_complete_;
139
141 uint8_t query_type_;
142
144 bool started_;
145
147 bool done_;
148};
149
150} // end of namespace isc::lease_query
151} // end of namespace isc
152
153#endif // BULK_LEASE_QUERY_H
blq_msg.h
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::lease_query::BulkLeaseQuery
Base class for providing control flow for processing a bulk query.
Definition bulk_lease_query.h:38
isc::lease_query::BulkLeaseQuery::query_complete_
BlqQueryCompleteCb query_complete_
The queryComplete callback.
Definition bulk_lease_query.h:138
isc::lease_query::BulkLeaseQuery::isProcessing
bool isProcessing() const
Processing in progress predicate.
Definition bulk_lease_query.h:89
isc::lease_query::BulkLeaseQuery::query_type_
uint8_t query_type_
The query type.
Definition bulk_lease_query.h:141
isc::lease_query::BulkLeaseQuery::start
virtual void start()=0
Start processing.
isc::lease_query::BulkLeaseQuery::setDone
virtual void setDone()
Set the done flag.
Definition bulk_lease_query.h:123
isc::lease_query::BulkLeaseQuery::getQuery
BlqQueryPtr getQuery()
Get the query.
Definition bulk_lease_query.h:103
isc::lease_query::BulkLeaseQuery::post_
BlqPostCb post_
The post callback.
Definition bulk_lease_query.h:132
isc::lease_query::BulkLeaseQuery::isProcessed
bool isProcessed() const
Processing finished predicate.
Definition bulk_lease_query.h:96
isc::lease_query::BulkLeaseQuery::~BulkLeaseQuery
virtual ~BulkLeaseQuery()
Destructor.
Definition bulk_lease_query.h:61
isc::lease_query::BulkLeaseQuery::BulkLeaseQuery
BulkLeaseQuery(BlqQueryPtr query, const BlqPostCb &post, const BlqPushToSendCb &push_to_send, const BlqQueryCompleteCb &query_complete)
Constructor.
Definition bulk_lease_query.h:48
isc::lease_query::BulkLeaseQuery::query_
BlqQueryPtr query_
The query.
Definition bulk_lease_query.h:129
isc::lease_query::BulkLeaseQuery::init
virtual void init()=0
Initialization.
isc::lease_query::BulkLeaseQuery::started_
bool started_
The processing is in progress.
Definition bulk_lease_query.h:144
isc::lease_query::BulkLeaseQuery::getQueryType
uint8_t getQueryType() const
Get the query type.
Definition bulk_lease_query.h:110
isc::lease_query::BulkLeaseQuery::push_to_send_
BlqPushToSendCb push_to_send_
The pushToSend callback.
Definition bulk_lease_query.h:135
isc::lease_query::BulkLeaseQuery::processStart
static void processStart(BulkLeaseQueryPtr ptr)
Class/static start processing.
Definition bulk_lease_query.h:77
isc::lease_query::BulkLeaseQuery::done_
bool done_
The processing finished.
Definition bulk_lease_query.h:147
isc::lease_query::BulkLeaseQuery::getXid
Xid getXid() const
Get the transaction id of the query.
Definition bulk_lease_query.h:117
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
isc::lease_query
Definition blq_msg.h:15
isc::lease_query::BlqResponsePtr
boost::shared_ptr< BlqResponse > BlqResponsePtr
Defines a shared pointer to an BlqResponse.
Definition blq_msg.h:143
isc::lease_query::BlqPostCb
std::function< void(const BlqPostCbArg &)> BlqPostCb
Type of BLQ post callback.
Definition bulk_lease_query.h:23
isc::lease_query::BlqQueryCompleteCb
std::function< void(Xid)> BlqQueryCompleteCb
Type of BLQ queryComplete callback.
Definition bulk_lease_query.h:29
isc::lease_query::BlqPostCbArg
std::function< void()> BlqPostCbArg
Type of BLQ post callback argument..
Definition bulk_lease_query.h:20
isc::lease_query::Xid
uint32_t Xid
Defines a Bulk LeaseQuery transaction id.
Definition blq_msg.h:18
isc::lease_query::BlqQueryPtr
boost::shared_ptr< BlqQuery > BlqQueryPtr
Defines a shared pointer to an BlqQuery.
Definition blq_msg.h:116
isc::lease_query::BulkLeaseQueryPtr
boost::shared_ptr< BulkLeaseQuery > BulkLeaseQueryPtr
Defines a shared pointer to a BulkLeaseQuery object.
Definition bulk_lease_query.h:35
isc::lease_query::BlqPushToSendCb
std::function< bool(BlqResponsePtr)> BlqPushToSendCb
Type of BLQ pushToSend callback.
Definition bulk_lease_query.h:26
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18