18 HAConfig::PeerConfig::PeerConfig()
19 :
name_(), url_(
""), role_(STANDBY), auto_failover_(false) {
35 role_ = stringToRole(role);
40 std::ostringstream label;
41 label << getName() <<
" (" << getUrl().toText() <<
")";
47 if (role ==
"primary") {
50 }
else if (role ==
"secondary") {
53 }
else if (role ==
"standby") {
56 }
else if (role ==
"backup") {
88 pausing_ = stringToPausing(pausing);
93 if (pausing ==
"always") {
96 }
else if (pausing ==
"never") {
99 }
else if (pausing ==
"once") {
122 isc_throw(
BadValue,
"unsupported pause enumeration " << static_cast<int>(pausing));
128 auto state_config = states_.find(state);
129 if (state_config != states_.end()) {
130 return (state_config->second);
135 states_[state] = new_state_config;
137 return (new_state_config);
151 if (
peers_.count(name) > 0) {
184 if (ha_mode ==
"load-balancing") {
187 }
else if (ha_mode ==
"hot-standby") {
198 return (
"load-balancing");
200 return (
"hot-standby");
209 auto peer =
peers_.find(name);
210 if (peer ==
peers_.end()) {
214 return (peer->second);
220 for (
auto peer = servers.begin(); peer != servers.end(); ++peer) {
222 return (peer->second);
251 std::map<PeerConfig::Role, unsigned> peers_cnt;
253 if (!p->second->getUrl().isValid()) {
255 << p->second->getUrl().getErrorMessage()
256 <<
" for server " << p->second->getName());
259 ++peers_cnt[p->second->getRole()];
281 "balancing configuration");
287 " balancing configuration");
293 " balancing configuration");
302 " standby configuration");
308 " standby configuration");
314 " standby configuration");
PeerConfigPtr getPeerConfig(const std::string &name) const
Returns configuration of the specified server.
uint32_t max_unacked_clients_
Maximum number of unacked clients.
Configuration specific to a single HA state.
StatePausing
State machine pausing modes.
PeerConfigMap peers_
Map of peers' configurations.
void setThisServerName(const std::string &this_server_name)
Sets name of this server.
void setName(const std::string &name)
Sets server name.
State machine configuration information.
void setHAMode(const std::string &ha_mode)
Sets new mode of operation.
void setPausing(const std::string &pausing)
Sets pausing mode for the gievn state.
std::map< std::string, PeerConfigPtr > PeerConfigMap
Map of the servers' configurations.
static Role stringToRole(const std::string &role)
Decodes role provided as a string.
std::string this_server_name_
This server name.
StateConfigPtr getStateConfig(const int state)
Returns pointer to the state specific configuration.
StateConfig(const int state)
Constructor.
PeerConfigPtr getFailoverPeerConfig() const
Returns configuration of the partner which takes part in failover.
uint32_t max_response_delay_
Max delay in response to heartbeats.
bool sync_leases_
Synchronize databases on startup?
StateMachineConfigPtr state_machine_
State machine configuration.
uint32_t sync_page_limit_
Page size limit while synchronizing leases.
uint32_t heartbeat_delay_
Heartbeat delay in milliseconds.
uint32_t max_ack_delay_
Maximum DHCP message ack delay.
std::string getLogLabel() const
Returns a string identifying a server used in logging.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Exception thrown when configuration validation fails.
std::string getThisServerName() const
Returns name of this server.
uint32_t sync_timeout_
Timeout for syncing lease database (ms)
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< StateConfig > StateConfigPtr
Pointer to the state configuration.
bool send_lease_updates_
Send lease updates to partner?
Defines the logger used by the top-level component of kea-dhcp-ddns.
void validate() const
Validates configuration.
PeerConfigMap getOtherServersConfig() const
Returns configuration of other servers.
static std::string HAModeToString(const HAMode &ha_mode)
Returns HA mode name.
void setRole(const std::string &role)
Sets servers role.
A generic exception that is thrown if a function is called in a prohibited way.
Role
Server's role in the High Availability setup.
static std::string pausingToString(const util::StatePausing &pausing)
Returns pausing mode in the textual form.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
static std::string roleToString(const HAConfig::PeerConfig::Role &role)
Returns role name.
PeerConfigPtr getThisServerConfig() const
Returns configuration of this server.
PeerConfigPtr selectNextPeerConfig(const std::string &name)
Creates and returns pointer to the new peer's configuration.
static util::StatePausing stringToPausing(const std::string &pausing)
Converts pausing mode from the textual form.
static HAMode stringToHAMode(const std::string &ha_mode)
Decodes HA mode provided as string.
HAMode ha_mode_
Mode of operation.
boost::shared_ptr< PeerConfig > PeerConfigPtr
Pointer to the server's configuration.