Kea 2.7.7
ha_impl.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_IMPL_H
8#define HA_IMPL_H
9
10#include <ha_config.h>
11#include <ha_service.h>
12#include <asiolink/io_service.h>
13#include <cc/data.h>
15#include <hooks/hooks.h>
16#include <boost/noncopyable.hpp>
17#include <boost/shared_ptr.hpp>
18
19
20namespace isc {
21namespace ha {
22
31class HAImpl : public boost::noncopyable {
32public:
33
35 HAImpl();
36
41 void configure(const data::ConstElementPtr& input_config);
42
52 void startServices(const dhcp::NetworkStatePtr& network_state,
53 const HAServerType& server_type);
54
56 virtual ~HAImpl();
57
69 return (config_->get());
70 }
71
77 HAConfigPtr getConfig(const std::string& partner_name) const {
78 return (config_->get(partner_name));
79 }
80
100 void buffer4Receive(hooks::CalloutHandle& callout_handle);
101
109 void subnet4Select(hooks::CalloutHandle& callout_handle);
110
114 void leases4Committed(hooks::CalloutHandle& callout_handle);
115
119 void lease4ServerDecline(hooks::CalloutHandle& callout_handle);
120
124 void lease4Expire(hooks::CalloutHandle& callout_handle);
125
145 void buffer6Receive(hooks::CalloutHandle& callout_handle);
146
147
155 void subnet6Select(hooks::CalloutHandle& callout_handle);
156
160 void leases6Committed(hooks::CalloutHandle& callout_handle);
161
165 void lease6Expire(hooks::CalloutHandle& callout_handle);
166
173 void commandProcessed(hooks::CalloutHandle& callout_handle);
174
178 void heartbeatHandler(hooks::CalloutHandle& callout_handle);
179
183 void synchronizeHandler(hooks::CalloutHandle& callout_handle);
184
188 void scopesHandler(hooks::CalloutHandle& callout_handle);
189
193 void continueHandler(hooks::CalloutHandle& callout_handle);
194
199
203 void maintenanceStartHandler(hooks::CalloutHandle& callout_handle);
204
209
213 void haResetHandler(hooks::CalloutHandle& callout_handle);
214
219
231 HAServicePtr getHAServiceByServerName(const std::string& command_name,
232 data::ConstElementPtr args) const;
233
240
245 io_service_ = io_service;
246 }
247
248protected:
249
262 virtual bool shouldReclaim(const HAServicePtr& service, const dhcp::Lease4Ptr& lease4) const;
263
276 virtual bool shouldReclaim(const HAServicePtr& service, const dhcp::Lease6Ptr& lease6) const;
277
280
283
286};
287
289typedef boost::shared_ptr<HAImpl> HAImplPtr;
290
291} // end of namespace isc::ha
292} // end of namespace isc
293
294#endif
High Availability hooks library implementation.
Definition ha_impl.h:31
void setIOService(isc::asiolink::IOServicePtr io_service)
Set the hook I/O service.
Definition ha_impl.h:244
void scopesHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-scopes command.
Definition ha_impl.cc:803
void continueHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-continue command.
Definition ha_impl.cc:862
HAConfigPtr getConfig(const std::string &partner_name) const
Returns parsed configuration by partner name.
Definition ha_impl.h:77
void lease4Expire(hooks::CalloutHandle &callout_handle)
Implementation of the "lease4_expire" callout.
Definition ha_impl.cc:340
HAConfigMapperPtr config_
Holds parsed configuration.
Definition ha_impl.h:282
void syncCompleteNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync-complete-notify command.
Definition ha_impl.cc:976
HAServicePtr getHAServiceByServerName(const std::string &command_name, data::ConstElementPtr args) const
Attempts to get an HAService by server name.
Definition ha_impl.cc:1022
HAServiceMapperPtr services_
Pointer to the high availability services (state machines).
Definition ha_impl.h:285
void startServices(const dhcp::NetworkStatePtr &network_state, const HAServerType &server_type)
Creates high availability services using current configuration.
Definition ha_impl.cc:44
void subnet4Select(hooks::CalloutHandle &callout_handle)
Implementation of the "subnet4_select" callout.
Definition ha_impl.cc:133
void configure(const data::ConstElementPtr &input_config)
Parses configuration.
Definition ha_impl.cc:39
virtual ~HAImpl()
Destructor.
Definition ha_impl.cc:64
void maintenanceCancelHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-cancel command.
Definition ha_impl.cc:941
void haResetHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-reset command.
Definition ha_impl.cc:950
void maintenanceNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-notify command.
Definition ha_impl.cc:887
void synchronizeHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync command.
Definition ha_impl.cc:738
void maintenanceStartHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-start command.
Definition ha_impl.cc:927
isc::asiolink::IOServicePtr getIOService()
Get the hook I/O service.
Definition ha_impl.h:237
void lease6Expire(hooks::CalloutHandle &callout_handle)
Implementation of the "lease6_expire" callout.
Definition ha_impl.cc:621
isc::asiolink::IOServicePtr io_service_
The hook I/O service.
Definition ha_impl.h:279
void leases4Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases4_committed" callout.
Definition ha_impl.cc:217
virtual bool shouldReclaim(const HAServicePtr &service, const dhcp::Lease4Ptr &lease4) const
Checks if the lease should be reclaimed by this server.
Definition ha_impl.cc:1052
HAConfigPtr getConfig() const
Returns a configuration for the first relationship.
Definition ha_impl.h:68
void buffer4Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer4_receive" callout.
Definition ha_impl.cc:76
void buffer6Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer6_receive" callout.
Definition ha_impl.cc:397
void commandProcessed(hooks::CalloutHandle &callout_handle)
Implementation of the "command_processed" callout.
Definition ha_impl.cc:678
HAImpl()
Constructor.
Definition ha_impl.cc:34
void leases6Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases6_committed" callout.
Definition ha_impl.cc:538
void subnet6Select(hooks::CalloutHandle &callout_handle)
Implementation of the "subnet6_select" callout.
Definition ha_impl.cc:454
void lease4ServerDecline(hooks::CalloutHandle &callout_handle)
Implementation of the "lease4_server_decline" callout.
Definition ha_impl.cc:307
void heartbeatHandler(hooks::CalloutHandle &callout_handle)
Implements handle for the heartbeat command.
Definition ha_impl.cc:711
Per-packet callout handle.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition lease.h:528
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
boost::shared_ptr< HAImpl > HAImplPtr
Pointer to the High Availability hooks library implementation.
Definition ha_impl.h:289
boost::shared_ptr< HAConfigMapper > HAConfigMapperPtr
Pointer to an object mapping HAConfig to relationships.
Definition ha_config.h:43
boost::shared_ptr< HAServiceMapper > HAServiceMapperPtr
Pointer to an object mapping HAService to relationships.
Definition ha_service.h:45
boost::shared_ptr< HAConfig > HAConfigPtr
Pointer to the High Availability configuration structure.
Definition ha_config.h:37
HAServerType
Lists possible server types for which HA service is created.
boost::shared_ptr< HAService > HAServicePtr
Pointer to the HAService class.
Defines the logger used by the top-level component of kea-lfc.