26#define CLUSTER_RESTDATALEN(clustercmd_p, data_type) \
27 __extension__((clustercmd_p)->h.data_len - sizeof(data_type) + sizeof(char *))
29#define CLUSTER_LOOP_EXPECTCMD(clustercmd_p, clustercmd_id, ret) {\
32 error("CLUSTER_LOOP_EXPECTCMD()"); \
37 if(clustercmd_p->h.cmd_id != clustercmd_id)\
44#define CLUSTER_REQMEM(data_type, restdata_len) \
45 __extension__(sizeof(clustercmdhdr_t) + sizeof(data_type) + (restdata_len) + 2)
48#define CLUSTER_REQMEM_PADDED(data_type, restdata_len) \
49 CLUSTER_PAD(CLUSTER_REQMEM(data_type, restdata_len))
52#define CLUSTER_ALLOC(data_type, restdata_len, alloc_funct)\
53 (clustercmd_t *)memset((alloc_funct)(CLUSTER_REQMEM_PADDED(data_type, restdata_len)), 0, CLUSTER_REQMEM_PADDED(data_type, restdata_len))
56#define CLUSTER_ALLOCA(data_type, restdata_len)\
57 CLUSTER_ALLOC(data_type, restdata_len, alloca)
60#define CLUSTER_MALLOC(data_type, restdata_len)\
61 CLUSTER_ALLOC(data_type, restdata_len, xmalloc)
65#define CLUSTER_PAD(size) ((((size) + 3) >> 2) << 2)
67#define CLUSTERCMD_SIZE(clustercmd_p) (sizeof(clustercmdhdr_t) + (*(clustercmd_p)).h.data_len)
68#define CLUSTERCMD_SIZE_PADDED(clustercmd_p) (sizeof(clustercmdhdr_t) + CLUSTER_PAD((*(clustercmd_p)).h.data_len))
73 ADLER32_CALC_NONE = 0x00,
74 ADLER32_CALC_HEADER = 0x01,
75 ADLER32_CALC_DATA = 0x02,
76 ADLER32_CALC_ALL = 0x03,
80enum cluster_read_flags {
84typedef enum cluster_read_flags cluster_read_flags_t;
87 NODESTATUS_DOESNTEXIST = 0,
89 NODESTATUS_SEEMSONLINE,
93typedef enum nodestatus nodestatus_t;
98typedef enum nodeid nodeid_t;
100struct packets_stats {
104typedef struct packets_stats packets_stats_t;
111 GHashTable *modtime_ht;
112 GHashTable *serial2queuedpacket_ht;
113 packets_stats_t packets_in;
114 packets_stats_t packets_out;
115 uint32_t last_serial;
118typedef struct nodeinfo nodeinfo_t;
121 CLUSTERCMDID_PING = 0,
122 CLUSTERCMDID_ACK = 1,
123 CLUSTERCMDID_REG = 2,
124 CLUSTERCMDID_HELLO = 3,
125 CLUSTERCMDID_WELCOME = 4,
126 CLUSTERCMDID_DIE = 5,
127 CLUSTERCMDID_HT_EXCH = 6,
130typedef enum clustercmd_id clustercmd_id_t;
132__extension__
struct clustercmd_hello {
135typedef struct clustercmd_hello clustercmd_hello_t;
137#define welcome_to_node_name_len(cmd_p) ((cmd_p)->h.data_len-(((clustercmd_welcome_t *)&(cmd_p)->data)->from_node_name_len)-sizeof(clustercmd_welcome_t))
138#define welcome_to_node_name(cmddata_p) (&cmddata_p->from_node_name[cmddata_p->from_node_name_len])
139__extension__
struct clustercmd_welcome {
140 size_t from_node_name_len;
141 char from_node_name[0];
144typedef struct clustercmd_welcome clustercmd_welcome_t;
146__extension__
struct clustercmd_reg {
149typedef struct clustercmd_reg clustercmd_reg_t;
151struct clustercmd_ack {
154typedef struct clustercmd_ack clustercmd_ack_t;
160typedef enum reject_reason reject_reason_t;
162struct clustercmd_rej {
166typedef struct clustercmd_rej clustercmd_rej_t;
168__extension__
struct clustercmd_ht_exch {
173typedef struct clustercmd_ht_exch clustercmd_ht_exch_t;
175struct clustercmdadler32 {
179typedef struct clustercmdadler32 clustercmdadler32_t;
181struct clustercmdhdr {
186 clustercmdadler32_t adler32;
191typedef struct clustercmdhdr clustercmdhdr_t;
193typedef char clustercmd_die_t;
195__extension__
struct clustercmd {
199 clustercmd_welcome_t welcome;
200 clustercmd_reg_t reg;
201 clustercmd_ack_t ack;
202 clustercmd_rej_t rej;
203 clustercmd_hello_t hello;
204 clustercmd_ht_exch_t ht_exch;
205 clustercmd_die_t die;
208typedef struct clustercmd clustercmd_t;
210struct clustercmdqueuedpackethdri {
213typedef struct clustercmdqueuedpackethdri clustercmdqueuedpackethdri_t;
215struct clustercmdqueuedpackethdro {
219typedef struct clustercmdqueuedpackethdro clustercmdqueuedpackethdro_t;
221struct clustercmdqueuedpackethdr {
222 unsigned int window_id;
224 clustercmdqueuedpackethdri_t i;
225 clustercmdqueuedpackethdro_t o;
228typedef struct clustercmdqueuedpackethdr clustercmdqueuedpackethdr_t;
230struct clustercmdqueuedpacket {
231 clustercmdqueuedpackethdr_t h;
234typedef struct clustercmdqueuedpacket clustercmdqueuedpacket_t;
236struct window_occupied_sides {
240typedef struct window_occupied_sides window_occupied_sides_t;
244 unsigned int packets_len;
245 unsigned int *packets_id;
246 window_occupied_sides_t *occupied_sides;
250typedef struct window window_t;
252typedef int ( *cluster_recvproc_funct_t ) ( clustercmd_t *clustercmd_p );
256extern int cluster_init (
struct ctx *
ctx_p,
struct indexes *indexes_p );
257extern int cluster_deinit();
259extern int cluster_lock (
const char *fpath );
260extern int cluster_lock_byindexes();
261extern int cluster_unlock_all();
262extern int cluster_capture (
const char *fpath );
264extern int cluster_modtime_update (
const char *dirpath,
short int dirlevel, mode_t st_mode );
265extern int cluster_initialsync();
uint32_t adler32_calc(const unsigned char *const data, uint32_t len)
Calculated Adler32 value for char array.