20 #ifdef CLUSTER_SUPPORT
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,
80 enum cluster_read_flags {
84 typedef enum cluster_read_flags cluster_read_flags_t;
87 NODESTATUS_DOESNTEXIST = 0,
89 NODESTATUS_SEEMSONLINE,
93 typedef enum nodestatus nodestatus_t;
98 typedef enum nodeid nodeid_t;
100 struct packets_stats {
104 typedef 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;
118 typedef 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,
130 typedef enum clustercmd_id clustercmd_id_t;
132 __extension__
struct clustercmd_hello {
135 typedef 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];
144 typedef struct clustercmd_welcome clustercmd_welcome_t;
146 __extension__
struct clustercmd_reg {
149 typedef struct clustercmd_reg clustercmd_reg_t;
151 struct clustercmd_ack {
154 typedef struct clustercmd_ack clustercmd_ack_t;
160 typedef enum reject_reason reject_reason_t;
162 struct clustercmd_rej {
166 typedef struct clustercmd_rej clustercmd_rej_t;
168 __extension__
struct clustercmd_ht_exch {
173 typedef struct clustercmd_ht_exch clustercmd_ht_exch_t;
175 struct clustercmdadler32 {
179 typedef struct clustercmdadler32 clustercmdadler32_t;
181 struct clustercmdhdr {
186 clustercmdadler32_t adler32;
191 typedef struct clustercmdhdr clustercmdhdr_t;
193 typedef 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;
208 typedef struct clustercmd clustercmd_t;
210 struct clustercmdqueuedpackethdri {
213 typedef struct clustercmdqueuedpackethdri clustercmdqueuedpackethdri_t;
215 struct clustercmdqueuedpackethdro {
219 typedef struct clustercmdqueuedpackethdro clustercmdqueuedpackethdro_t;
221 struct clustercmdqueuedpackethdr {
222 unsigned int window_id;
224 clustercmdqueuedpackethdri_t i;
225 clustercmdqueuedpackethdro_t o;
228 typedef struct clustercmdqueuedpackethdr clustercmdqueuedpackethdr_t;
230 struct clustercmdqueuedpacket {
231 clustercmdqueuedpackethdr_t h;
234 typedef struct clustercmdqueuedpacket clustercmdqueuedpacket_t;
236 struct window_occupied_sides {
240 typedef 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;
250 typedef struct window window_t;
252 typedef int ( *cluster_recvproc_funct_t ) ( clustercmd_t *clustercmd_p );
256 extern int cluster_init (
struct ctx *
ctx_p,
struct indexes *indexes_p );
257 extern int cluster_deinit();
259 extern int cluster_lock (
const char *fpath );
260 extern int cluster_lock_byindexes();
261 extern int cluster_unlock_all();
262 extern int cluster_capture (
const char *fpath );
264 extern int cluster_modtime_update (
const char *dirpath,
short int dirlevel, mode_t st_mode );
265 extern int cluster_initialsync();