45 service_ = boost::make_shared<HAService>(io_service, network_state,
49 io_service->post([&]() {
service_->startClientAndListener(); } );
70 if (callout_handle.
getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
81 }
catch (
const std::exception& ex) {
84 .arg(query4->getRemoteAddr().toText())
85 .arg(query4->getLocalAddr().toText())
86 .arg(query4->getIface())
91 static_cast<int64_t
>(1));
93 static_cast<int64_t
>(1));
96 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
103 .arg(query4->getLabel());
104 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
109 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
118 if (!
config_->amSendingLeaseUpdates()) {
135 callout_handle.
getArgument(
"deleted_leases4", deleted_leases4);
138 if (leases4->empty() && deleted_leases4->empty()) {
140 .arg(query4->getLabel());
150 parking_lot->reference(query4);
157 if (
service_->asyncSendLeaseUpdates(query4, leases4, deleted_leases4, parking_lot) == 0) {
159 parking_lot->dereference(query4);
164 parking_lot->dereference(query4);
171 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_PARK);
184 if (callout_handle.
getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
195 }
catch (
const std::exception& ex) {
198 .arg(query6->getRemoteAddr().toText())
199 .arg(query6->getLocalAddr().toText())
200 .arg(query6->getIface())
205 static_cast<int64_t
>(1));
207 static_cast<int64_t
>(1));
210 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
217 .arg(query6->getLabel());
218 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
223 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
232 if (!
config_->amSendingLeaseUpdates()) {
249 callout_handle.
getArgument(
"deleted_leases6", deleted_leases6);
252 if (leases6->empty() && deleted_leases6->empty()) {
254 .arg(query6->getLabel());
264 parking_lot->reference(query6);
271 if (
service_->asyncSendLeaseUpdates(query6, leases6, deleted_leases6, parking_lot) == 0) {
273 parking_lot->dereference(query6);
278 parking_lot->dereference(query6);
285 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_PARK);
290 std::string command_name;
292 if (command_name ==
"status-get") {
296 if (!response || (response->getType() != Element::map)) {
301 if (!resp_args || (resp_args->getType() != Element::map)) {
306 boost::const_pointer_cast<Element>(resp_args);
311 auto ha_relationships = Element::createList();
312 auto ha_relationship = Element::createMap();
314 ha_relationship->set(
"ha-servers", ha_servers);
316 ha_relationships->add(ha_relationship);
317 mutable_resp_args->set(
"high-availability", ha_relationships);
338 unsigned int max_period_value = 0;
347 if (args->getType() != Element::map) {
353 server_name = args->get(
"server-name");
359 if (server_name->getType() != Element::string) {
367 if ((max_period->getType() != Element::integer) ||
368 (max_period->intValue() <= 0)) {
369 isc_throw(
BadValue,
"'max-period' must be a positive integer in the 'ha-sync' command");
372 max_period_value =
static_cast<unsigned int>(max_period->intValue());
375 }
catch (
const std::exception& ex) {
399 std::vector<std::string> scopes_vector;
408 if (args->getType() != Element::map) {
419 if (scopes->getType() != Element::list) {
425 for (
size_t i = 0; i < scopes->size(); ++i) {
427 if (!scope || scope->getType() != Element::string) {
430 scopes_vector.push_back(scope->stringValue());
433 }
catch (
const std::exception& ex) {
464 isc_throw(
BadValue,
"'cancel' is mandatory for the 'ha-maintenance-notify' command");
467 if (cancel_op->getType() != Element::boolean) {
468 isc_throw(
BadValue,
"'cancel' must be a boolean in the 'ha-maintenance-notify' command");
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception thrown during option unpacking This exception is thrown when an error has occurred,...
Configuration parser for High Availability.
void parse(const HAConfigPtr &config_storage, const data::ConstElementPtr &config)
Parses HA configuration.
Storage for High Availability configuration.
static std::string HAModeToString(const HAMode &ha_mode)
Returns HA mode name.
void scopesHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-scopes command.
void continueHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-continue command.
void syncCompleteNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync-complete-notify command.
HAServicePtr service_
Pointer to the high availability service (state machine).
void configure(const data::ConstElementPtr &input_config)
Parses configuration.
void maintenanceCancelHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-cancel command.
void haResetHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-reset command.
void maintenanceNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-notify command.
void synchronizeHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync command.
void startService(const asiolink::IOServicePtr &io_service, const dhcp::NetworkStatePtr &network_state, const HAServerType &server_type)
Creates high availability service using current configuration.
void maintenanceStartHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-start command.
void leases4Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases4_committed" callout.
void buffer4Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer4_receive" callout.
HAConfigPtr config_
Holds parsed configuration.
void buffer6Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer6_receive" callout.
void commandProcessed(hooks::CalloutHandle &callout_handle)
Implementation of the "command_processed" callout.
void leases6Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases6_committed" callout.
void heartbeatHandler(hooks::CalloutHandle &callout_handle)
Implements handle for the heartbeat command.
Per-packet callout handle.
ParkingLotHandlePtr getParkingLotHandlePtr() const
Returns pointer to the parking lot handle for this hook point.
CalloutNextStep getStatus() const
Returns the next processing step.
void setStatus(const CalloutNextStep next)
Sets the next processing step.
void getArgument(const std::string &name, T &value) const
Get argument.
void setArgument(const std::string &name, T value)
Set argument.
static StatsMgr & instance()
Statistics Manager accessor method.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
std::string parseCommandWithArgs(ConstElementPtr &arg, ConstElementPtr command)
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
std::string parseCommand(ConstElementPtr &arg, ConstElementPtr command)
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
const isc::log::MessageID HA_BUFFER4_RECEIVE_UNPACK_FAILED
const isc::log::MessageID HA_LEASES6_COMMITTED_NOTHING_TO_UPDATE
const isc::log::MessageID HA_BUFFER4_RECEIVE_PACKET_OPTIONS_SKIPPED
const isc::log::MessageID HA_BUFFER6_RECEIVE_UNPACK_FAILED
isc::log::Logger ha_logger("ha-hooks")
const isc::log::MessageID HA_BUFFER6_RECEIVE_PACKET_OPTIONS_SKIPPED
HAServerType
Lists possible server types for which HA service is created.
const isc::log::MessageID HA_LEASES4_COMMITTED_NOTHING_TO_UPDATE
const isc::log::MessageID HA_BUFFER4_RECEIVE_NOT_FOR_US
const isc::log::MessageID HA_BUFFER6_RECEIVE_NOT_FOR_US
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
Defines the logger used by the top-level component of kea-lfc.