Kea 2.7.5
|
Holds communication state between the two HA peers. More...
#include <communication_state.h>
Public Member Functions | |
CommunicationState (const asiolink::IOServicePtr &io_service, const HAConfigPtr &config) | |
Constructor. | |
virtual | ~CommunicationState () |
Destructor. | |
virtual void | analyzeMessage (const boost::shared_ptr< dhcp::Pkt > &message)=0 |
Checks if the DHCP message appears to be unanswered. | |
void | clearRejectedLeaseUpdates () |
Clears rejected client leases (MT safe). | |
bool | clockSkewShouldTerminate () |
Indicates whether the HA service should enter "terminated" state as a result of the clock skew exceeding maximum value. | |
bool | clockSkewShouldWarn () |
Issues a warning about high clock skew between the active servers if one is warranted. | |
virtual bool | failureDetected () const =0 |
Checks if the partner failure has been detected based on the DHCP traffic analysis. | |
size_t | getAnalyzedMessagesCount () const |
Returns the number of analyzed messages while being in the communications interrupted state. | |
virtual size_t | getConnectingClientsCount () const =0 |
Returns the current number of clients which attempted to get a lease from the partner server. | |
int64_t | getDurationInMillisecs () const |
Returns duration between the poke time and current time. | |
boost::posix_time::time_duration | getDurationSincePartnerStateTime () const |
Returns the duration since the partner was first seen in the current state. | |
boost::posix_time::ptime | getMyTimeAtSkew () const |
Retrieves the time of the local node when skew was last calculated. | |
std::set< std::string > | getPartnerScopes () const |
Returns scopes served by the partner server. | |
int | getPartnerState () const |
Returns last known state of the partner. | |
boost::posix_time::ptime | getPartnerTimeAtSkew () const |
Retrieves the time of the partner node when skew was last calculated. | |
size_t | getRejectedLeaseUpdatesCount () |
Returns the number of lease updates rejected by the partner (MT safe). | |
data::ElementPtr | getReport () const |
Returns the report about current communication state. | |
virtual size_t | getUnackedClientsCount () const =0 |
Returns the current number of clients which haven't got the lease from the partner server. | |
uint64_t | getUnsentUpdateCount () const |
Returns a total number of unsent lease updates. | |
bool | hasPartnerNewUnsentUpdates () const |
Checks if the partner allocated new leases for which it hasn't sent any lease updates. | |
void | increaseUnsentUpdateCount () |
Increases a total number of unsent lease updates by 1. | |
bool | isCommunicationInterrupted () const |
Checks if communication with the partner is interrupted. | |
bool | isHeartbeatRunning () const |
Checks if recurring heartbeat is running. | |
std::string | logFormatClockSkew () const |
Returns current clock skew value in the logger friendly format. | |
void | modifyPokeTime (const long secs) |
Modifies poke time by adding seconds to it. | |
void | poke () |
Pokes the communication state. | |
bool | rejectedLeaseUpdatesShouldTerminate () |
Indicates whether the HA service should enter "terminated" state due to excessive number of rejected lease updates. | |
bool | reportRejectedLeaseUpdate (const dhcp::PktPtr &message, const uint32_t lifetime=86400) |
Marks that the lease update failed due to a conflict for the specified DHCP message (MT safe). | |
bool | reportSuccessfulLeaseUpdate (const dhcp::PktPtr &message) |
Marks the lease update successful (MT safe). | |
void | setPartnerScopes (data::ConstElementPtr new_scopes) |
Sets partner scopes. | |
void | setPartnerState (const std::string &state) |
Sets partner state. | |
void | setPartnerTime (const std::string &time_text) |
Provide partner's notion of time so the new clock skew can be calculated. | |
void | setPartnerUnavailable () |
Sets partner state unavailable. | |
void | setPartnerUnsentUpdateCount (uint64_t unsent_update_count) |
Saves new total number of unsent lease updates from the partner. | |
void | startHeartbeat (const long interval, const std::function< void()> &heartbeat_impl) |
Starts recurring heartbeat (public interface). | |
void | stopHeartbeat () |
Stops recurring heartbeat. | |
Protected Member Functions | |
virtual void | clearConnectingClients ()=0 |
Removes information about the clients the partner server should respond to while communication with the partner was interrupted. | |
virtual void | clearRejectedLeaseUpdatesInternal ()=0 |
Clears rejected client leases. | |
virtual size_t | getRejectedLeaseUpdatesCountInternal ()=0 |
Returns the number of lease updates rejected by the partner. | |
virtual bool | reportRejectedLeaseUpdateInternal (const dhcp::PktPtr &message, const uint32_t lifetime)=0 |
Marks that the lease update failed due to a conflict for the specified DHCP message. | |
virtual bool | reportSuccessfulLeaseUpdateInternal (const dhcp::PktPtr &message)=0 |
Marks the lease update successful. | |
boost::posix_time::time_duration | updatePokeTime () |
Update the poke time and compute the duration. | |
Static Protected Member Functions | |
static std::vector< uint8_t > | getClientId (const dhcp::PktPtr &message, const uint16_t option_type) |
Convenience function attempting to retrieve client identifier from the DHCP message. | |
template<typename RejectedClientsType > | |
static size_t | getRejectedLeaseUpdatesCountFromContainer (RejectedClientsType &rejected_clients) |
Extracts the number of lease updates rejected by the partner from the specified container. | |
Protected Attributes | |
size_t | analyzed_messages_count_ |
Total number of analyzed messages to be responded by partner. | |
boost::posix_time::time_duration | clock_skew_ |
Clock skew between the active servers. | |
HAConfigPtr | config_ |
High availability configuration. | |
std::function< void()> | heartbeat_impl_ |
Pointer to the function providing heartbeat implementation. | |
long | interval_ |
Interval specified for the heartbeat. | |
asiolink::IOServicePtr | io_service_ |
Pointer to the common IO service instance. | |
boost::posix_time::ptime | last_clock_skew_warn_ |
Holds a time when last warning about too high clock skew was issued. | |
const boost::scoped_ptr< std::mutex > | mutex_ |
The mutex used to protect internal state. | |
boost::posix_time::ptime | my_time_at_skew_ |
My time when skew was calculated. | |
std::set< std::string > | partner_scopes_ |
Last known set of scopes served by the partner server. | |
int | partner_state_ |
Last known state of the partner server. | |
boost::posix_time::ptime | partner_state_time_ |
Holds a time when partner was first seen in the current state. | |
boost::posix_time::ptime | partner_time_at_skew_ |
Partner reported time when skew was calculated. | |
std::pair< uint64_t, uint64_t > | partner_unsent_update_count_ |
Previous and current total number of unsent lease updates from the partner. | |
boost::posix_time::ptime | poke_time_ |
Last poke time. | |
asiolink::IntervalTimerPtr | timer_ |
Interval timer triggering heartbeat commands. | |
uint64_t | unsent_update_count_ |
Total number of unsent lease updates. | |
Holds communication state between the two HA peers.
The HA service constantly monitors the state of the connection between the two peers. If the connection is lost it is an indicator that the partner server may be down and failover actions should be triggered.
A heartbeat command successfully sent over the control channel is an indicator that the connection is healthy. A reply to the heartbeat command includes information about the recipient state, its notion of time, and other information useful for determining its health and current activity.
This class uses an interval timer to run heartbeat commands over the control channel. The implementation of the heartbeat is external to this class and is provided via CommunicationState::startHeartbeat
method. This implementation is required to run the poke
method in case of receiving a successful response to the heartbeat command.
The poke
method sets the "last poke time" to current time, thus indicating that the connection is healthy. The getDurationInMillisecs
method is used to check for how long the server hasn't been able to communicate with the partner. This duration is simply a time elapsed since last successful poke time. If this duration becomes greater than the configured threshold, the server assumes that the communication with the partner is interrupted.
The derivations of this class provide DHCPv4 and DHCPv6 specific mechanisms for detecting server failures based on the analysis of the received DHCP messages, i.e. how long the clients have been trying to communicate with the partner and message types they sent. In particular, the increased number of Rebind messages may indicate issues with the DHCP server.
This class is also used to monitor the clock skew between the active servers. Maintaining a reasonably low clock skew is essential for the HA service to function properly. This class calculates the clock skew by comparing local time of the server with the time returned by the partner in response to a heartbeat command. If this value exceeds the certain thresholds, the CommunicationState::clockSkewShouldWarn and the CommuicationState::clockSkewShouldTerminate
indicate whether the HA service should continue to operate normally, should start issuing a warning about high clock skew or simply enter the "terminated" state refusing to further operate until the clocks are synchronized. This requires administrative intervention and the restart of the HA service.
Definition at line 81 of file communication_state.h.
isc::ha::CommunicationState::CommunicationState | ( | const asiolink::IOServicePtr & | io_service, |
const HAConfigPtr & | config ) |
Constructor.
io_service | pointer to the common IO service instance. |
config | pointer to the HA configuration. |
Definition at line 57 of file communication_state.cc.
|
virtual |
Destructor.
Stops scheduled heartbeat.
Definition at line 68 of file communication_state.cc.
References stopHeartbeat().
|
pure virtual |
Checks if the DHCP message appears to be unanswered.
This method is used to provide the communication state with a received DHCP message directed to the HA partner, to detect if the partner fails to answer DHCP messages directed to it. The DHCPv4 and DHCPv6 specific derivations implement this functionality.
This check is orthogonal to the heartbeat mechanism and is usually triggered after several consecutive heartbeats fail to be responded.
The general approach to server failure detection is based on the analysis of the "secs" field value (DHCPv4) and "elapsed time" option value (DHCPv6). They indicate for how long the client has been trying to complete the DHCP transaction. If these values exceed a configured threshold, the client is considered to fail to communicate with the server. This fact is recorded by this object. If the number of distinct clients failing to communicate with the partner exceeds a configured maximum value, this server considers the partner to be offline. In this case, this server will most likely start serving clients which would normally be served by the partner.
All information gathered by this method is cleared when the poke
method is invoked.
message | DHCP message to be analyzed. This must be the message which belongs to the partner, i.e. the caller must filter out messages belonging to the partner prior to calling this method. |
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
|
protectedpure virtual |
Removes information about the clients the partner server should respond to while communication with the partner was interrupted.
This information is cleared by the CommunicationState::poke
. The derivations of this class must provide DHCPv4 and DHCPv6 specific implementations of this method. The poke
method is called to indicate that the connection has been successfully (re)established. Therefore the clients counters are reset and the failure detection procedure starts over.
See CommunicationState::analyzeMessage
for details.
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
void isc::ha::CommunicationState::clearRejectedLeaseUpdates | ( | ) |
Clears rejected client leases (MT safe).
Definition at line 392 of file communication_state.cc.
References clearRejectedLeaseUpdatesInternal(), isc::util::MultiThreadingMgr::instance(), and mutex_.
|
protectedpure virtual |
Clears rejected client leases.
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
Referenced by clearRejectedLeaseUpdates().
bool isc::ha::CommunicationState::clockSkewShouldTerminate | ( | ) |
Indicates whether the HA service should enter "terminated" state as a result of the clock skew exceeding maximum value.
If the clocks on the active servers are not synchronized (perhaps as a result of a warning message caused by clockSkewShouldWarn
) and the clocks further drift, the clock skew may exceed another threshold which should cause the HA service to enter "terminated" state. In this state the servers still respond to DHCP clients normally, but they will neither send lease updates nor heartbeats. In this case, the administrator must correct the problem (synchronize the clocks) and restart the service. This method indicates whether the service should terminate or not.
Currently, the terminal threshold for the clock skew is hardcoded to 60 seconds. In the future it may become configurable.
Definition at line 442 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
bool isc::ha::CommunicationState::clockSkewShouldWarn | ( | ) |
Issues a warning about high clock skew between the active servers if one is warranted.
The HA service monitors the clock skew between the active servers. The clock skew is calculated from the local time and the time returned by the partner in response to a heartbeat. When clock skew exceeds a certain threshold the HA service starts issuing a warning message. This method returns true if the HA service should issue this message.
Currently, the warning threshold for the clock skew is hardcoded to 30 seconds. In the future it may become configurable.
This method is called for each heartbeat. If we issue a warning for each heartbeat it may flood logs with those messages. This method provides a gating mechanism which prevents the HA service from logging the warning more often than every 60 seconds. If the last warning was issued less than 60 seconds ago this method will return false even if the clock skew exceeds the 30 seconds threshold. The correction of the clock skew will reset the gating counter.
Definition at line 402 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
|
pure virtual |
Checks if the partner failure has been detected based on the DHCP traffic analysis.
In the special case when max-unacked-clients is set to 0 this method always returns true. Note that max-unacked-clients set to 0 means that failure detection is not really performed. Returning true in that case simplifies the code of the HAService
which doesn't need to check if the failure detection is enabled or not. It simply calls this method in the 'communications interrupted' situation to check if the server should be transitioned to the 'partner-down' state.
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
size_t isc::ha::CommunicationState::getAnalyzedMessagesCount | ( | ) | const |
Returns the number of analyzed messages while being in the communications interrupted state.
Definition at line 356 of file communication_state.cc.
References analyzed_messages_count_.
Referenced by getReport().
|
staticprotected |
Convenience function attempting to retrieve client identifier from the DHCP message.
message | DHCPv4 or DHCPv6 message. |
option_type | code of the option holding the client id. |
Definition at line 345 of file communication_state.cc.
Referenced by isc::ha::CommunicationState4::analyzeMessageInternal(), isc::ha::CommunicationState6::analyzeMessageInternal(), isc::ha::CommunicationState4::reportRejectedLeaseUpdateInternal(), isc::ha::CommunicationState6::reportRejectedLeaseUpdateInternal(), isc::ha::CommunicationState4::reportSuccessfulLeaseUpdateInternal(), and isc::ha::CommunicationState6::reportSuccessfulLeaseUpdateInternal().
|
pure virtual |
Returns the current number of clients which attempted to get a lease from the partner server.
The returned number is reset to 0 when the server successfully establishes communication with the partner. The number is incremented only in the communications interrupted case.
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
Referenced by getReport().
int64_t isc::ha::CommunicationState::getDurationInMillisecs | ( | ) | const |
Returns duration between the poke time and current time.
Definition at line 323 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
Referenced by getReport(), and isCommunicationInterrupted().
time_duration isc::ha::CommunicationState::getDurationSincePartnerStateTime | ( | ) | const |
Returns the duration since the partner was first seen in the current state.
Definition at line 129 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and partner_state_time_.
boost::posix_time::ptime isc::ha::CommunicationState::getMyTimeAtSkew | ( | ) | const |
Retrieves the time of the local node when skew was last calculated.
Definition at line 665 of file communication_state.cc.
References my_time_at_skew_.
std::set< std::string > isc::ha::CommunicationState::getPartnerScopes | ( | ) | const |
Returns scopes served by the partner server.
Definition at line 145 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and partner_scopes_.
Referenced by getReport().
int isc::ha::CommunicationState::getPartnerState | ( | ) | const |
Returns last known state of the partner.
Definition at line 83 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and partner_state_.
Referenced by getReport().
boost::posix_time::ptime isc::ha::CommunicationState::getPartnerTimeAtSkew | ( | ) | const |
Retrieves the time of the partner node when skew was last calculated.
Definition at line 670 of file communication_state.cc.
References partner_time_at_skew_.
size_t isc::ha::CommunicationState::getRejectedLeaseUpdatesCount | ( | ) |
Returns the number of lease updates rejected by the partner (MT safe).
Each rejected lease update is counted only once if it failed multiple times. Before returning the counter, it discards expired rejected lease updates.
Definition at line 361 of file communication_state.cc.
References getRejectedLeaseUpdatesCountInternal(), isc::util::MultiThreadingMgr::instance(), and mutex_.
|
inlinestaticprotected |
Extracts the number of lease updates rejected by the partner from the specified container.
rejected_clients | container holding rejected clients (v4 or v6). |
RejectedClientsType | type of the container holding rejected clients. |
Definition at line 353 of file communication_state.h.
Referenced by isc::ha::CommunicationState4::getRejectedLeaseUpdatesCountInternal(), and isc::ha::CommunicationState6::getRejectedLeaseUpdatesCountInternal().
|
protectedpure virtual |
Returns the number of lease updates rejected by the partner.
Each rejected lease update is counted only once if it failed multiple times. Before returning the counter, it discards expired rejected lease updates.
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
Referenced by getRejectedLeaseUpdatesCount().
ElementPtr isc::ha::CommunicationState::getReport | ( | ) | const |
Returns the report about current communication state.
This function returns a JSON map describing the state of communication with a partner. This report is included in the response to the status-get command.
Definition at line 557 of file communication_state.cc.
References clock_skew_, config_, isc::data::Element::create(), isc::data::Element::createList(), isc::data::Element::createMap(), getAnalyzedMessagesCount(), getConnectingClientsCount(), getDurationInMillisecs(), getPartnerScopes(), getPartnerState(), getUnackedClientsCount(), isCommunicationInterrupted(), partner_time_at_skew_, isc::util::ptimeToText(), and isc::ha::stateToString().
|
pure virtual |
Returns the current number of clients which haven't got the lease from the partner server.
The returned number is reset to 0 when the server successfully establishes communication with the partner. The number is incremented only in the communications interrupted case.
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
Referenced by getReport().
uint64_t isc::ha::CommunicationState::getUnsentUpdateCount | ( | ) | const |
Returns a total number of unsent lease updates.
Definition at line 602 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and unsent_update_count_.
bool isc::ha::CommunicationState::hasPartnerNewUnsentUpdates | ( | ) | const |
Checks if the partner allocated new leases for which it hasn't sent any lease updates.
It compares a previous and current value of the partner_unsent_update_count_
. If the current value is 0 and the previous value is non-zero it indicates that the partner was restarted.
Definition at line 633 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::increaseUnsentUpdateCount | ( | ) |
Increases a total number of unsent lease updates by 1.
This method should be called when the server has allocated a lease but decided to not send the lease update to its partner. If the server is in the partner-down state it allocates new leases but doesn't send lease updates because the partner is unavailable.
This method protects against setting the value to 0 in an unlikely event of the overflow. The zero is reserved for the server startup case.
Definition at line 612 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
bool isc::ha::CommunicationState::isCommunicationInterrupted | ( | ) | const |
Checks if communication with the partner is interrupted.
This method checks if the communication with the partner appears to be interrupted. This is the case when the time since last successful communication is longer than the configured max-response-delay value.
Definition at line 340 of file communication_state.cc.
References config_, and getDurationInMillisecs().
Referenced by getReport().
bool isc::ha::CommunicationState::isHeartbeatRunning | ( | ) | const |
Checks if recurring heartbeat is running.
Definition at line 259 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and timer_.
std::string isc::ha::CommunicationState::logFormatClockSkew | ( | ) | const |
Returns current clock skew value in the logger friendly format.
Definition at line 516 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::modifyPokeTime | ( | const long | secs | ) |
Modifies poke time by adding seconds to it.
Used in unittests only.
secs | number of seconds to be added to the poke time. If the value is negative it will set the poke time in the past comparing to current value. |
Definition at line 73 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and poke_time_.
void isc::ha::CommunicationState::poke | ( | ) |
Pokes the communication state.
Sets the last poke time to current time. If the heartbeat timer has been scheduled, it is reset (starts over measuring the time to the next heartbeat).
Definition at line 288 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
bool isc::ha::CommunicationState::rejectedLeaseUpdatesShouldTerminate | ( | ) |
Indicates whether the HA service should enter "terminated" state due to excessive number of rejected lease updates.
Definition at line 464 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
bool isc::ha::CommunicationState::reportRejectedLeaseUpdate | ( | const dhcp::PktPtr & | message, |
const uint32_t | lifetime = 86400 ) |
Marks that the lease update failed due to a conflict for the specified DHCP message (MT safe).
If the conflict has been already reported for the given client, the rejected lease count remains unchanged.
message | DHCP message for which a lease update failed due to a conflict. |
lifetime | a time in seconds after which the rejected lease update entry should be discarded. |
Definition at line 371 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and reportRejectedLeaseUpdateInternal().
|
protectedpure virtual |
Marks that the lease update failed due to a conflict for the specified DHCP message.
If the conflict has been already reported for the given client, the rejected lease count remains unchanged.
message | DHCP message for which a lease update failed due to a conflict. |
lifetime | a time in seconds after which the rejected lease update entry should be discarded. |
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
Referenced by reportRejectedLeaseUpdate().
bool isc::ha::CommunicationState::reportSuccessfulLeaseUpdate | ( | const dhcp::PktPtr & | message | ) |
Marks the lease update successful (MT safe).
If the lease update was previously marked "in conflict", it is now cleared, effectively lowering the number of conflicted leases.
message | DHCP message for which the lease update was successful. |
Definition at line 382 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), mutex_, and reportSuccessfulLeaseUpdateInternal().
|
protectedpure virtual |
Marks the lease update successful.
If the lease update was previously marked "in conflict", it is now cleared, effectively lowering the number of conflicted leases.
message | DHCP message for which the lease update was successful. |
Implemented in isc::ha::CommunicationState4, and isc::ha::CommunicationState6.
Referenced by reportSuccessfulLeaseUpdate().
void isc::ha::CommunicationState::setPartnerScopes | ( | data::ConstElementPtr | new_scopes | ) |
Sets partner scopes.
new_scopes | Partner scopes enclosed in a JSON list. |
Definition at line 155 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::setPartnerState | ( | const std::string & | state | ) |
Sets partner state.
state | new partner's state in a textual form. Supported values are those returned in response to a ha-heartbeat command. |
BadValue | if unsupported state value was provided. |
Definition at line 93 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::setPartnerTime | ( | const std::string & | time_text | ) |
Provide partner's notion of time so the new clock skew can be calculated.
time_text | Partner's time received in response to a heartbeat. The time must be provided in the RFC 1123 format. It stores the current time, partner's time, and the difference (skew) between them. |
isc::http::HttpTimeConversionError | if the time format is invalid. |
Definition at line 491 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::setPartnerUnavailable | ( | ) |
Sets partner state unavailable.
This function should be called whenever there is a problem to communicate with the partner. Besides setting the state, it also resets some other communication states. In particular, it resets the clock skew.
Definition at line 103 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::setPartnerUnsentUpdateCount | ( | uint64_t | unsent_update_count | ) |
Saves new total number of unsent lease updates from the partner.
unsent_update_count | new total number of unsent lease updates from the partner. |
Definition at line 649 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::startHeartbeat | ( | const long | interval, |
const std::function< void()> & | heartbeat_impl ) |
Starts recurring heartbeat (public interface).
interval | heartbeat interval in milliseconds. |
heartbeat_impl | pointer to the heartbeat implementation function. |
Definition at line 187 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
void isc::ha::CommunicationState::stopHeartbeat | ( | ) |
Stops recurring heartbeat.
Definition at line 239 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
Referenced by ~CommunicationState().
|
protected |
Update the poke time and compute the duration.
Definition at line 269 of file communication_state.cc.
References isc::util::MultiThreadingMgr::instance(), and mutex_.
|
protected |
Total number of analyzed messages to be responded by partner.
Definition at line 755 of file communication_state.h.
Referenced by isc::ha::CommunicationState4::analyzeMessageInternal(), isc::ha::CommunicationState6::analyzeMessageInternal(), and getAnalyzedMessagesCount().
|
protected |
Clock skew between the active servers.
Definition at line 742 of file communication_state.h.
Referenced by getReport().
|
protected |
High availability configuration.
Definition at line 716 of file communication_state.h.
Referenced by isc::ha::CommunicationState4::analyzeMessageInternal(), isc::ha::CommunicationState6::analyzeMessageInternal(), isc::ha::CommunicationState4::failureDetectedInternal(), isc::ha::CommunicationState6::failureDetectedInternal(), getReport(), and isCommunicationInterrupted().
|
protected |
Pointer to the function providing heartbeat implementation.
Definition at line 728 of file communication_state.h.
|
protected |
Interval specified for the heartbeat.
Definition at line 722 of file communication_state.h.
|
protected |
Pointer to the common IO service instance.
Definition at line 713 of file communication_state.h.
|
protected |
Holds a time when last warning about too high clock skew was issued.
Definition at line 746 of file communication_state.h.
|
protected |
The mutex used to protect internal state.
Definition at line 776 of file communication_state.h.
Referenced by isc::ha::CommunicationState4::analyzeMessage(), isc::ha::CommunicationState6::analyzeMessage(), clearRejectedLeaseUpdates(), clockSkewShouldTerminate(), clockSkewShouldWarn(), isc::ha::CommunicationState4::failureDetected(), isc::ha::CommunicationState6::failureDetected(), isc::ha::CommunicationState4::getConnectingClientsCount(), isc::ha::CommunicationState6::getConnectingClientsCount(), getDurationInMillisecs(), getDurationSincePartnerStateTime(), getPartnerScopes(), getPartnerState(), getRejectedLeaseUpdatesCount(), isc::ha::CommunicationState4::getUnackedClientsCount(), isc::ha::CommunicationState6::getUnackedClientsCount(), getUnsentUpdateCount(), hasPartnerNewUnsentUpdates(), increaseUnsentUpdateCount(), isHeartbeatRunning(), logFormatClockSkew(), modifyPokeTime(), poke(), rejectedLeaseUpdatesShouldTerminate(), reportRejectedLeaseUpdate(), reportSuccessfulLeaseUpdate(), setPartnerScopes(), setPartnerState(), setPartnerTime(), setPartnerUnavailable(), setPartnerUnsentUpdateCount(), startHeartbeat(), stopHeartbeat(), and updatePokeTime().
|
protected |
My time when skew was calculated.
Definition at line 749 of file communication_state.h.
Referenced by getMyTimeAtSkew().
|
protected |
Last known set of scopes served by the partner server.
Definition at line 739 of file communication_state.h.
Referenced by getPartnerScopes().
|
protected |
Last known state of the partner server.
Negative value means that the partner's state is unknown.
Definition at line 733 of file communication_state.h.
Referenced by getPartnerState().
|
protected |
Holds a time when partner was first seen in the current state.
Definition at line 736 of file communication_state.h.
Referenced by getDurationSincePartnerStateTime().
|
protected |
Partner reported time when skew was calculated.
Definition at line 752 of file communication_state.h.
Referenced by getPartnerTimeAtSkew(), and getReport().
|
protected |
Previous and current total number of unsent lease updates from the partner.
This value is returned in response to a heartbeat command and saved using the setPartnerUnsentUpdateCount
. The previous value is preserved so the values can be compared in the state handlers.
Definition at line 773 of file communication_state.h.
|
protected |
Last poke time.
Definition at line 725 of file communication_state.h.
Referenced by modifyPokeTime().
|
protected |
Interval timer triggering heartbeat commands.
Definition at line 719 of file communication_state.h.
Referenced by isHeartbeatRunning().
|
protected |
Total number of unsent lease updates.
The lease updates are not sent when the server is in the partner down state. The server counts the number of lease updates which haven't been sent to the partner because the partner was unavailable. The partner receives this value in a response to a heartbeat message and can use it to determine if it should synchronize its lease database.
Definition at line 765 of file communication_state.h.
Referenced by getUnsentUpdateCount().