![]() |
Kea 2.2.0
|
Holds communication state between DHCPv6 servers. More...
#include <communication_state.h>
Classes | |
struct | ConnectingClient6 |
Structure holding information about a client which sent a packet being analyzed. More... | |
Public Member Functions | |
CommunicationState6 (const asiolink::IOServicePtr &io_service, const HAConfigPtr &config) | |
Constructor. More... | |
virtual void | analyzeMessage (const boost::shared_ptr< dhcp::Pkt > &message) |
Checks if the DHCPv6 message appears to be unanswered. More... | |
virtual bool | failureDetected () const |
Checks if the partner failure has been detected based on the DHCP traffic analysis. More... | |
virtual size_t | getConnectingClientsCount () const |
Returns the current number of clients which attempted to get a lease from the partner server. More... | |
virtual size_t | getUnackedClientsCount () const |
Returns the current number of clients which haven't gotten a lease from the partner server. More... | |
![]() | |
CommunicationState (const asiolink::IOServicePtr &io_service, const HAConfigPtr &config) | |
Constructor. More... | |
virtual | ~CommunicationState () |
Destructor. More... | |
virtual void | analyzeMessage (const boost::shared_ptr< dhcp::Pkt > &message)=0 |
Checks if the DHCP message appears to be unanswered. More... | |
bool | clockSkewShouldTerminate () const |
Indicates whether the HA service should enter "terminated" state as a result of the clock skew exceeding maximum value. More... | |
bool | clockSkewShouldWarn () |
Issues a warning about high clock skew between the active servers if one is warranted. More... | |
virtual bool | failureDetected () const =0 |
Checks if the partner failure has been detected based on the DHCP traffic analysis. More... | |
size_t | getAnalyzedMessagesCount () const |
Returns the number of analyzed messages while being in the communications interrupted state. More... | |
virtual size_t | getConnectingClientsCount () const =0 |
Returns the current number of clients which attempted to get a lease from the partner server. More... | |
int64_t | getDurationInMillisecs () const |
Returns duration between the poke time and current time. More... | |
std::set< std::string > | getPartnerScopes () const |
Returns scopes served by the partner server. More... | |
int | getPartnerState () const |
Returns last known state of the partner. More... | |
data::ElementPtr | getReport () const |
Returns the report about current communication state. More... | |
virtual size_t | getUnackedClientsCount () const =0 |
Returns the current number of clients which haven't got the lease from the partner server. More... | |
uint64_t | getUnsentUpdateCount () const |
Returns a total number of unsent lease updates. More... | |
bool | hasPartnerNewUnsentUpdates () const |
Checks if the partner allocated new leases for which it hasn't sent any lease updates. More... | |
void | increaseUnsentUpdateCount () |
Increases a total number of unsent lease updates by 1. More... | |
bool | isCommunicationInterrupted () const |
Checks if communication with the partner is interrupted. More... | |
bool | isHeartbeatRunning () const |
Checks if recurring heartbeat is running. More... | |
std::string | logFormatClockSkew () const |
Returns current clock skew value in the logger friendly format. More... | |
void | modifyPokeTime (const long secs) |
Modifies poke time by adding seconds to it. More... | |
void | poke () |
Pokes the communication state. More... | |
void | setPartnerScopes (data::ConstElementPtr new_scopes) |
Sets partner scopes. More... | |
void | setPartnerState (const std::string &state) |
Sets partner state. More... | |
void | setPartnerTime (const std::string &time_text) |
Provide partner's notion of time so the new clock skew can be calculated. More... | |
void | setPartnerUnsentUpdateCount (uint64_t unsent_update_count) |
Saves new total number of unsent lease updates from the partner. More... | |
void | startHeartbeat (const long interval, const std::function< void()> &heartbeat_impl) |
Starts recurring heartbeat (public interface). More... | |
void | stopHeartbeat () |
Stops recurring heartbeat. More... | |
Protected Types | |
typedef boost::multi_index_container< ConnectingClient6, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::member< ConnectingClient6, std::vector< uint8_t >, &ConnectingClient6::duid_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::member< ConnectingClient6, bool, &ConnectingClient6::unacked_ > > > > | ConnectingClients6 |
Multi index container holding information about the clients attempting to get leases from the partner server. More... | |
Protected Member Functions | |
virtual void | analyzeMessageInternal (const boost::shared_ptr< dhcp::Pkt > &message) |
Checks if the DHCPv6 message appears to be unanswered. More... | |
virtual void | clearConnectingClients () |
Removes information about the clients the partner server should respond to while communication with the partner was interrupted. More... | |
virtual bool | failureDetectedInternal () const |
Checks if the partner failure has been detected based on the DHCP traffic analysis. More... | |
![]() | |
virtual void | clearConnectingClients ()=0 |
Removes information about the clients the partner server should respond to while communication with the partner was interrupted. More... | |
boost::posix_time::time_duration | updatePokeTime () |
Update the poke time and compute the duration. More... | |
Protected Attributes | |
ConnectingClients6 | connecting_clients_ |
Holds information about the clients attempting to contact the partner server while the servers are in communications interrupted state. More... | |
![]() | |
size_t | analyzed_messages_count_ |
Total number of analyzed messages to be responded by partner. More... | |
boost::posix_time::time_duration | clock_skew_ |
Clock skew between the active servers. More... | |
HAConfigPtr | config_ |
High availability configuration. More... | |
std::function< void()> | heartbeat_impl_ |
Pointer to the function providing heartbeat implementation. More... | |
long | interval_ |
Interval specified for the heartbeat. More... | |
asiolink::IOServicePtr | io_service_ |
Pointer to the common IO service instance. More... | |
boost::posix_time::ptime | last_clock_skew_warn_ |
Holds a time when last warning about too high clock skew was issued. More... | |
const boost::scoped_ptr< std::mutex > | mutex_ |
The mutex used to protect internal state. More... | |
boost::posix_time::ptime | my_time_at_skew_ |
My time when skew was calculated. More... | |
std::set< std::string > | partner_scopes_ |
Last known set of scopes served by the partner server. More... | |
int | partner_state_ |
Last known state of the partner server. More... | |
boost::posix_time::ptime | partner_time_at_skew_ |
Partner reported time when skew was calculated. More... | |
std::pair< uint64_t, uint64_t > | partner_unsent_update_count_ |
Previous and current total number of unsent lease updates from the partner. More... | |
boost::posix_time::ptime | poke_time_ |
Last poke time. More... | |
asiolink::IntervalTimerPtr | timer_ |
Interval timer triggering heartbeat commands. More... | |
uint64_t | unsent_update_count_ |
Total number of unsent lease updates. More... | |
Holds communication state between DHCPv6 servers.
This class implements DHCPv6 failure detection by monitoring the value of the "Elapsed Time" option in received DHCPv6 messages as described in CommunicationState::analyzeMessage
.
Definition at line 732 of file communication_state.h.
|
protected |
Multi index container holding information about the clients attempting to get leases from the partner server.
Definition at line 832 of file communication_state.h.
isc::ha::CommunicationState6::CommunicationState6 | ( | 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 677 of file communication_state.cc.
|
virtual |
Checks if the DHCPv6 message appears to be unanswered.
See CommunicationState::analyzeMessage
for details.
message | DHCPv6 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. |
Implements isc::ha::CommunicationState.
Definition at line 683 of file communication_state.cc.
References analyzeMessageInternal(), and isc::ha::CommunicationState::mutex_.
|
protectedvirtual |
Checks if the DHCPv6 message appears to be unanswered.
Should be called in a thread safe context.
See CommunicationState::analyzeMessage
for details.
message | DHCPv6 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. |
Definition at line 693 of file communication_state.cc.
References isc::ha::CommunicationState::analyzed_messages_count_, isc::ha::CommunicationState::config_, connecting_clients_, D6O_CLIENTID, D6O_ELAPSED_TIME, isc::dhcp::Option::getOption(), isc::ha::HA_COMMUNICATION_INTERRUPTED_CLIENT6, isc::ha::HA_COMMUNICATION_INTERRUPTED_CLIENT6_UNACKED, isc::ha::ha_logger, isc_throw, and LOG_INFO.
Referenced by analyzeMessage().
|
protectedvirtual |
Removes information about the clients the partner server should respond to while communication with the partner was interrupted.
See CommunicationState::analyzeMessage
for details.
Implements isc::ha::CommunicationState.
Definition at line 799 of file communication_state.cc.
References connecting_clients_.
|
virtual |
Checks if the partner failure has been detected based on the DHCP traffic analysis.
Implements isc::ha::CommunicationState.
Definition at line 762 of file communication_state.cc.
References failureDetectedInternal(), and isc::ha::CommunicationState::mutex_.
|
protectedvirtual |
Checks if the partner failure has been detected based on the DHCP traffic analysis.
Should be called in a thread safe context.
Definition at line 772 of file communication_state.cc.
References isc::ha::CommunicationState::config_, and connecting_clients_.
Referenced by failureDetected().
|
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.
Implements isc::ha::CommunicationState.
Definition at line 779 of file communication_state.cc.
References connecting_clients_, and isc::ha::CommunicationState::mutex_.
|
virtual |
Returns the current number of clients which haven't gotten 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.
Implements isc::ha::CommunicationState.
Definition at line 789 of file communication_state.cc.
References connecting_clients_, and isc::ha::CommunicationState::mutex_.
|
protected |
Holds information about the clients attempting to contact the partner server while the servers are in communications interrupted state.
Definition at line 837 of file communication_state.h.
Referenced by analyzeMessageInternal(), clearConnectingClients(), failureDetectedInternal(), getConnectingClientsCount(), and getUnackedClientsCount().