hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cl_cluster.h
Go to the documentation of this file.
1 /*
2  * The Aerospike C interface. A good, basic library that many clients can be based on.
3  *
4  * This is the internal, non-public header file.
5  *
6  * this code currently assumes that the server is running in an ASCII-7 based
7  * (ie, utf8 or ISO-LATIN-1)
8  * character set, as values coming back from the server are UTF-8. We currently
9  * don't bother to convert to the character set of the machine we're running on
10  * but we advertise these values as 'strings'
11  *
12  * All rights reserved
13  * Brian Bulkowski, 2009
14  * CitrusLeaf
15  */
16 
17 #include "citrusleaf.h"
18 
19 
20 // do this both the new skool and old skool way which gives the highest correctness,
21 // speed, and compatibility
22 #pragma once
23 #ifndef __CL_C_H__
24 #define __CL_C_H__
25 
26 #define MAX_INTERVALS_ABSENT 1
27 
28 typedef struct cl_cluster_node_s {
29 
31 
32  // How many tend periods this node has been out of partitions map.
33  uint32_t intervals_absent;
34 
35  // A vector of sockaddr_in which the host is currently known by
37 
38  // the server's generation count for all its partition management
40 
41  // pool of current, cached FDs
43  cf_queue *conn_q_asyncfd; // FDs for async command execution
44 
45  int asyncfd;
47 
49 
50 typedef struct cl_partition_s {
51  // Mutex to cover master/prole transitions for this partition.
52  pthread_mutex_t lock;
53 
54  // Which node, if any, is the master.
56 
57  // Which node, if any, is the prole.
58  // TODO - not ideal for replication factor > 2.
60 } cl_partition;
61 
62 typedef struct cl_partition_table_s {
63 
65 
66  char ns[33]; // the namespace name
67 
69 
71 
72 //Structure to hold information about compression.
74  int compression_threshold; // Minimum size of packet, to be compressed. 0 = No cpmpression.
75  uint64_t actual_sz; // Accumulative count. Actual size of data, compressed till now.
76  uint64_t compressed_sz; // Accumulative count. Size of data after compression.
77 };
78 
79 struct cl_cluster_s {
80  // Linked list element should be first element in the structure
82 
83  uint32_t state; //bitmap representing state information
84 
85  bool follow; // possible to create a no-follow cluster
86  bool nbconnect;
87  // mostly for testing
88  // that only targets specific nodes
89 
90  volatile bool found_all; // have, at some time, found all cluster memebers
91 
92  // List of host-strings added by the user.
93  cf_vector host_str_v; // vector is pointer-type
94  cf_vector host_port_v; // vector is integer-type
95 
96  cf_vector host_addr_map_v; //Mapping from host string to its alternate
97 
98  // list actual node objects that represent the cluster
99  uint32_t last_node;
100  cf_vector node_v; // vector is pointer-type, host objects are ref-counted
101 
102  // information about where all the partitions are
105 
107 
108  uint32_t ref_count;
109  uint32_t tend_speed;
110  int info_timeout; // timeout in ms for info requests
111  // Need a lock
112  pthread_mutex_t LOCK;
113 
114 };
115 
116 #define CLS_TENDER_RUNNING 0x00000001
117 #define CLS_FREED 0x00000002
118 #define CLS_UNUSED1 0x00000004
119 #define CLS_UNUSED2 0x00000008
120 #define CLS_UNUSED3 0x00000010
121 
122 extern cf_ll cluster_ll;
123 // Cluster calls
124 extern cl_cluster_node *cl_cluster_node_get_random(cl_cluster *asc); // get node from cluster
125 extern cl_cluster_node *cl_cluster_node_get(cl_cluster *asc, const char *ns, const cf_digest *d, bool write); // get node from cluster
126 extern void cl_cluster_node_release(cl_cluster_node *cn, const char *tag);
127 extern void cl_cluster_node_reserve(cl_cluster_node *cn, const char *tag);
128 extern void cl_cluster_node_put(cl_cluster_node *cn); // put node back
129 extern int cl_cluster_node_fd_get(cl_cluster_node *cn, bool asyncfd, bool nbconnect); // get an FD to the node
130 extern void cl_cluster_node_fd_put(cl_cluster_node *cn, int fd, bool asyncfd); // put the FD back
131 extern int citrusleaf_cluster_init();
133 
134 // must free node_names when done
135 extern int cl_cluster_get_node_names_byhostportlist(cl_cluster *asc, char *list_nodes, int *n_nodes, char **node_names);
136 
137 //
138 extern int citrusleaf_info_parse_single(char *values, char **value);
139 
140 // Partition table calls
141 // --- all these assume the partition lock is held
144 extern void cl_partition_table_update(cl_cluster* asc, cl_cluster_node* node, const char* ns, bool* masters, bool* proles);
145 extern cl_cluster_node* cl_partition_table_get(cl_cluster* asc, const char* ns, cl_partition_id pid, bool write);
146 
147 #endif
148 
149 #ifdef __cplusplus
150 } // end extern "C"
151 #endif
152 
153