yumapro  21.10T-8
YumaPro SDK
agt_yp_ha.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 - 2021, YumaWorks, Inc., All Rights Reserved.
3  *
4  * Unless required by applicable law or agreed to in writing,
5  * software distributed under the License is distributed on an
6  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7  * KIND, either express or implied. See the License for the
8  * specific language governing permissions and limitations
9  * under the License.
10  */
11 #ifdef WITH_YP_HA
12 #ifndef _H_agt_yp_ha
13 #define _H_agt_yp_ha
14 
15 /* FILE: agt_yp_ha.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
28 /*********************************************************************
29 * *
30 * C H A N G E H I S T O R Y *
31 * *
32 *********************************************************************
33 
34 date init comment
35 ----------------------------------------------------------------------
36 06-feb-16 abb Begun
37 */
38 
39 #include <xmlstring.h>
40 
41 #ifndef _H_agt
42 #include "agt.h"
43 #endif
44 
45 #ifndef _H_agt_cfg
46 #include "agt_cfg.h"
47 #endif
48 
49 #ifndef _H_status_enum
50 #include "status_enum.h"
51 #endif
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 
58 /* header only */
59 
60 
84 /********************************************************************
85 * *
86 * C O N S T A N T S *
87 * *
88 *********************************************************************/
89 
90 
91 /********************************************************************
92 * *
93 * T Y P E S *
94 * *
95 *********************************************************************/
96 
98 typedef enum yp_ha_state_t_ {
101 
104 
107 
110 
113 
116 
119 
122 
125 } yp_ha_state_t;
126 
127 
133 typedef struct yp_ha_server_t_ {
135  dlq_hdr_t qhdr;
136 
138  xmlChar *server_name;
139 
141  xmlChar *server_addr;
142 
144  uint16 server_port;
145 
147  struct yp_ha_subsys_t_ *subsys_cb;
148 
150 
151 
157 typedef struct yp_ha_service_t_ {
159  dlq_hdr_t ha_serverQ;
160 
163 
165  const xmlChar *ha_server_key;
166 
169 
172 
174  yp_ha_state_t ha_state;
175 
177  boolean ha_enabled;
178 
180  boolean ha_init_done;
181 
183  struct yp_ha_active_t_ *active_cb;
184 
186  struct yp_ha_standby_t_ *standby_cb;
187 
189  xmlChar tstamp[TSTAMP_MIN_SIZE];
190 
193 
196 
198  xmlChar last_error_time[TSTAMP_MIN_SIZE];
199 
202 
204 
205 
206 /********************************************************************
207 * *
208 * F U N C T I O N S *
209 * *
210 *********************************************************************/
211 
220 extern void
221  agt_yp_ha_preinit (void);
222 
223 
229 extern status_t
230  agt_yp_ha_init (void);
231 
232 
241 extern status_t
242  agt_yp_ha_init2 (void);
243 
244 
250 extern void
251  agt_yp_ha_cleanup (void);
252 
253 
260 extern status_t
261  agt_yp_ha_add_server_cli (const xmlChar *valstr);
262 
263 
269 extern boolean
270  agt_yp_ha_mgmt_enabled (void);
271 
272 
278 extern status_t
279  agt_yp_ha_be_active (void);
280 
281 
287 extern status_t
288  agt_yp_ha_be_none (void);
289 
290 
297 extern status_t
298  agt_yp_ha_be_standby (const xmlChar *new_server_id);
299 
300 
306 extern agt_ha_role_t
307  agt_yp_ha_get_role (void);
308 
309 
317 extern const xmlChar *
318  agt_yp_ha_get_role_state (const xmlChar **tstamp);
319 
320 
326 extern yp_ha_service_t *
328 
329 
335 extern void
337 
338 
348 extern yp_ha_server_t *
349  agt_yp_ha_find_server (const xmlChar *server_name);
350 
351 
358 extern void
360  agt_cfg_transaction_t *txcb);
361 
362 
368 extern status_t
369  agt_yp_ha_nvstore (void);
370 
371 
378 extern boolean
379  agt_yp_ha_sil_disabled (void);
380 
381 
382 
393 extern void
394  agt_yp_ha_mod_event (const xmlChar *name,
395  const xmlChar *revision,
396  val_value_t *inputval,
397  boolean is_module,
398  boolean is_load);
399 
400 
410 extern status_t
412  const xmlChar **config_stamp);
413 
414 
415 
426 extern status_t
427  agt_yp_ha_get_error_info (const xmlChar **tstamp,
428  const xmlChar **msg);
429 
430 
436 extern const xmlChar *
438 
439 
440 
451 extern status_t
452  agt_yp_ha_get_config_counters(uint64 *updates,
453  uint64 *failures);
454 
455 
459 #ifdef __cplusplus
460 } /* end extern 'C' */
461 #endif
462 
463 #endif /* _H_agt_yp_ha */
464 #endif // WITH_YP_HA
yp_ha_server_t * agt_yp_ha_find_server(const xmlChar *server_name)
Find a server record.
Definition: agt_yp_ha.c:1125
uint64 ncx_transaction_id_t
transaction is scoped to single session write operation on a config
Definition: ncxtypes.h:700
in process of becoming standby server
Definition: agt_yp_ha.h:118
status_t agt_yp_ha_nvstore(void)
Do an <nvstore> in the active role.
Definition: agt_yp_ha.c:1239
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
void agt_yp_ha_check_standby_io(void)
Check if the YP-SA Standby mode needs to check for input.
Definition: agt_yp_ha.c:1078
One YANG data-def-stmt.
Definition: obj.h:1140
standby server role
Definition: agt_yp_ha.h:121
boolean ha_enabled
HA enabled flag.
Definition: agt_yp_ha.h:177
status_t agt_yp_ha_init2(void)
Initialize the YP-HA shared state (phase 2 init, post external init).
Definition: agt_yp_ha.c:372
struct yp_ha_active_t_ * active_cb
active mode
Definition: agt_yp_ha.h:183
boolean ha_init_done
HA init done flag.
Definition: agt_yp_ha.h:180
yp_ha_state_t
YP-HA Shared State.
Definition: agt_yp_ha.h:98
const xmlChar * agt_yp_ha_get_role_state(const xmlChar **tstamp)
Get the YP-HA server role for this server as a string.
Definition: agt_yp_ha.c:1012
Transaction Control Block.
Definition: agt_cfg.h:224
void agt_yp_ha_cleanup(void)
Cleanup the YP-HA Module.
Definition: agt_yp_ha.c:448
status_t last_error_num
last error message leaf
Definition: agt_yp_ha.h:201
in process of becoming active server
Definition: agt_yp_ha.h:112
void agt_yp_ha_config_update(rpc_msg_t *msg, agt_cfg_transaction_t *txcb)
Do a config update in the active role.
Definition: agt_yp_ha.c:1150
val_value_t * payload_val
payload_val for reuse and faster messages
Definition: agt_yp_ha.h:171
status_t agt_yp_ha_add_server_cli(const xmlChar *valstr)
Add an HA server entry from the –ha-server CLI parm.
Definition: agt_yp_ha.c:482
uint64 config_failures
config-failures leaf
Definition: agt_yp_ha.h:195
xmlChar * server_name
service name
Definition: agt_yp_ha.h:138
status_t agt_yp_ha_get_config_counters(uint64 *updates, uint64 *failures)
Get the config-updates and config-failures counters.
Definition: agt_yp_ha.c:1459
agt_ha_role_t agt_yp_ha_get_role(void)
Get the YP-HA server role for this server.
Definition: agt_yp_ha.c:970
not set
Definition: agt_yp_ha.h:100
Manage Server configuration edit transactions.
one value to match one type
Definition: val.h:870
status_t agt_yp_ha_be_standby(const xmlChar *new_server_id)
Put this server in YP-HA Standby mode.
Definition: agt_yp_ha.c:781
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:67
obj_template_t * yp_ha_obj
YANG object template for service layer.
Definition: agt_yp_ha.h:168
status_t
global error return code
Definition: status_enum.h:186
Multi-Protocol Network Management Server.
yp_ha_state_t ha_state
current HA state
Definition: agt_yp_ha.h:174
uint16 server_port
peer TCP port number
Definition: agt_yp_ha.h:144
shutting down HA service
Definition: agt_yp_ha.h:124
const xmlChar * agt_yp_ha_get_active_server(void)
Get the active server or in progress of connecting.
Definition: agt_yp_ha.c:1427
void agt_yp_ha_preinit(void)
Pre-Initialize the YP-HA subsys handler.
Definition: agt_yp_ha.c:221
boolean agt_yp_ha_sil_disabled(void)
Check if all hooks are enabled or disabled because of the YP-HA Standby mode.
Definition: agt_yp_ha.c:1276
yp_ha_service_t * agt_yp_ha_get_service_cb(void)
Get the YP-HA service control block for this server.
Definition: agt_yp_ha.c:1061
uint64 config_updates
config-updates leaf
Definition: agt_yp_ha.h:192
boolean agt_yp_ha_mgmt_enabled(void)
Check if MGMT protocols disabled because YP-HA Standby mode.
Definition: agt_yp_ha.c:926
status_t agt_yp_ha_be_none(void)
Put this server in WAIT_ROLE state.
Definition: agt_yp_ha.c:681
HA disabled.
Definition: agt_yp_ha.h:103
struct yp_ha_subsys_t_ * subsys_cb
maintained only by the active server
Definition: agt_yp_ha.h:147
waiting for HA role
Definition: agt_yp_ha.h:109
xmlChar * server_addr
peer IP address or domain name
Definition: agt_yp_ha.h:141
yp_ha_server_t * my_server_cb
HA control block.
Definition: agt_yp_ha.h:162
status_t agt_yp_ha_get_error_info(const xmlChar **tstamp, const xmlChar **msg)
Get the last error time and error message, if any.
Definition: agt_yp_ha.c:1392
struct yp_ha_standby_t_ * standby_cb
standby mode
Definition: agt_yp_ha.h:186
void agt_yp_ha_mod_event(const xmlChar *name, const xmlChar *revision, val_value_t *inputval, boolean is_module, boolean is_load)
Generate a module event.
Definition: agt_yp_ha.c:1309
active server role
Definition: agt_yp_ha.h:115
YP-HA service instance.
Definition: agt_yp_ha.h:157
agt_ha_role_t
server HA mode mode
Definition: agt.h:689
const xmlChar * ha_server_key
shared HA pool key
Definition: agt_yp_ha.h:165
For each CLI-configured ha-server there will be one entry entry the active and standby both need this...
Definition: agt_yp_ha.h:133
status_t agt_yp_ha_init(void)
Initialize the YP-HA subsys handler (begin phase 2 init)
Definition: agt_yp_ha.c:247
status_t agt_yp_ha_be_active(void)
Put this server in YP-HA Active mode.
Definition: agt_yp_ha.c:572
status_t agt_yp_ha_get_config_info(ncx_transaction_id_t *config_id, const xmlChar **config_stamp)
Get the config ID and timestamp info.
Definition: agt_yp_ha.c:1349
global error status code enumerations
HA error state.
Definition: agt_yp_ha.h:106