This function is called by the replica to initialize the replica HA runtime parameters to default values.
void mco_HA_replica_params_init(mco_HA_replica_params_t* params)
params
This function is called by a replica to initialize the replica HA runtime parameters to default values. The
parameters are then set according to the application's needs and passed to mco_HA_attach_master().
void
The mco_HA_replica_params_t structure is defined as follows:
typedef struct
{
uint4 mode_flags;
timer_unit initial_timeout;
timer_unit commit_timeout;
timer_unit wait_data_timeout;
mco_ha_notifying notifying_callback;
void* notifying_context;
uint2 repeat_counter;
uint2 mcast_port;
const char *mcast_addr;
const char* cancelpoint_addr;
} mco_HA_replica_params_t;
mode_flags
initial_timeout
commit_timeout
wait_data_timeout
notifying_callback
MCO_HAMODE_REPLICA_NOTIFICATION flag.notifying_context
pcontext parameter for the user-defined notification callback function (see below).repeat_counter
MCO_HAMODE_MCAST_RELIABLE).mcast_port
mcast_addr
cancelpoint_addr
MCO_HAMODE_ALLOW_CANCEL flag is set in flags. If the application does not use mco_HA_create_cancel_socket() and mco_HA_destroy_cancel_socket(), mco_HA_attach_master() implicitly creates the cancel socket before connecting to the master and closes it before exit. In other words, mco_HA_attach_master() "manages" the cancel socket.The possible values for the mode_flags argument are defined as follows:
MCO_HAMODE_ALLOW_CANCEL
mco_HA_cancel()). The cancellation feature is implemented only for TCP and UDP transports.MCO_HAMODE_FORCE_MASTER
MCO_HAMODE_REPLICA_NOTIFICATION
notifying_callback and notifying_context parameters).MCO_HAMODE_SEND_RESTLIST
MCO_HAMODE_EXPLICIT_WRITE_ACCESS
mco_HA_attach_master() API. To enable write operations, the application must explicitly call mco_HA_set_master_params(). xSQL uses this flag to prohibit write/DDL operations in replica switch mode even if the replica is not currently connected to the master. Changing switch mode to master, auto, or standalone (using the xsql_ha_set_switch_mode() UDF) will enable write access to the database.The notification callback prototype is as follows:
typedef void(*mco_ha_notifying)
(uint2 notification_code, uint4 param1, void *param2, void *pcontext);
Arguments param1 and param2 are optional parameters sent to the callback (to
indicate error codes, replica channel, etc.). Argument pcontext is a user-defined parameter
passed via the notifying_context field, and notification_code can have one of the
following values:
MCO_REPL_NOTIFY_CONNECTED
MCO_REPL_NOTIFY_CONNECT_FAILED
MCO_REPL_NOTIFY_DB_EQUAL
MCO_REPL_NOTIFY_DB_LOAD_BEGIN
MCO_REPL_NOTIFY_DB_LOAD_FAILED
param1 argument to the notification callback function contains the MCO_RET code.MCO_REPL_NOTIFY_DB_LOAD_OK
param1 argument to the notification callback function contains the MCO_E_HA_REPLICA_STOP_REASON code.MCO_REPL_NOTIFY_COMMIT_FAILED
param1 argument to the notification callback function contains the MCO_RET code.MCO_REPL_NOTIFY_REPLICA_STOPPED
MCO_REPL_NOTIFY_DB_CREATION_FAILED
param1 argument of the notification callback contains the MCO_RET code.MCO_REPL_NOTIFY_HOTSYNC
MCO_REPL_NOTIFY_EOHOTSYNC
MCO_REPL_NOTIFY_STATEFUL_SYNC
MCO_REPL_NOTIFY_STATEFUL_SYNC_END