Kea 3.2.0-git
ha_impl.h
Go to the documentation of this file.
1// Copyright (C) 2018-2026 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
59 void stop();
60
72 return (config_->get());
73 }
74
80 HAConfigPtr getConfig(const std::string& partner_name) const {
81 return (config_->get(partner_name));
82 }
83
103 void buffer4Receive(hooks::CalloutHandle& callout_handle);
104
112 void subnet4Select(hooks::CalloutHandle& callout_handle);
113
117 void leases4Committed(hooks::CalloutHandle& callout_handle);
118
122 void lease4ServerDecline(hooks::CalloutHandle& callout_handle);
123
127 void lease4Expire(hooks::CalloutHandle& callout_handle);
128
148 void buffer6Receive(hooks::CalloutHandle& callout_handle);
149
150
158 void subnet6Select(hooks::CalloutHandle& callout_handle);
159
163 void leases6Committed(hooks::CalloutHandle& callout_handle);
164
168 void lease6Expire(hooks::CalloutHandle& callout_handle);
169
176 void commandProcessed(hooks::CalloutHandle& callout_handle);
177
181 void heartbeatHandler(hooks::CalloutHandle& callout_handle);
182
186 void synchronizeHandler(hooks::CalloutHandle& callout_handle);
187
191 void scopesHandler(hooks::CalloutHandle& callout_handle);
192
196 void continueHandler(hooks::CalloutHandle& callout_handle);
197
202
206 void maintenanceStartHandler(hooks::CalloutHandle& callout_handle);
207
212
216 void haResetHandler(hooks::CalloutHandle& callout_handle);
217
222
234 HAServicePtr getHAServiceByServerName(const std::string& command_name,
235 data::ConstElementPtr args) const;
236
243
248 io_service_ = io_service;
249 }
250
251protected:
252
265 virtual bool shouldReclaim(const HAServicePtr& service, const dhcp::Lease4Ptr& lease4) const;
266
279 virtual bool shouldReclaim(const HAServicePtr& service, const dhcp::Lease6Ptr& lease6) const;
280
283
286
289};
290
292typedef boost::shared_ptr<HAImpl> HAImplPtr;
293
294} // end of namespace isc::ha
295} // end of namespace isc
296
297#endif
void stop()
Stop the client and listener.
Definition ha_impl.cc:72
void setIOService(isc::asiolink::IOServicePtr io_service)
Set the hook I/O service.
Definition ha_impl.h:247
void scopesHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-scopes command.
Definition ha_impl.cc:831
void continueHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-continue command.
Definition ha_impl.cc:890
HAConfigPtr getConfig(const std::string &partner_name) const
Returns parsed configuration by partner name.
Definition ha_impl.h:80
void lease4Expire(hooks::CalloutHandle &callout_handle)
Implementation of the "lease4_expire" callout.
Definition ha_impl.cc:356
HAConfigMapperPtr config_
Holds parsed configuration.
Definition ha_impl.h:285
void syncCompleteNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync-complete-notify command.
Definition ha_impl.cc:1004
HAServicePtr getHAServiceByServerName(const std::string &command_name, data::ConstElementPtr args) const
Attempts to get an HAService by server name.
Definition ha_impl.cc:1050
HAServiceMapperPtr services_
Pointer to the high availability services (state machines).
Definition ha_impl.h:288
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:139
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:969
void haResetHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-reset command.
Definition ha_impl.cc:978
void maintenanceNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-notify command.
Definition ha_impl.cc:915
void synchronizeHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync command.
Definition ha_impl.cc:766
void maintenanceStartHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-start command.
Definition ha_impl.cc:955
isc::asiolink::IOServicePtr getIOService()
Get the hook I/O service.
Definition ha_impl.h:240
void lease6Expire(hooks::CalloutHandle &callout_handle)
Implementation of the "lease6_expire" callout.
Definition ha_impl.cc:649
isc::asiolink::IOServicePtr io_service_
The hook I/O service.
Definition ha_impl.h:282
void leases4Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases4_committed" callout.
Definition ha_impl.cc:231
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:1080
HAConfigPtr getConfig() const
Returns a configuration for the first relationship.
Definition ha_impl.h:71
void buffer4Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer4_receive" callout.
Definition ha_impl.cc:82
void buffer6Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer6_receive" callout.
Definition ha_impl.cc:413
void commandProcessed(hooks::CalloutHandle &callout_handle)
Implementation of the "command_processed" callout.
Definition ha_impl.cc:706
HAImpl()
Constructor.
Definition ha_impl.cc:34
void leases6Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases6_committed" callout.
Definition ha_impl.cc:564
void subnet6Select(hooks::CalloutHandle &callout_handle)
Implementation of the "subnet6_select" callout.
Definition ha_impl.cc:472
void lease4ServerDecline(hooks::CalloutHandle &callout_handle)
Implementation of the "lease4_server_decline" callout.
Definition ha_impl.cc:323
void heartbeatHandler(hooks::CalloutHandle &callout_handle)
Implements handle for the heartbeat command.
Definition ha_impl.cc:739
Per-packet callout handle.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
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:292
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.