Kea
1.9.9-git
|
High Availability hooks library implementation. More...
#include <ha_impl.h>
Public Member Functions | |
HAImpl () | |
Constructor. More... | |
~HAImpl () | |
Destructor. More... | |
void | buffer4Receive (hooks::CalloutHandle &callout_handle) |
Implementation of the "buffer4_receive" callout. More... | |
void | buffer6Receive (hooks::CalloutHandle &callout_handle) |
Implementation of the "buffer6_receive" callout. More... | |
void | commandProcessed (hooks::CalloutHandle &callout_handle) |
Implementation of the "command_processed" callout. More... | |
void | configure (const data::ConstElementPtr &input_config) |
Parses configuration. More... | |
void | continueHandler (hooks::CalloutHandle &callout_handle) |
Implements handler for the ha-continue command. More... | |
HAConfigPtr | getConfig () const |
Returns parsed configuration. More... | |
void | haResetHandler (hooks::CalloutHandle &callout_handle) |
Implements handler for the ha-reset command. More... | |
void | heartbeatHandler (hooks::CalloutHandle &callout_handle) |
Implements handle for the heartbeat command. More... | |
void | leases4Committed (hooks::CalloutHandle &callout_handle) |
Implementation of the "leases4_committed" callout. More... | |
void | leases6Committed (hooks::CalloutHandle &callout_handle) |
Implementation of the "leases6_committed" callout. More... | |
void | maintenanceCancelHandler (hooks::CalloutHandle &callout_handle) |
Implements handler for the ha-maintenance-cancel command. More... | |
void | maintenanceNotifyHandler (hooks::CalloutHandle &callout_handle) |
Implements handler for the ha-maintenance-notify command. More... | |
void | maintenanceStartHandler (hooks::CalloutHandle &callout_handle) |
Implements handler for the ha-maintenance-start command. More... | |
void | scopesHandler (hooks::CalloutHandle &callout_handle) |
Implements handler for the ha-scopes command. More... | |
void | startService (const asiolink::IOServicePtr &io_service, const dhcp::NetworkStatePtr &network_state, const HAServerType &server_type) |
Creates high availability service using current configuration. More... | |
void | synchronizeHandler (hooks::CalloutHandle &callout_handle) |
Implements handler for the ha-sync command. More... | |
Protected Attributes | |
HAConfigPtr | config_ |
Holds parsed configuration. More... | |
HAServicePtr | service_ |
Pointer to the high availability service (state machine). More... | |
High Availability hooks library implementation.
This object provides an interface between the HA hook library callouts and the HA state model implemented in the HAService
. Callouts invoke respective methods of the HAImpl
to configure the service, generate lease updates etc. The HAImpl
retrieves and validates the arguments provided within CalloutHandle
object and then invokes appropriate methods of the HAService
class.
isc::ha::HAImpl::HAImpl | ( | ) |
Constructor.
Definition at line 30 of file ha_impl.cc.
isc::ha::HAImpl::~HAImpl | ( | ) |
void isc::ha::HAImpl::buffer4Receive | ( | hooks::CalloutHandle & | callout_handle | ) |
Implementation of the "buffer4_receive" callout.
This callout uses HA service to check if the query should be processed by this server or a partner. If the partner should process the query, this callout sets the status to CalloutHandle::NEXT_STEP_DROP
to cause the server to drop the packet. Therefore it is important to note that, if multiple hook libraries implementing buffer4_receive
hook are loaded, the order of loading the libraries may matter. If this library sets the status to CalloutHandle::NEXT_STEP_DROP
and the other library overrides this status, the query will be processed by the server instead of being dropped. This problem may be mitigated by loading the HA library last, i.e. placing the library at the end of the "hooks-libraries" list within a Kea configuration file.
If the received query is to be processed by this server instance, the CalloutHabndle::NEXT_STEP_SKIP
status is set to prevent the server from unpacking the query because the query is unpacked by the callout.
callout_handle | Callout handle provided to the callout. |
Definition at line 61 of file ha_impl.cc.
References isc::stats::StatsMgr::addValue(), isc::log::DBGLVL_TRACE_BASIC, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::ha::HA_BUFFER4_RECEIVE_NOT_FOR_US, isc::ha::HA_BUFFER4_RECEIVE_PACKET_OPTIONS_SKIPPED, isc::ha::HA_BUFFER4_RECEIVE_UNPACK_FAILED, isc::ha::ha_logger, isc::stats::StatsMgr::instance(), LOG_DEBUG, service_, isc::hooks::CalloutHandle::setStatus(), and isc::Exception::what().
void isc::ha::HAImpl::buffer6Receive | ( | hooks::CalloutHandle & | callout_handle | ) |
Implementation of the "buffer6_receive" callout.
This callout uses HA service to check if the query should be processed by this server or a partner. If the partner should process the query, this callout sets the status to CalloutHandle::NEXT_STEP_DROP
to cause the server to drop the packet. Therefore it is important to note that, if multiple hook libraries implementing buffer6_receive
hook are loaded, the order of loading the libraries may matter. If this library sets the status to CalloutHandle::NEXT_STEP_DROP
and the other library overrides this status, the query will be processed by the server instead of being dropped. This problem may be mitigated by loading the HA library last, i.e. placing the library at the end of the "hooks-libraries" list within a Kea configuration file.
If the received query is to be processed by this server instance, the CalloutHabndle::NEXT_STEP_SKIP
status is set to prevent the server from unpacking the query because the query is unpacked by the callout.
callout_handle | Callout handle provided to the callout. |
Definition at line 175 of file ha_impl.cc.
References isc::stats::StatsMgr::addValue(), isc::log::DBGLVL_TRACE_BASIC, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::ha::HA_BUFFER6_RECEIVE_NOT_FOR_US, isc::ha::HA_BUFFER6_RECEIVE_PACKET_OPTIONS_SKIPPED, isc::ha::HA_BUFFER6_RECEIVE_UNPACK_FAILED, isc::ha::ha_logger, isc::stats::StatsMgr::instance(), LOG_DEBUG, service_, isc::hooks::CalloutHandle::setStatus(), and isc::Exception::what().
void isc::ha::HAImpl::commandProcessed | ( | hooks::CalloutHandle & | callout_handle | ) |
Implementation of the "command_processed" callout.
It adds the HA servers information to "status-get" command responses by calling HAService::commandProcessed
.
callout_handle | Callout handle provided to the callout. |
Definition at line 289 of file ha_impl.cc.
References config_, isc::hooks::CalloutHandle::getArgument(), isc::ha::HAConfig::HAModeToString(), and service_.
void isc::ha::HAImpl::configure | ( | const data::ConstElementPtr & | input_config | ) |
Parses configuration.
input_config | Configuration specified for the hooks library. |
ConfigError | when configuration fails. |
Definition at line 35 of file ha_impl.cc.
References config_, and isc::ha::HAConfigParser::parse().
void isc::ha::HAImpl::continueHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handler for the ha-continue command.
callout_handle | Callout handle provided to the callout. |
Definition at line 447 of file ha_impl.cc.
References service_, and isc::hooks::CalloutHandle::setArgument().
|
inline |
void isc::ha::HAImpl::haResetHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handler for the ha-reset command.
callout_handle | Callout handle provided to the callout. |
Definition at line 488 of file ha_impl.cc.
References service_, and isc::hooks::CalloutHandle::setArgument().
void isc::ha::HAImpl::heartbeatHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handle for the heartbeat command.
callout_handle | Callout handle provided to the callout. |
Definition at line 322 of file ha_impl.cc.
References service_, and isc::hooks::CalloutHandle::setArgument().
void isc::ha::HAImpl::leases4Committed | ( | hooks::CalloutHandle & | callout_handle | ) |
Implementation of the "leases4_committed" callout.
callout_handle | Callout handle provided to the callout. |
Definition at line 114 of file ha_impl.cc.
References config_, isc::log::DBGLVL_TRACE_BASIC, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getParkingLotHandlePtr(), isc::ha::HA_LEASES4_COMMITTED_NOTHING_TO_UPDATE, isc::ha::ha_logger, LOG_DEBUG, service_, and isc::hooks::CalloutHandle::setStatus().
void isc::ha::HAImpl::leases6Committed | ( | hooks::CalloutHandle & | callout_handle | ) |
Implementation of the "leases6_committed" callout.
callout_handle | Callout handle provided to the callout. |
Definition at line 228 of file ha_impl.cc.
References config_, isc::log::DBGLVL_TRACE_BASIC, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getParkingLotHandlePtr(), isc::ha::HA_LEASES6_COMMITTED_NOTHING_TO_UPDATE, isc::ha::ha_logger, LOG_DEBUG, service_, and isc::hooks::CalloutHandle::setStatus().
void isc::ha::HAImpl::maintenanceCancelHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handler for the ha-maintenance-cancel command.
callout_handle | Callout handle provided to the callout. |
Definition at line 482 of file ha_impl.cc.
References service_, and isc::hooks::CalloutHandle::setArgument().
void isc::ha::HAImpl::maintenanceNotifyHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handler for the ha-maintenance-notify command.
callout_handle | Callout handle provided to the callout. |
Definition at line 453 of file ha_impl.cc.
References isc::hooks::CalloutHandle::getArgument(), isc_throw, isc::config::parseCommandWithArgs(), service_, and isc::hooks::CalloutHandle::setArgument().
void isc::ha::HAImpl::maintenanceStartHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handler for the ha-maintenance-start command.
callout_handle | Callout handle provided to the callout. |
Definition at line 476 of file ha_impl.cc.
References service_, and isc::hooks::CalloutHandle::setArgument().
void isc::ha::HAImpl::scopesHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handler for the ha-scopes command.
callout_handle | Callout handle provided to the callout. |
Definition at line 390 of file ha_impl.cc.
References isc::config::CONTROL_RESULT_ERROR, isc::config::createAnswer(), isc::hooks::CalloutHandle::getArgument(), isc_throw, isc::config::parseCommand(), service_, and isc::hooks::CalloutHandle::setArgument().
void isc::ha::HAImpl::startService | ( | const asiolink::IOServicePtr & | io_service, |
const dhcp::NetworkStatePtr & | network_state, | ||
const HAServerType & | server_type | ||
) |
Creates high availability service using current configuration.
The caller must ensure that the HA configuration is valid before calling this function.
io_service | IO service object provided by the DHCP server. |
network_state | pointer to the object holding a state of the DHCP service (enabled/disabled). |
server_type | DHCP server type for which the HA service should be created. |
Definition at line 41 of file ha_impl.cc.
void isc::ha::HAImpl::synchronizeHandler | ( | hooks::CalloutHandle & | callout_handle | ) |
Implements handler for the ha-sync command.
callout_handle | Callout handle provided to the callout. |
Definition at line 328 of file ha_impl.cc.
References isc::config::CONTROL_RESULT_ERROR, isc::config::createAnswer(), isc::hooks::CalloutHandle::getArgument(), isc_throw, isc::config::parseCommand(), service_, and isc::hooks::CalloutHandle::setArgument().
|
protected |
Holds parsed configuration.
Definition at line 170 of file ha_impl.h.
Referenced by commandProcessed(), configure(), getConfig(), leases4Committed(), leases6Committed(), and startService().
|
protected |
Pointer to the high availability service (state machine).
Definition at line 173 of file ha_impl.h.
Referenced by buffer4Receive(), buffer6Receive(), commandProcessed(), continueHandler(), haResetHandler(), heartbeatHandler(), leases4Committed(), leases6Committed(), maintenanceCancelHandler(), maintenanceNotifyHandler(), maintenanceStartHandler(), scopesHandler(), startService(), synchronizeHandler(), and ~HAImpl().