Name

confd_lib_ha — library for connecting to ConfD HA subsystem

Synopsis

#include <confd_lib.h>
#include <confd_ha.h>
      
int confd_ha_connect(int sock,
 const struct sockaddr* srv,
 int srv_sz,
 const char *token);
 
int confd_ha_bemaster(int sock,
 confd_value_t *mynodeid);
 
int confd_ha_beslave(int sock,
 confd_value_t *mynodeid,
 struct confd_ha_node *master,
 int waitreply);
 
int confd_ha_berelay(int sock);
 
int confd_ha_benone(int sock);
 
int confd_ha_status(int sock,
 struct confd_ha_status *stat);
 
int confd_ha_slave_dead(int sock,
 confd_value_t *nodeid);
 

LIBRARY

ConfD Library, (libconfd, -lconfd)

DESCRIPTION

The libconfd shared library is used to connect to the ConfD High Availability (HA) subsystem. ConfD can replicate the configuration data on several nodes in a cluster. The purpose of this API is to manage the HA functionality. The details on usage of the HA API are described in the chapter High availability in the User Guide.

FUNCTIONS

int confd_ha_connect(int sock,
 const struct sockaddr* srv,
 int srv_sz,
 const char *token);
 

Connect a HA socket which can be used to control a ConfD HA node. The token is a secret string that must be shared by all participants in the cluster. There can only be one HA socket towards ConfD, a new call to confd_ha_connect() makes ConfD close the previous connection and reset the token to the new value. Returns CONFD_OK or CONFD_ERR.

Note

If this call fails (i.e. does not return CONFD_OK), the socket descriptor must be closed and a new socket created before the call is re-attempted.

int confd_ha_bemaster(int sock,
 confd_value_t *mynodeid);
 

Instruct a HA node to be master and also give the node a name. Returns CONFD_OK or CONFD_ERR.

Errors: CONFD_ERR_HA_BIND if we cannot bind the TCP socket, CONFD_ERR_BADSTATE if ConfD is still in start phase 0.

int confd_ha_beslave(int sock,
 confd_value_t *mynodeid,
 struct confd_ha_node *master,
 int waitreply);
 

Instruct a ConfD HA node to be slave with a named master. The waitreply is a boolean int. If 1, the function is synchronous and it will hang until the node has initialized its CDB database. This may mean that the CDB database is copied in its entirety from the master. If 0, we do not wait for the reply, but it is possible to use a notifications socket and get notified asynchronously via a HA_INFO_BESLAVE_RESULT notification. In both cases, it is also possible to use a notifications socket and get notified asynchronously when CDB at the slave is initialized.

If the call of this function fails with confd_errno CONFD_ERR_HA_CLOSED, it means that the initial synchronization with the master failed, either due to the socket being closed or due to a timeout while waiting for a response from the master. The function will fail with error CONFD_ERR_BADSTATE if ConfD is still in start phase 0.

Errors: CONFD_ERR_HA_CONNECT, CONFD_ERR_HA_BADNAME, CONFD_ERR_HA_BADTOKEN, CONFD_ERR_HA_BADFXS, CONFD_ERR_HA_BADVSN, CONFD_ERR_HA_CLOSED, CONFD_ERR_BADSTATE

int confd_ha_berelay(int sock);
 

Instruct an established HA slave node to be a relay for other slaves. This can be useful in certain deployment scenarios, but makes the management of the cluster more complex. Read more about this in the Relay slaves section of the High availability chapter in the User Guide. Returns CONFD_OK or CONFD_ERR.

Errors: CONFD_ERR_HA_BIND if we cannot bind the TCP socket, CONFD_ERR_BADSTATE if the node is not already a slave.

int confd_ha_benone(int sock);
 

Instruct a node to resume the initial state, i.e. neither master nor slave.

Errors: CONFD_ERR_BADSTATE if ConfD is still in start phase 0.

int confd_ha_status(int sock,
 struct confd_ha_status *stat);
 

Query a ConfD HA node for its status. If successful, the function populates the confd_ha_status structure. This is the only HA related function which is possible to call while the ConfD daemon is still in start phase 0.

int confd_ha_slave_dead(int sock,
 confd_value_t *nodeid);
 

This function must be used by the application to inform ConfD HA subsystem that another node which is possibly connected to ConfD is dead.

Errors: CONFD_ERR_BADSTATE if ConfD is still in start phase 0.

SEE ALSO

confd.conf(5) - ConfD daemon configuration file format

The ConfD User Guide