| Kea 3.0.2-git

ha_service.h
Go to the documentation of this file.
1// Copyright (C) 2018-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 HA_SERVICE_H
8#define HA_SERVICE_H
9
10#include <communication_state.h>
11#include <ha_config.h>
12#include <ha_server_type.h>
13#include <lease_sync_filter.h>
14#include <lease_update_backlog.h>
15#include <query_filter.h>
16#include <asiolink/asio_wrapper.h>
17#include <asiolink/io_service.h>
18#include <asiolink/tls_socket.h>
19#include <cc/data.h>
20#include <config/cmd_http_listener.h>
21#include <dhcp/pkt4.h>
22#include <http/response.h>
23#include <dhcpsrv/lease.h>
24#include <dhcpsrv/network_state.h>
25#include <hooks/parking_lots.h>
26#include <http/client.h>
27#include <util/state_model.h>
28
29#include <boost/noncopyable.hpp>
30#include <boost/shared_ptr.hpp>
31#include <functional>
32#include <map>
33#include <mutex>
34#include <vector>
35
36 namespace isc {
37 namespace ha {
38
39 class HAService;
40
42 typedef HARelationshipMapper<HAService> HAServiceMapper;
43
45 typedef boost::shared_ptr<HAServiceMapper> HAServiceMapperPtr;
46
52 class HAService : public boost::noncopyable, public util::StateModel {
53 public:
54
56 static const int HA_HEARTBEAT_COMPLETE_EVT = SM_DERIVED_EVENT_MIN + 1;
57
59 static const int HA_LEASE_UPDATES_COMPLETE_EVT = SM_DERIVED_EVENT_MIN + 2;
60
62 static const int HA_SYNCING_FAILED_EVT = SM_DERIVED_EVENT_MIN + 3;
63
65 static const int HA_SYNCING_SUCCEEDED_EVT = SM_DERIVED_EVENT_MIN + 4;
66
68 static const int HA_MAINTENANCE_NOTIFY_EVT = SM_DERIVED_EVENT_MIN + 5;
69
71 static const int HA_MAINTENANCE_START_EVT = SM_DERIVED_EVENT_MIN + 6;
72
74 static const int HA_MAINTENANCE_CANCEL_EVT = SM_DERIVED_EVENT_MIN + 7;
75
78 static const int HA_SYNCED_PARTNER_UNAVAILABLE_EVT = SM_DERIVED_EVENT_MIN + 8;
79
81 static const int HA_CONTROL_RESULT_MAINTENANCE_NOT_ALLOWED = 1001;
82
85 static const int HA_WAITING_TO_TERMINATED_ST_DELAY_MINUTES = 10;
86
87 protected:
88
95 typedef std::function<void(const bool, const std::string&, const int)> PostRequestCallback;
96
104 typedef std::function<void(const bool, const std::string&, const bool)> PostSyncCallback;
105
106 public:
107
120 HAService(const unsigned int id,
121 const asiolink::IOServicePtr& io_service,
122 const dhcp::NetworkStatePtr& network_state,
123 const HAConfigPtr& config,
124 const HAServerType& server_type = HAServerType::DHCPv4);
125
130 virtual ~HAService();
131
133 HAServerType getServerType() const {
134 return (server_type_);
135 }
136
137 private:
138
143 unsigned int getLocalOrigin() const {
144 return (dhcp::NetworkState::HA_LOCAL_COMMAND + id_);
145 }
146
151 unsigned int getRemoteOrigin() const {
152 return (dhcp::NetworkState::HA_REMOTE_COMMAND + id_);
153 }
154
162 std::string getCSCallbacksSetName() const;
163
165 virtual void defineEvents();
166
168 virtual void verifyEvents();
169
171 virtual void defineStates();
172
185 void backupStateHandler();
186
214 void communicationRecoveryHandler();
215
244 void normalStateHandler();
245
255 void inMaintenanceStateHandler();
256
281 void partnerDownStateHandler();
282
303 void partnerInMaintenanceStateHandler();
304
312 void passiveBackupStateHandler();
313
329 void readyStateHandler();
330
347 void syncingStateHandler();
348
366 void terminatedStateHandler();
367
391 void waitingStateHandler();
392
395 int getPartnerState() const {
396 return (communication_state_->getPartnerState());
397 }
398
399 protected:
400
404 void verboseTransition(const unsigned state);
405
412 int getNormalState() const;
413
414 public:
415
423 bool unpause();
424
425 protected:
426
431 void conditionalLogPausedState() const;
432
433 public:
434
439 void serveDefaultScopes();
440
445 void serveFailoverScopes();
446
460 bool inScope(dhcp::Pkt4Ptr& query4);
461
475 bool inScope(dhcp::Pkt6Ptr& query6);
476
477 private:
478
492 template<typename QueryPtrType>
493 bool inScopeInternal(QueryPtrType& query);
494
495 public:
496
506 bool shouldReclaim(const dhcp::Lease4Ptr& lease4) const;
507
517 bool shouldReclaim(const dhcp::Lease6Ptr& lease6) const;
518
519 private:
520
531 template<typename LeaseTypePtr>
532 bool shouldReclaimInternal(const LeaseTypePtr& lease) const;
533
534 public:
535
540 void adjustNetworkState();
541
542 protected:
543
557 bool shouldPartnerDown() const;
558
577 bool shouldTerminate() const;
578
583 bool isMaintenanceCanceled() const;
584
600 bool isPartnerStateInvalid() const;
601
602 public:
603
637 size_t asyncSendLeaseUpdates(const dhcp::Pkt4Ptr& query,
638 const dhcp::Lease4CollectionPtr& leases,
639 const dhcp::Lease4CollectionPtr& deleted_leases,
640 const hooks::ParkingLotHandlePtr& parking_lot);
641
658 size_t asyncSendSingleLeaseUpdate(const dhcp::Pkt4Ptr& query,
659 const dhcp::Lease4Ptr& lease,
660 const hooks::ParkingLotHandlePtr& parking_lot);
661
680 size_t asyncSendLeaseUpdates(const dhcp::Pkt6Ptr& query,
681 const dhcp::Lease6CollectionPtr& leases,
682 const dhcp::Lease6CollectionPtr& deleted_leases,
683 const hooks::ParkingLotHandlePtr& parking_lot);
684
685 protected:
686
699 template<typename QueryPtrType>
700 void asyncSendLeaseUpdate(const QueryPtrType& query,
701 const HAConfig::PeerConfigPtr& config,
702 const data::ConstElementPtr& command,
703 const hooks::ParkingLotHandlePtr& parking_lot);
704
714 void logFailedLeaseUpdates(const dhcp::PktPtr& query,
715 const data::ConstElementPtr& args) const;
716
727 bool shouldSendLeaseUpdates(const HAConfig::PeerConfigPtr& peer_config) const;
728
740 bool shouldQueueLeaseUpdates(const HAConfig::PeerConfigPtr& peer_config) const;
741
742 public:
743
768 data::ConstElementPtr processHeartbeat();
769
774 data::ConstElementPtr processStatusGet() const;
775
788 data::ConstElementPtr processHAReset();
789
790 protected:
791
793 void asyncSendHeartbeat();
794
800 void scheduleHeartbeat();
801
803 void startHeartbeat();
804
816 void asyncDisableDHCPService(http::HttpClient& http_client,
817 const HAConfig::PeerConfigPtr& remote_config,
818 const unsigned int max_period,
819 PostRequestCallback post_request_action);
820
830 void asyncEnableDHCPService(http::HttpClient& http_client,
831 const HAConfig::PeerConfigPtr& remote_config,
832 PostRequestCallback post_request_action);
833
835 void localDisableDHCPService();
836
838 void localEnableDHCPService();
839
855 void asyncSyncLeases();
856
907 void asyncSyncLeases(http::HttpClient& http_client,
908 const HAConfig::PeerConfigPtr& remote_config,
909 const unsigned int max_period,
910 const dhcp::LeasePtr& last_lease,
911 PostSyncCallback post_sync_action,
912 const bool dhcp_disabled = false);
913
940 void asyncSyncLeasesInternal(http::HttpClient& http_client,
941 const HAConfig::PeerConfigPtr& remote_config,
942 const unsigned int max_period,
943 const dhcp::LeasePtr& last_lease,
944 PostSyncCallback post_sync_action,
945 const bool dhcp_disabled);
946
947 public:
948
968 data::ConstElementPtr processSynchronize(const std::string& server_name,
969 const unsigned int max_period);
970
971 protected:
972
993 int synchronize(std::string& status_message,
994 const HAConfig::PeerConfigPtr& remote_config,
995 const unsigned int max_period);
996
1015 void asyncSendLeaseUpdatesFromBacklog(http::HttpClient& http_client,
1016 const HAConfig::PeerConfigPtr& remote_config,
1017 PostRequestCallback post_request_action);
1018
1032 bool sendLeaseUpdatesFromBacklog();
1033
1040 void asyncSendHAReset(http::HttpClient& http_client,
1041 const HAConfig::PeerConfigPtr& remote_config,
1042 PostRequestCallback post_request_action);
1043
1056 bool sendHAReset();
1057
1058 public:
1059
1065 data::ConstElementPtr processScopes(const std::vector<std::string>& scopes);
1066
1070 data::ConstElementPtr processContinue();
1071
1094 data::ConstElementPtr processMaintenanceNotify(const bool cancel,
1095 const std::string& state);
1096
1113 data::ConstElementPtr processMaintenanceStart();
1114
1130 data::ConstElementPtr processMaintenanceCancel();
1131
1137 void checkPermissionsClientAndListener();
1138
1139 protected:
1140
1150 void asyncSyncCompleteNotify(http::HttpClient& http_client,
1151 const HAConfig::PeerConfigPtr& remote_config,
1152 PostRequestCallback post_request_action);
1153
1154 public:
1155
1169 data::ConstElementPtr processSyncCompleteNotify(const unsigned int origin_id);
1170
1178 void startClientAndListener();
1179
1186 void pauseClientAndListener();
1187
1194 void resumeClientAndListener();
1195
1201 void stopClientAndListener();
1202
1203 protected:
1204
1219 data::ConstElementPtr verifyAsyncResponse(const http::HttpResponsePtr& response,
1220 int& rcode);
1221
1231 bool clientConnectHandler(const boost::system::error_code& ec, int tcp_native_fd);
1232
1238 bool clientHandshakeHandler(const boost::system::error_code&) {
1239 return (true);
1240 }
1241
1258 void socketReadyHandler(int tcp_native_fd);
1259
1267 void clientCloseHandler(int tcp_native_fd);
1268
1270 unsigned int id_;
1271
1274 asiolink::IOServicePtr io_service_;
1275
1277 dhcp::NetworkStatePtr network_state_;
1278
1280 HAConfigPtr config_;
1281
1283 HAServerType server_type_;
1284
1286 http::HttpClientPtr client_;
1287
1290 config::CmdHttpListenerPtr listener_;
1291
1293 CommunicationStatePtr communication_state_;
1294
1296 QueryFilter query_filter_;
1297
1299 LeaseSyncFilter lease_sync_filter_;
1300
1317 template<typename QueryPtrType>
1318 bool leaseUpdateComplete(QueryPtrType& query,
1319 const hooks::ParkingLotHandlePtr& parking_lot);
1320
1326 template<typename QueryPtrType>
1327 void updatePendingRequest(QueryPtrType& query);
1328
1333 size_t pendingRequestSize();
1334
1344 template<typename QueryPtrType>
1345 int getPendingRequest(const QueryPtrType& query);
1346
1347 private:
1366 template<typename QueryPtrType>
1367 bool leaseUpdateCompleteInternal(QueryPtrType& query,
1368 const hooks::ParkingLotHandlePtr& parking_lot);
1369
1377 template<typename QueryPtrType>
1378 void updatePendingRequestInternal(QueryPtrType& query);
1379
1390 template<typename QueryPtrType>
1391 int getPendingRequestInternal(const QueryPtrType& query);
1392
1394 std::mutex mutex_;
1395
1404 std::map<boost::shared_ptr<dhcp::Pkt>, int> pending_requests_;
1405
1406 protected:
1407
1413 LeaseUpdateBacklog lease_update_backlog_;
1414
1422 bool sync_complete_notified_;
1423};
1424
1426 typedef boost::shared_ptr<HAService> HAServicePtr;
1427
1428} // end of namespace isc::ha
1429} // end of namespace isc
1430
1431#endif
asio_wrapper.h
isc::dhcp::NetworkState::HA_LOCAL_COMMAND
static const unsigned int HA_LOCAL_COMMAND
The network state is being altered by an HA internal command.
Definition network_state.h:88
isc::dhcp::NetworkState::HA_REMOTE_COMMAND
static const unsigned int HA_REMOTE_COMMAND
The network state is being altered by a "dhcp-disable" or "dhcp-enable" command sent by a HA partner.
Definition network_state.h:95
isc::ha::HAConfig::PeerConfigPtr
boost::shared_ptr< PeerConfig > PeerConfigPtr
Pointer to the server's configuration.
Definition ha_config.h:242
isc::ha::HARelationshipMapper
Holds associations between objects and HA relationships.
Definition ha_relationship_mapper.h:33
isc::ha::HAService
High availability service.
Definition ha_service.h:52
isc::ha::HAService::HA_MAINTENANCE_START_EVT
static const int HA_MAINTENANCE_START_EVT
ha-maintenance-start command received.
Definition ha_service.h:71
isc::ha::HAService::inScope
bool inScope(dhcp::Pkt4Ptr &query4)
Checks if the DHCPv4 query should be processed by this server.
Definition ha_service.cc:1059
isc::ha::HAService::adjustNetworkState
void adjustNetworkState()
Enables or disables network state depending on the served scopes.
Definition ha_service.cc:1105
isc::ha::HAService::stopClientAndListener
void stopClientAndListener()
Stop the client and(or) listener instances.
Definition ha_service.cc:3469
isc::ha::HAService::getNormalState
int getNormalState() const
Returns normal operation state for the current configuration.
Definition ha_service.cc:1010
isc::ha::HAService::shouldQueueLeaseUpdates
bool shouldQueueLeaseUpdates(const HAConfig::PeerConfigPtr &peer_config) const
Checks if the lease updates should be queued.
Definition ha_service.cc:1624
isc::ha::HAService::HA_HEARTBEAT_COMPLETE_EVT
static const int HA_HEARTBEAT_COMPLETE_EVT
Finished heartbeat command.
Definition ha_service.h:56
isc::ha::HAService::asyncSendHAReset
void asyncSendHAReset(http::HttpClient &http_client, const HAConfig::PeerConfigPtr &remote_config, PostRequestCallback post_request_action)
Sends ha-reset command to partner asynchronously.
Definition ha_service.cc:2665
isc::ha::HAService::clientConnectHandler
bool clientConnectHandler(const boost::system::error_code &ec, int tcp_native_fd)
HttpClient connect callback handler.
Definition ha_service.cc:3308
isc::ha::HAService::asyncSyncLeases
void asyncSyncLeases()
Asynchronously reads leases from a peer and updates local lease database.
Definition ha_service.cc:2121
isc::ha::HAService::isMaintenanceCanceled
bool isMaintenanceCanceled() const
Convenience method checking if the current state is a result of canceling the maintenance.
Definition ha_service.cc:1180
isc::ha::HAService::processMaintenanceCancel
data::ConstElementPtr processMaintenanceCancel()
Processes ha-maintenance-cancel command and returns a response.
Definition ha_service.cc:2953
isc::ha::HAService::checkPermissionsClientAndListener
void checkPermissionsClientAndListener()
Check client and(or) listener current thread permissions to perform thread pool state transition.
Definition ha_service.cc:3386
isc::ha::HAService::shouldReclaim
bool shouldReclaim(const dhcp::Lease4Ptr &lease4) const
Checks if the lease should be reclaimed by this server.
Definition ha_service.cc:1089
isc::ha::HAService::asyncSendLeaseUpdate
void asyncSendLeaseUpdate(const QueryPtrType &query, const HAConfig::PeerConfigPtr &config, const data::ConstElementPtr &command, const hooks::ParkingLotHandlePtr &parking_lot)
Asynchronously sends lease update to the peer.
Definition ha_service.cc:1434
isc::ha::HAService::verboseTransition
void verboseTransition(const unsigned state)
Transitions to a desired state and logs it.
Definition ha_service.cc:939
isc::ha::HAService::sendLeaseUpdatesFromBacklog
bool sendLeaseUpdatesFromBacklog()
Attempts to send all lease updates from the backlog synchronously.
Definition ha_service.cc:2617
isc::ha::HAService::listener_
config::CmdHttpListenerPtr listener_
HTTP listener instance used to receive and respond to HA commands and lease updates.
Definition ha_service.h:1290
isc::ha::HAService::clientCloseHandler
void clientCloseHandler(int tcp_native_fd)
HttpClient close callback handler.
Definition ha_service.cc:3348
isc::ha::HAService::leaseUpdateComplete
bool leaseUpdateComplete(QueryPtrType &query, const hooks::ParkingLotHandlePtr &parking_lot)
Handle last pending request for this query.
Definition ha_service.cc:1378
isc::ha::HAService::config_
HAConfigPtr config_
Pointer to the HA hooks library configuration.
Definition ha_service.h:1280
isc::ha::HAService::processMaintenanceStart
data::ConstElementPtr processMaintenanceStart()
Processes ha-maintenance-start command and returns a response.
Definition ha_service.cc:2816
isc::ha::HAService::id_
unsigned int id_
Unique service id.
Definition ha_service.h:1270
isc::ha::HAService::server_type_
HAServerType server_type_
DHCP server type.
Definition ha_service.h:1283
isc::ha::HAService::sync_complete_notified_
bool sync_complete_notified_
An indicator that a partner sent ha-sync-complete-notify command.
Definition ha_service.h:1422
isc::ha::HAService::shouldTerminate
bool shouldTerminate() const
Indicates if the server should transition to the terminated state.
Definition ha_service.cc:1164
isc::ha::HAService::processScopes
data::ConstElementPtr processScopes(const std::vector< std::string > &scopes)
Processes ha-scopes command and returns a response.
Definition ha_service.cc:2741
isc::ha::HAService::network_state_
dhcp::NetworkStatePtr network_state_
Pointer to the state of the DHCP service (enabled/disabled).
Definition ha_service.h:1277
isc::ha::HAService::processSynchronize
data::ConstElementPtr processSynchronize(const std::string &server_name, const unsigned int max_period)
Processes ha-sync command and returns a response.
Definition ha_service.cc:2385
isc::ha::HAService::scheduleHeartbeat
void scheduleHeartbeat()
Schedules asynchronous heartbeat to a peer if it is not scheduled.
Definition ha_service.cc:1936
isc::ha::HAService::asyncSyncCompleteNotify
void asyncSyncCompleteNotify(http::HttpClient &http_client, const HAConfig::PeerConfigPtr &remote_config, PostRequestCallback post_request_action)
Schedules asynchronous "ha-sync-complete-notify" command to the specified server.
Definition ha_service.cc:3081
isc::ha::HAService::query_filter_
QueryFilter query_filter_
Selects queries to be processed/dropped.
Definition ha_service.h:1296
isc::ha::HAService::HA_MAINTENANCE_NOTIFY_EVT
static const int HA_MAINTENANCE_NOTIFY_EVT
ha-maintenance-notify command received.
Definition ha_service.h:68
isc::ha::HAService::HA_SYNCED_PARTNER_UNAVAILABLE_EVT
static const int HA_SYNCED_PARTNER_UNAVAILABLE_EVT
The heartbeat command failed after receiving ha-sync-complete-notify command from the partner.
Definition ha_service.h:78
isc::ha::HAService::processMaintenanceNotify
data::ConstElementPtr processMaintenanceNotify(const bool cancel, const std::string &state)
Processes ha-maintenance-notify command and returns a response.
Definition ha_service.cc:2762
isc::ha::HAService::conditionalLogPausedState
void conditionalLogPausedState() const
Logs if the server is paused in the current state.
Definition ha_service.cc:1037
isc::ha::HAService::unpause
bool unpause()
Unpauses the HA state machine with logging.
Definition ha_service.cc:1026
isc::ha::HAService::HA_CONTROL_RESULT_MAINTENANCE_NOT_ALLOWED
static const int HA_CONTROL_RESULT_MAINTENANCE_NOT_ALLOWED
Control result returned in response to ha-maintenance-notify.
Definition ha_service.h:81
isc::ha::HAService::serveDefaultScopes
void serveDefaultScopes()
Instructs the HA service to serve default scopes.
Definition ha_service.cc:1049
isc::ha::HAService::asyncSendLeaseUpdates
size_t asyncSendLeaseUpdates(const dhcp::Pkt4Ptr &query, const dhcp::Lease4CollectionPtr &leases, const dhcp::Lease4CollectionPtr &deleted_leases, const hooks::ParkingLotHandlePtr &parking_lot)
Schedules asynchronous IPv4 leases updates.
Definition ha_service.cc:1218
isc::ha::HAService::pendingRequestSize
size_t pendingRequestSize()
Get the number of entries in the pending request map.
Definition ha_service.cc:3355
isc::ha::HAService::HA_SYNCING_SUCCEEDED_EVT
static const int HA_SYNCING_SUCCEEDED_EVT
Lease database synchronization succeeded.
Definition ha_service.h:65
isc::ha::HAService::sendHAReset
bool sendHAReset()
Sends ha-reset command to partner synchronously.
Definition ha_service.cc:2718
isc::ha::HAService::PostRequestCallback
std::function< void(const bool, const std::string &, const int)> PostRequestCallback
Callback invoked when request was sent and a response received or an error occurred.
Definition ha_service.h:95
isc::ha::HAService::io_service_
asiolink::IOServicePtr io_service_
Pointer to the IO service object shared between this hooks library and the DHCP server.
Definition ha_service.h:1274
isc::ha::HAService::localDisableDHCPService
void localDisableDHCPService()
Disables local DHCP service.
Definition ha_service.cc:2111
isc::ha::HAService::communication_state_
CommunicationStatePtr communication_state_
Holds communication state with a peer.
Definition ha_service.h:1293
isc::ha::HAService::logFailedLeaseUpdates
void logFailedLeaseUpdates(const dhcp::PktPtr &query, const data::ConstElementPtr &args) const
Log failed lease updates.
Definition ha_service.cc:1637
isc::ha::HAService::clientHandshakeHandler
bool clientHandshakeHandler(const boost::system::error_code &)
HttpClient handshake callback handler.
Definition ha_service.h:1238
isc::ha::HAService::lease_update_backlog_
LeaseUpdateBacklog lease_update_backlog_
Backlog of DHCP lease updates.
Definition ha_service.h:1413
isc::ha::HAService::~HAService
virtual ~HAService()
Destructor.
Definition ha_service.cc:147
isc::ha::HAService::HA_SYNCING_FAILED_EVT
static const int HA_SYNCING_FAILED_EVT
Lease database synchronization failed.
Definition ha_service.h:62
isc::ha::HAService::HA_MAINTENANCE_CANCEL_EVT
static const int HA_MAINTENANCE_CANCEL_EVT
ha-maintenance-cancel command received.
Definition ha_service.h:74
isc::ha::HAService::asyncSendLeaseUpdatesFromBacklog
void asyncSendLeaseUpdatesFromBacklog(http::HttpClient &http_client, const HAConfig::PeerConfigPtr &remote_config, PostRequestCallback post_request_action)
Sends lease updates from backlog to partner asynchronously.
Definition ha_service.cc:2539
isc::ha::HAService::processHeartbeat
data::ConstElementPtr processHeartbeat()
Processes ha-heartbeat command and returns a response.
Definition ha_service.cc:1746
isc::ha::HAService::asyncSyncLeasesInternal
void asyncSyncLeasesInternal(http::HttpClient &http_client, const HAConfig::PeerConfigPtr &remote_config, const unsigned int max_period, const dhcp::LeasePtr &last_lease, PostSyncCallback post_sync_action, const bool dhcp_disabled)
Implements fetching one page of leases during synchronization.
Definition ha_service.cc:2169
isc::ha::HAService::processHAReset
data::ConstElementPtr processHAReset()
Processes ha-reset command and returns a response.
Definition ha_service.cc:1769
isc::ha::HAService::asyncSendSingleLeaseUpdate
size_t asyncSendSingleLeaseUpdate(const dhcp::Pkt4Ptr &query, const dhcp::Lease4Ptr &lease, const hooks::ParkingLotHandlePtr &parking_lot)
Schedules an asynchronous IPv4 lease update.
Definition ha_service.cc:1300
isc::ha::HAService::asyncSendHeartbeat
void asyncSendHeartbeat()
Starts asynchronous heartbeat to a peer.
Definition ha_service.cc:1779
isc::ha::HAService::isPartnerStateInvalid
bool isPartnerStateInvalid() const
Indicates if the partner's state is invalid.
Definition ha_service.cc:1185
isc::ha::HAService::startClientAndListener
void startClientAndListener()
Start the client and(or) listener instances.
Definition ha_service.cc:3415
isc::ha::HAService::verifyAsyncResponse
data::ConstElementPtr verifyAsyncResponse(const http::HttpResponsePtr &response, int &rcode)
Checks if the response is valid or contains an error.
Definition ha_service.cc:3185
isc::ha::HAService::resumeClientAndListener
void resumeClientAndListener()
Resumes client and(or) listener thread pool operations.
Definition ha_service.cc:3450
isc::ha::HAService::processStatusGet
data::ConstElementPtr processStatusGet() const
Processes status-get command and returns a response.
Definition ha_service.cc:1689
isc::ha::HAService::getPendingRequest
int getPendingRequest(const QueryPtrType &query)
Get the number of scheduled requests for a given query.
Definition ha_service.cc:3366
isc::ha::HAService::lease_sync_filter_
LeaseSyncFilter lease_sync_filter_
Lease synchronization filter used in hub-and-spoke model.
Definition ha_service.h:1299
isc::ha::HAService::synchronize
int synchronize(std::string &status_message, const HAConfig::PeerConfigPtr &remote_config, const unsigned int max_period)
Synchronizes lease database with a partner.
Definition ha_service.cc:2404
isc::ha::HAService::shouldSendLeaseUpdates
bool shouldSendLeaseUpdates(const HAConfig::PeerConfigPtr &peer_config) const
Checks if the lease updates should be sent as result of leases allocation or release.
Definition ha_service.cc:1592
isc::ha::HAService::serveFailoverScopes
void serveFailoverScopes()
Instructs the HA service to serve failover scopes.
Definition ha_service.cc:1054
isc::ha::HAService::localEnableDHCPService
void localEnableDHCPService()
Enables local DHCP service.
Definition ha_service.cc:2116
isc::ha::HAService::HA_LEASE_UPDATES_COMPLETE_EVT
static const int HA_LEASE_UPDATES_COMPLETE_EVT
Finished lease updates commands.
Definition ha_service.h:59
isc::ha::HAService::HAService
HAService(const unsigned int id, const asiolink::IOServicePtr &io_service, const dhcp::NetworkStatePtr &network_state, const HAConfigPtr &config, const HAServerType &server_type=HAServerType::DHCPv4)
Constructor.
Definition ha_service.cc:76
isc::ha::HAService::getServerType
HAServerType getServerType() const
Returns HA server type used in object construction.
Definition ha_service.h:133
isc::ha::HAService::socketReadyHandler
void socketReadyHandler(int tcp_native_fd)
IfaceMgr external socket ready callback handler.
Definition ha_service.cc:3339
isc::ha::HAService::client_
http::HttpClientPtr client_
HTTP client instance used to send HA commands and lease updates.
Definition ha_service.h:1286
isc::ha::HAService::updatePendingRequest
void updatePendingRequest(QueryPtrType &query)
Update pending request counter for this query.
Definition ha_service.cc:1413
isc::ha::HAService::shouldPartnerDown
bool shouldPartnerDown() const
Indicates if the server should transition to the partner down state.
Definition ha_service.cc:1137
isc::ha::HAService::startHeartbeat
void startHeartbeat()
Unconditionally starts one heartbeat to a peer.
Definition ha_service.cc:1943
isc::ha::HAService::processSyncCompleteNotify
data::ConstElementPtr processSyncCompleteNotify(const unsigned int origin_id)
Process ha-sync-complete-notify command and returns a response.
Definition ha_service.cc:3164
isc::ha::HAService::processContinue
data::ConstElementPtr processContinue()
Processes ha-continue command and returns a response.
Definition ha_service.cc:2754
isc::ha::HAService::asyncDisableDHCPService
void asyncDisableDHCPService(http::HttpClient &http_client, const HAConfig::PeerConfigPtr &remote_config, const unsigned int max_period, PostRequestCallback post_request_action)
Schedules asynchronous "dhcp-disable" command to the specified server.
Definition ha_service.cc:1952
isc::ha::HAService::pauseClientAndListener
void pauseClientAndListener()
Pauses client and(or) listener thread pool operations.
Definition ha_service.cc:3432
isc::ha::HAService::PostSyncCallback
std::function< void(const bool, const std::string &, const bool)> PostSyncCallback
Callback invoked when lease database synchronization is complete.
Definition ha_service.h:104
isc::ha::HAService::HA_WAITING_TO_TERMINATED_ST_DELAY_MINUTES
static const int HA_WAITING_TO_TERMINATED_ST_DELAY_MINUTES
A delay in minutes to transition from the waiting to terminated state when the partner remains in ter...
Definition ha_service.h:85
isc::ha::HAService::asyncEnableDHCPService
void asyncEnableDHCPService(http::HttpClient &http_client, const HAConfig::PeerConfigPtr &remote_config, PostRequestCallback post_request_action)
Schedules asynchronous "dhcp-enable" command to the specified server.
Definition ha_service.cc:2033
isc::ha::LeaseSyncFilter
Checks if a lease fetched from the other server should be synchronized into the local lease database.
Definition lease_sync_filter.h:52
isc::ha::LeaseUpdateBacklog
Queue holding a backlog of unsent lease updates.
Definition lease_update_backlog.h:45
isc::ha::QueryFilter
DHCP query filtering class.
Definition query_filter.h:61
isc::util::StateModel
Implements a finite state machine.
Definition state_model.h:274
isc::util::StateModel::defineEvents
virtual void defineEvents()
Populates the set of events.
Definition state_model.cc:229
isc::util::StateModel::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition state_model.cc:237
isc::util::StateModel::defineStates
virtual void defineStates()
Populates the set of states.
Definition state_model.cc:245
isc::util::StateModel::SM_DERIVED_EVENT_MIN
static const int SM_DERIVED_EVENT_MIN
Value at which custom events in a derived class should begin.
Definition state_model.h:304
cmd_http_listener.h
communication_state.h
data.h
ha_config.h
ha_server_type.h
io_service.h
lease.h
lease_sync_filter.h
lease_update_backlog.h
client.h
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:28
isc::config
Definition command_interpreter.cc:23
isc::config::CmdHttpListenerPtr
boost::shared_ptr< CmdHttpListener > CmdHttpListenerPtr
Defines a shared pointer to CmdHttpListener.
Definition cmd_http_listener.h:155
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::dhcp::PktPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:998
isc::dhcp::Lease4CollectionPtr
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
Definition lease.h:523
isc::dhcp::Pkt4Ptr
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:555
isc::dhcp::Lease6Ptr
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition lease.h:528
isc::dhcp::LeasePtr
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
Definition lease.h:25
isc::dhcp::NetworkStatePtr
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
Definition network_state.h:220
isc::dhcp::Lease6CollectionPtr
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
Definition lease.h:696
isc::dhcp::Pkt6Ptr
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition pkt6.h:31
isc::dhcp::Lease4Ptr
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
isc::ha
Definition command_creator.cc:20
isc::ha::CommunicationStatePtr
boost::shared_ptr< CommunicationState > CommunicationStatePtr
Type of the pointer to the CommunicationState object.
Definition communication_state.h:780
isc::ha::HAServiceMapper
HARelationshipMapper< HAService > HAServiceMapper
Type of an object mapping HAService to relationships.
Definition ha_service.h:42
isc::ha::HAServiceMapperPtr
boost::shared_ptr< HAServiceMapper > HAServiceMapperPtr
Pointer to an object mapping HAService to relationships.
Definition ha_service.h:45
isc::ha::HAConfigPtr
boost::shared_ptr< HAConfig > HAConfigPtr
Pointer to the High Availability configuration structure.
Definition ha_config.h:37
isc::ha::HAServerType
HAServerType
Lists possible server types for which HA service is created.
Definition ha_server_type.h:14
isc::ha::HAServerType::DHCPv4
@ DHCPv4
Definition ha_server_type.h:15
isc::ha::HAServicePtr
boost::shared_ptr< HAService > HAServicePtr
Pointer to the HAService class.
Definition ha_service.h:1426
isc::hooks::ParkingLotHandlePtr
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
Definition parking_lots.h:381
isc::http::HttpClientPtr
boost::shared_ptr< HttpClient > HttpClientPtr
Defines a pointer to an HttpClient instance.
Definition lib/http/client.h:339
isc::http::HttpResponsePtr
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
Definition response.h:81
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
network_state.h
parking_lots.h
pkt4.h
query_filter.h
response.h
state_model.h
This file defines the class StateModel.
tls_socket.h