yumapro  20.10-12
YumaPro SDK
agt_yp_ha_standby.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_standby
13 #define _H_agt_yp_ha_standby
14 
15 /* FILE: agt_yp_ha_standby.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 #ifndef _H_agt
40 #include "agt.h"
41 #endif
42 
43 #ifndef _H_agt_yp_ha
44 #include "agt_yp_ha.h"
45 #endif
46 
47 #ifndef _H_status_enum
48 #include "status_enum.h"
49 #endif
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 /********************************************************************
56 * *
57 * C O N S T A N T S *
58 * *
59 *********************************************************************/
60 
61 /********************************************************************
62 * *
63 * T Y P E S *
64 * *
65 *********************************************************************/
66 
67 
68 /********************************************************************
69 * *
70 * F U N C T I O N S *
71 * *
72 *********************************************************************/
73 
74 
94 extern status_t
95  agt_yp_ha_standby_go (yp_ha_service_t *ha_serv);
96 
97 
103 extern void
104  agt_yp_ha_standby_stop (yp_ha_service_t *ha_serv);
105 
106 
112 extern void
113  agt_yp_ha_standby_init (yp_ha_service_t *ha_serv);
114 
115 
123 extern status_t
124  agt_yp_ha_standby_setup (yp_ha_service_t *ha_serv,
125  const xmlChar *new_server_id);
126 
127 
133 extern void
134  agt_yp_ha_standby_cleanup (yp_ha_service_t *ha_serv);
135 
136 
142 extern void
143  agt_yp_ha_standby_check_cleanup (yp_ha_service_t *ha_serv);
144 
145 
156 extern status_t
157  agt_yp_ha_standby_get_config_info (yp_ha_service_t *ha_serv,
158  ncx_transaction_id_t *config_id,
159  const xmlChar **config_stamp);
160 
161 
162 
166 #ifdef __cplusplus
167 } /* end extern 'C' */
168 #endif
169 
170 #endif /* _H_agt_yp_ha_standby */
171 #endif // WITH_YP_HA
ycontrol_set_retry_interval
void ycontrol_set_retry_interval(int retry_int)
Set the re-connect retry interval.
Definition: ycontrol.c:1441
ycontrol_get_service_object
obj_template_t * ycontrol_get_service_object(const xmlChar *service_name)
Get the service object from the payload container.
Definition: ycontrol.c:1088
cfg.h
YCONTROL_MSG_SERVER_REQUEST
@ YCONTROL_MSG_SERVER_REQUEST
server-request sent from server to subsystem
Definition: ycontrol_types.h:72
SES_YPMODE_HA
@ SES_YPMODE_HA
YP-HA mode.
Definition: ses.h:311
agt_util.h
Utility Functions for NCX Server method routines.
OP_EDITOP_REPLACE
@ OP_EDITOP_REPLACE
edit op is replace
Definition: op.h:125
tstamp.h
Timestamp utilities.
agt_ncx_cfg_save
status_t agt_ncx_cfg_save(cfg_template_t *cfg)
Save the specified cfg to the its startup source, which should be stored in the cfg struct.
Definition: agt_ncx.c:5489
OP_EDITOP_NONE
@ OP_EDITOP_NONE
not set
Definition: op.h:123
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
cfg_rwlock_acquire_single_wrlock
status_t cfg_rwlock_acquire_single_wrlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Acquire a single RWLOCK for write access.
Definition: cfg.c:978
val_find_child
val_value_t * val_find_child(const val_value_t *parent, const xmlChar *modname, const xmlChar *childname)
Find the first instance of the specified child node.
Definition: val.c:8560
VAL_NSID
#define VAL_NSID(V)
Access the namespace ID.
Definition: val.h:396
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
AGT_YP_HA
#define AGT_YP_HA
YP-HA service name for YControl.
Definition: agt.h:418
val.h
Value Node Basic Support.
agt_yp_ha_find_server
yp_ha_server_t * agt_yp_ha_find_server(const xmlChar *server_name)
Find a server record.
Definition: agt_yp_ha.c:1070
status_enum.h
global error status code enumerations
YCONTROL_MSGBODY_ERROR
@ YCONTROL_MSGBODY_ERROR
error message
Definition: ycontrol_types.h:96
HA_STATE_STANDBY
@ HA_STATE_STANDBY
standby server role
Definition: agt_yp_ha.h:129
ncx_num.h
NCX Module Library Number Utility Functions.
YCONTROL_MSG_SUBSYS_REQUEST
@ YCONTROL_MSG_SUBSYS_REQUEST
subsystem-request sent from subsystem to server
Definition: ycontrol_types.h:81
agt_ncxserver.h
NCX Server Transport and IO Library.
YCONTROL_MSGBODY_OK
@ YCONTROL_MSGBODY_OK
OK message.
Definition: ycontrol_types.h:90
op.h
NETCONF protocol operations.
ncxconst.h
Contains NCX constants.
ycontrol_register_service
status_t ycontrol_register_service(const xmlChar *service_name, ycontrol_service_start_t service_start, ycontrol_service_stop_t service_stop, ycontrol_service_msg_rcvr_t service_rcvr, ycontrol_service_shutdown_t service_shut)
Register a specific service with the YumaPro control message manager.
Definition: ycontrol.c:951
HA_STATE_BE_STANDBY
@ HA_STATE_BE_STANDBY
in process of becoming standby server
Definition: agt_yp_ha.h:126
yangapi_new_rcb
yangapi_cb_t * yangapi_new_rcb(void)
Create a new YANG-API control block.
Definition: yangapi.c:317
agt_ncx_load_config_ha
status_t agt_ncx_load_config_ha(ses_cb_t *scb, rpc_msg_t *msg, val_value_t *config_val, ncx_transaction_id_t txid)
load-config : validate params callback
Definition: agt_ncx.c:6645
VAL_ENUM_NAME
#define VAL_ENUM_NAME(V)
Access the enum name in the value ONLY if BCX_NT_ENUM This is the macro used to check values in SIL c...
Definition: val.h:434
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
val_remove_child
void val_remove_child(val_value_t *child)
Remove a child value node from its parent value node.
Definition: val.c:8316
ERR_NCX_MISSING_PARM
@ ERR_NCX_MISSING_PARM
233
Definition: status_enum.h:272
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
AGT_HA_ROLE_STANDBY
@ AGT_HA_ROLE_STANDBY
HA standby role.
Definition: agt.h:686
agt_yangpatch_edit
status_t agt_yangpatch_edit(ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg)
Handle a YANG Patch edit.
Definition: agt_yangpatch.c:1309
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
agt_yp_ha_standby_get_config_info
status_t agt_yp_ha_standby_get_config_info(yp_ha_service_t *ha_serv, ncx_transaction_id_t *config_id, const xmlChar **config_stamp)
Get the config ID and timestamp info.
Definition: agt_yp_ha_standby.c:1724
cfg_get_last_ch_time
const xmlChar * cfg_get_last_ch_time(cfg_template_t *cfg)
Get the last-modified timestamp.
Definition: cfg.c:2896
agt_get_server_key
const xmlChar * agt_get_server_key(void)
Get the ha-server-key string.
Definition: agt.c:4717
val_add_child
void val_add_child(val_value_t *child, val_value_t *parent)
Add a child (deprecated: use val_child_add instead)
Definition: val.c:8231
NC_MODULE
#define NC_MODULE
Internal NETCONF YANG module.
Definition: ncxconst.h:71
ycontrol_cleanup_ex
void ycontrol_cleanup_ex(boolean do_ncx_cleanup)
Cleanup ycontrol layer (extended)
Definition: ycontrol.c:766
agt_yp_ha_standby.h
YumaPro High Availability module (YP-HA). HA Standby Mode.
val_dump_value
void val_dump_value(val_value_t *val, int32 startindent, log_debug_t lvl)
Printf the specified val_value_t struct to the logfile, or stdout if none set Uses conf file format (...
Definition: val.c:5688
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
agt_ncx.h
NETCONF Server standard method routines.
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
cfg_rwlock_release_all_locks
status_t cfg_rwlock_release_all_locks(thd_tcb_t *tcb)
Release all RWLOCKs recorded in TCB lock state structure.
Definition: cfg.c:675
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
agt_yp_ha_standby_stop
void agt_yp_ha_standby_stop(yp_ha_service_t *ha_serv)
Exit YP-HA Standby server mode.
Definition: agt_yp_ha_standby.c:1583
val_util.h
Value Node Utilities.
ses_indent_count
int32 ses_indent_count(const ses_cb_t *scb)
Get the logging indent count for this session.
Definition: ses.c:2801
agt_yp_ha_standby_setup
status_t agt_yp_ha_standby_setup(yp_ha_service_t *ha_serv, const xmlChar *new_server_id)
Setup the HA service standby_cb record for YP-HA Standby mode.
Definition: agt_yp_ha_standby.c:1616
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
thd_module_db_wrlock
status_t thd_module_db_wrlock(thd_tcb_t *tcb)
Request write access to the module DB ("object tree").
Definition: thd.c:1397
agt_cfg_txid_in_progress
ncx_transaction_id_t agt_cfg_txid_in_progress(ncx_cfg_t cfgid)
Return the ID of the current transaction ID in progress.
Definition: agt_cfg.c:1479
OP_ERROP_CONTINUE
@ OP_ERROP_CONTINUE
continue-on-error
Definition: op.h:176
ycontrol_init2_ha_thd
void ycontrol_init2_ha_thd(thd_tcb_t *tcb)
Setup scb->tcb for ycontrol session.
Definition: ycontrol.c:734
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
ycontrol_set_timer_handler
void ycontrol_set_timer_handler(ycontrol_timer_handler_t timer_handler)
Set the timer callback handler.
Definition: ycontrol.c:1424
ERR_INTERNAL_INIT_SEQ
@ ERR_INTERNAL_INIT_SEQ
007
Definition: status_enum.h:197
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
agt_check_load_config
status_t agt_check_load_config(agt_ha_role_t ha_role)
Check if the boot-time load-config should be done because it was deferred while waiting for the YP-HA...
Definition: agt.c:4897
agt_yp_ha_get_service_cb
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:1006
SES_SET_YPMODE
#define SES_SET_YPMODE(S, V)
set internal YP mode flag
Definition: ses.h:287
agt_yp_ha_standby_cleanup
void agt_yp_ha_standby_cleanup(yp_ha_service_t *ha_serv)
Cleanup the YP-HA Standby module.
Definition: agt_yp_ha_standby.c:1662
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
typ.h
Parameter Type Handler.
thd_module_db_unlock
status_t thd_module_db_unlock(thd_tcb_t *tcb)
Unlock (release access) to the module DB ("object tree").
Definition: thd.c:1453
NCX_CFGID_RUNNING
@ NCX_CFGID_RUNNING
running datastore (no value for not set!)
Definition: ncxtypes.h:384
yangconst.h
Contains YANG constants separated to prevent H file include loops.
yang_patch.h
YANG Patch Media Type.
agt.h
Multi-Protocol Network Management Server.
agt_make_leaf
val_value_t * agt_make_leaf(obj_template_t *parentobj, const xmlChar *leafname, const xmlChar *leafstrval, status_t *res)
make a string val_value_t struct for a specified leaf or leaf-list
Definition: agt_util.c:3683
agt_yp_ha_standby_init
void agt_yp_ha_standby_init(yp_ha_service_t *ha_serv)
Initialize the YP-HA Standby module.
Definition: agt_yp_ha_standby.c:1600
VAL_UINT64
#define VAL_UINT64(V)
Access the value as an uint64 ONLY if NCX_BT_UINT64.
Definition: val.h:503
HA_STATE_WAIT_ROLE
@ HA_STATE_WAIT_ROLE
waiting for HA role
Definition: agt_yp_ha.h:117
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
ncx_find_rpc
obj_template_t * ncx_find_rpc(const ncx_module_t *mod, const xmlChar *rpcname)
Check if a rpc_template_t in the mod->rpcQ.
Definition: ncx.c:3775
YCONTROL_MSG_SERVER_RESPONSE
@ YCONTROL_MSG_SERVER_RESPONSE
server-response sent from server to subsystem
Definition: ycontrol_types.h:75
agt_yangpatch.h
YumaPro YANG-PATCH Edit Handler for HA/RESTCONF/NETCONF.
ycontrol_init2_ha
status_t ycontrol_init2_ha(const char *server_id, const char *server_addr, uint16 server_port)
Phase 2 initialization for HA.
Definition: ycontrol.c:669
ycontrol_send
status_t ycontrol_send(const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, status_t msg_status)
Send a YControl message.
Definition: ycontrol.c:1116
agt_timer_handler
void agt_timer_handler(void)
Handle an incoming server timer polling interval.
Definition: agt_timer.c:245
obj_find_child
obj_template_t * obj_find_child(obj_template_t *obj, const xmlChar *modname, const xmlChar *objname)
Find a child object with the specified Qname.
Definition: obj.c:6116
ncx_find_any_object
obj_template_t * ncx_find_any_object(const xmlChar *objname)
Find any top-level object in any YANG module.
Definition: ncx.c:4025
agt_cfg_free_transaction
void agt_cfg_free_transaction(agt_cfg_transaction_t *txcb)
Clean and free a agt_cfg_transaction_t struct.
Definition: agt_cfg.c:1278
YCONTROL_MSG_SERVER_EVENT
@ YCONTROL_MSG_SERVER_EVENT
server-event sent from server to subsystem
Definition: ycontrol_types.h:69
ycontrol_unregister_service
void ycontrol_unregister_service(const xmlChar *service_name)
Unregister a specific service.
Definition: ycontrol.c:997
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
ycontrol_msg_cmn.h
YControl Message Utilities.
VAL_BOOL
#define VAL_BOOL(V)
Access the value as a boolean ONLY IF btyp == NCX_BT_BOOLEAN.
Definition: val.h:405
OP_EDITOP_LOAD
@ OP_EDITOP_LOAD
load, internal enum
Definition: op.h:128
log.h
NCX System Logging Manager.
agt_ncx_load.h
NETCONF Server load and unload operations.
xmlns_nc_id
xmlns_id_t xmlns_nc_id(void)
Get the ID for the NETCONF namespace or 0 if it doesn't exist.
Definition: xmlns.c:880
rpc_new_msg
rpc_msg_t * rpc_new_msg(void)
Malloc and initialize a new rpc_msg_t struct.
Definition: rpc.c:84
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
rpc_err.h
NETCONF protocol standard error definitions.
YCONTROL_MSG_SUBSYS_EVENT
@ YCONTROL_MSG_SUBSYS_EVENT
subsystem-event sent from subsystem to server
Definition: ycontrol_types.h:78
agt_cfg.h
Manage Server configuration edit transactions.
agt_make_uint64_leaf2
val_value_t * agt_make_uint64_leaf2(obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, uint64 leafval, status_t *res)
make a val_value_t struct for a specified leaf or leaf-list
Definition: agt_util.c:5715
rpc_free_msg
void rpc_free_msg(rpc_msg_t *msg)
Free all the memory used by the specified rpc_msg_t.
Definition: rpc.c:152
yangapi_free_rcb
void yangapi_free_rcb(yangapi_cb_t *rcb)
Free a YANGAPI control block.
Definition: yangapi.c:351
agt_get_server_id
const xmlChar * agt_get_server_id(void)
Get the server-id string.
Definition: agt.c:4700
agt_ncx_load_module_ha
status_t agt_ncx_load_module_ha(ses_cb_t *scb, rpc_msg_t *msg, const xmlChar *name, const xmlChar *revision, boolean is_module, boolean is_load, val_value_t *dev_parent)
Handle a <module-update> event in YP-HA standby mode.
Definition: agt_ncx_load.c:2767
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
agt_ncxserver_get_timer_tcb
thd_tcb_t * agt_ncxserver_get_timer_tcb(void)
Get the timer TCB to hijack for the YP-HA standby SCB.
Definition: agt_ncxserver.c:3364
ncx.h
YANG module utility functions.
agt_yp_ha.h
YumaPro High Availability module (YP-HA)
obj.h
Data Object Support.
cfg_get_config_id
cfg_template_t * cfg_get_config_id(ncx_cfg_t cfgid)
Get the config struct from its ID.
Definition: cfg.c:1530
ycontrol.h
YumaPro Subsystem Control Protocol.
cfg_fill_candidate_from_running
status_t cfg_fill_candidate_from_running(ses_id_t sesid)
Fill the <candidate> config with the config contents of the <running> config.
Definition: cfg.c:1582
agt_yp_ha_standby_check_cleanup
void agt_yp_ha_standby_check_cleanup(yp_ha_service_t *ha_serv)
Check if the cleanup of standby mode is needed.
Definition: agt_yp_ha_standby.c:1684
SES_MY_SID
#define SES_MY_SID(S)
get session-id
Definition: ses.h:105
agt_ycontrol.h
Handle the YumaPro Control Protocol <ycontrol> (top-level) element.
val_init_from_template
void val_init_from_template(val_value_t *val, struct obj_template_t_ *obj)
Initialize a value node from its object template.
YCONTROL_MSGBODY_PAYLOAD
@ YCONTROL_MSGBODY_PAYLOAD
payload message
Definition: ycontrol_types.h:93
VAL_STR
#define VAL_STR(V)
Access the value as a string ONLY if typ_is_string() is true.
Definition: val.h:464
agt_timer.h
Handle timer services for the server.
agt_init2_done
boolean agt_init2_done(void)
Check if the init2 phase is complete.
Definition: agt.c:4983
ycontrol_init_ex
status_t ycontrol_init_ex(int argc, char *argv[], const xmlChar *subsys_id, boolean is_standby)
Initialize the YControl library.
Definition: ycontrol.c:513
ncx_find_module
ncx_module_t * ncx_find_module(const xmlChar *modname, const xmlChar *revision)
Find a ncx_module_t in the ncx_sesmodQ.
Definition: ncx.c:3227
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
HA_STATE_ERROR
@ HA_STATE_ERROR
HA error state.
Definition: agt_yp_ha.h:114
val_free_value
void val_free_value(val_value_t *val)
Scrub the memory in a val_value_t by freeing all the sub-fields and then freeing the entire struct it...
Definition: val.c:2842
status.h
Global error messages for status code enumerations.
ycontrol_shutdown_now
boolean ycontrol_shutdown_now(void)
Check if the YControl subsystem has shut down because a <shutdown-event> was received from the server...
Definition: ycontrol.c:1408
dlq.h
dlq provides general double-linked list and queue support:
agt_yp_ha_standby_go
status_t agt_yp_ha_standby_go(yp_ha_service_t *ha_serv)
Go into YP-HA Standby server mode.
Definition: agt_yp_ha_standby.c:1567
xmlns_check_deleted_ns
void xmlns_check_deleted_ns(void)
Check if a deleted namespace is pending and free it.
Definition: xmlns.c:1382
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297
ncx_transaction_id_t
uint64 ncx_transaction_id_t
transaction is scoped to single session write operation on a config
Definition: ncxtypes.h:548