23 #include "gu_config.h"
29 typedef int64_t gcs_seqno_t;
32 static const gcs_seqno_t GCS_SEQNO_ILL = -1;
34 static const gcs_seqno_t GCS_SEQNO_NIL = 0;
36 static const gcs_seqno_t GCS_SEQNO_FIRST = 1;
38 #define GCS_UUID_LEN 16
40 #define GCS_MAX_ACT_SIZE 0x7FFFFFFF
57 gcs_create (gu_config_t* conf, gcache_t* cache,
58 const char* node_name,
const char* inc_addr,
59 int repl_proto_ver,
int appl_proto_ver);
80 const uint8_t uuid[GCS_UUID_LEN]);
146 typedef enum gcs_act_type
180 const struct gu_buf* act_bufs,
182 gcs_act_type_t act_type,
186 static inline long gcs_send (
gcs_conn_t*
const conn,
187 const void*
const act,
188 size_t const act_size,
189 gcs_act_type_t
const act_type,
190 bool const scheduled)
192 struct gu_buf const buf = { act, (ssize_t)act_size };
193 return gcs_sendv (conn, &buf, act_size, act_type, scheduled);
218 const struct gu_buf* act_in,
223 static inline long gcs_repl (
gcs_conn_t*
const conn,
225 bool const scheduled)
227 struct gu_buf const buf = { action->buf, action->
size };
228 return gcs_replv (conn, &buf, action, scheduled);
366 extern long gcs_conf_set_log_file (FILE *file);
367 extern long gcs_conf_set_log_callback (
void (*logger) (
int,
const char*));
368 extern long gcs_conf_self_tstamp_on ();
369 extern long gcs_conf_self_tstamp_off ();
370 extern long gcs_conf_debug_on ();
371 extern long gcs_conf_debug_off ();
377 gcs_conf_set_pkt_size (
gcs_conn_t *conn,
long pkt_size);
379 #define GCS_DEFAULT_PKT_SIZE 64500
386 typedef enum gcs_node_state
388 GCS_NODE_STATE_NON_PRIM,
390 GCS_NODE_STATE_JOINER,
391 GCS_NODE_STATE_DONOR,
392 GCS_NODE_STATE_JOINED,
393 GCS_NODE_STATE_SYNCED,
418 double send_q_len_avg;
435 #define GCS_ARBITRATOR_NAME "garb"
gcs_node_state_t my_state
index of this node in the configuration
Definition: gcs.h:409
long gcs_open(gcs_conn_t *conn, const char *channel, const char *url, bool const bootstrap)
Opens connection to group (joins channel).
Definition: gcs.c:1253
const char * gcs_act_type_to_str(gcs_act_type_t type)
Definition: gcs.c:47
void gcs_register_params(gu_config_t *const conf)
Definition: gcs.c:2046
int recv_q_len
current recv queue size
Definition: gcs.h:425
long long fc_sent
faction of time paused due to flow control
Definition: gcs.h:422
int repl_proto_ver
current node state
Definition: gcs.h:410
long long fc_received
flow control stops sent
Definition: gcs.h:423
long gcs_schedule(gcs_conn_t *conn)
Schedules entry to CGS send monitor. Locks send monitor and should be quickly followed by gcs_repl()/...
Definition: gcs.c:1449
ssize_t size
Definition: gcs.h:199
char data[1]
application protocol version to use
Definition: gcs.h:412
long gcs_wait(gcs_conn_t *conn)
Deprecated. Waits until the group catches up. This call checks if any member of the group (including ...
Definition: gcs.c:1764
long gcs_resume_recv(gcs_conn_t *conn)
Definition: gcs.c:1742
long gcs_recv(gcs_conn_t *conn, struct gcs_action *action)
Receives an action from group. Blocks if no actions are available. Action buffer is allocated by GCS ...
Definition: gcs.c:1666
uint8_t uuid[GCS_UUID_LEN]
configuration ID (-1 if non-primary)
Definition: gcs.h:406
int appl_proto_ver
replicator protocol version to use
Definition: gcs.h:411
const char * gcs_param_get(gcs_conn_t *conn, const char *key)
Definition: gcs.c:2083
long gcs_replv(gcs_conn_t *const conn, const struct gu_buf *const act_in, struct gcs_action *const act, bool const scheduled)
Replicates a vector of buffers as a single action. Sends action to group and blocks until it is recei...
Definition: gcs.c:1465
void gcs_flush_stats(gcs_conn_t *conn)
Definition: gcs.c:1842
double recv_q_len_avg
average send queue length per send call
Definition: gcs.h:419
long gcs_request_state_transfer(gcs_conn_t *conn, const void *req, size_t size, const char *donor, gcs_seqno_t *local)
Sends state transfer request Broadcasts state transfer request which will be passed to one of the sui...
Definition: gcs.c:1588
const char * gcs_node_state_to_str(gcs_node_state_t state)
Definition: gcs.c:29
gcs_seqno_t gcs_caused(gcs_conn_t *conn)
Definition: gcs.c:1459
long gcs_param_set(gcs_conn_t *conn, const char *key, const char *value)
Definition: gcs.c:2052
long gcs_interrupt(gcs_conn_t *conn, long handle)
Interrupt a thread waiting to enter send monitor.
Definition: gcs.c:1454
long gcs_desync(gcs_conn_t *conn, gcs_seqno_t *local)
Turns off flow control on the node. Effectively desynchronizes the node from the cluster (while the n...
Definition: gcs.c:1645
size_t recv_q_size
flow control stops received
Definition: gcs.h:424
long gcs_destroy(gcs_conn_t *conn)
Frees resources associuated with connection handle.
Definition: gcs.c:1362
gcs_seqno_t gcs_local_sequence(gcs_conn_t *conn)
Allocate local seqno for accessing local resources.
Definition: gcs.c:1817
long gcs_set_last_applied(gcs_conn_t *conn, gcs_seqno_t seqno)
Definition: gcs.c:1791
long gcs_join(gcs_conn_t *conn, gcs_seqno_t seqno)
Informs group on behalf of donor that state stransfer is over. If status is non-negative, joiner will be considered fully joined to group.
Definition: gcs.c:1809
void gcs_get_stats(gcs_conn_t *conn, struct gcs_stats *stats)
Definition: gcs.c:1823
long memb_num
group UUID
Definition: gcs.h:407
long my_idx
number of members in configuration
Definition: gcs.h:408
gcs_seqno_t conf_id
last global seqno applied by this group
Definition: gcs.h:405
long gcs_close(gcs_conn_t *conn)
Closes connection to group.
Definition: gcs.c:1310
long long fc_paused_ns
average recv queue length per queued action
Definition: gcs.h:420
int send_q_len
current recv queue length
Definition: gcs.h:426
double fc_paused_avg
total nanoseconds spent in paused state
Definition: gcs.h:421
gcs_conn_t * gcs_create(gu_config_t *const conf, gcache_t *const gcache, const char *const node_name, const char *const inc_addr, int const repl_proto_ver, int const appl_proto_ver)
Creates GCS connection handle.
Definition: gcs.c:220
long gcs_sendv(gcs_conn_t *const conn, const struct gu_buf *const act_bufs, size_t const act_size, gcs_act_type_t const act_type, bool const scheduled)
Sends a vector of buffers as a single action to group and returns. A copy of action will be returned ...
Definition: gcs.c:1421