Kea 1.5.0
ha_service_states.cc
Go to the documentation of this file.
1// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <ha_service_states.h>
8
9namespace isc {
10namespace ha {
11
12std::string stateToString(int state) {
13 switch (state) {
14 case HA_BACKUP_ST:
15 return ("backup");
17 return ("hot-standby");
19 return ("load-balancing");
21 return ("partner-down");
22 case HA_READY_ST:
23 return ("ready");
24 case HA_SYNCING_ST:
25 return ("syncing");
27 return ("terminated");
28 case HA_WAITING_ST:
29 return ("waiting");
31 return ("unavailable");
32 default:
33 ;
34 }
35
36 isc_throw(BadValue, "unknown state identifier " << state);
37}
38
39int stringToState(const std::string& state_name) {
40 if (state_name == "backup") {
41 return (HA_BACKUP_ST);
42
43 } else if (state_name == "hot-standby") {
44 return (HA_HOT_STANDBY_ST);
45
46 } else if (state_name == "load-balancing") {
47 return (HA_LOAD_BALANCING_ST);
48
49 } else if (state_name == "partner-down") {
50 return (HA_PARTNER_DOWN_ST);
51
52 } else if (state_name == "ready") {
53 return (HA_READY_ST);
54
55 } else if (state_name == "syncing") {
56 return (HA_SYNCING_ST);
57
58 } else if (state_name == "terminated") {
59 return (HA_TERMINATED_ST);
60
61 } else if (state_name == "waiting") {
62 return (HA_WAITING_ST);
63
64 } else if (state_name == "unavailable") {
65 return (HA_UNAVAILABLE_ST);
66 }
67
68 isc_throw(BadValue, "unknown state " << state_name);
69}
70
71} // end of namespace isc::ha
72} // end of namespace isc
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const int HA_HOT_STANDBY_ST
Hot standby state.
const int HA_UNAVAILABLE_ST
Special state indicating that this server is unable to communicate with the partner.
const int HA_TERMINATED_ST
HA service terminated state.
const int HA_LOAD_BALANCING_ST
Load balancing state.
const int HA_PARTNER_DOWN_ST
Partner down state.
const int HA_WAITING_ST
Server waiting state, i.e. waiting for another server to be ready.
const int HA_BACKUP_ST
Backup state.
const int HA_SYNCING_ST
Synchronizing database state.
std::string stateToString(int state)
Returns state name.
const int HA_READY_ST
Server ready state, i.e. synchronized database, can enable DHCP service.
int stringToState(const std::string &state_name)
Returns state for a given name.
Defines the logger used by the top-level component of kea-dhcp-ddns.