1 | /* |
2 | * xdr_config.h |
3 | * |
4 | * Copyright (C) 2011-2016 Aerospike, Inc. |
5 | * |
6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
7 | * license agreements. |
8 | * |
9 | * This program is free software: you can redistribute it and/or modify it under |
10 | * the terms of the GNU Affero General Public License as published by the Free |
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
12 | * later version. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
17 | * details. |
18 | * |
19 | * You should have received a copy of the GNU Affero General Public License |
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
21 | */ |
22 | |
23 | #pragma once |
24 | |
25 | //========================================================== |
26 | // Includes. |
27 | // |
28 | |
29 | #include "citrusleaf/cf_vector.h" |
30 | |
31 | #include "node.h" |
32 | #include "tls.h" |
33 | |
34 | //========================================================== |
35 | // Forward declarations. |
36 | // |
37 | |
38 | //========================================================== |
39 | // Constants & typedefs. |
40 | // |
41 | |
42 | // Length definitions. This should be in sync with the server definitions. |
43 | // It is bad that we are not using a common header file for all this. |
44 | #define CLUSTER_MAX_SZ 128 |
45 | #define NAMESPACE_MAX_NUM 32 |
46 | #define DC_MAX_NUM 32 |
47 | |
48 | #define XDR_MAX_CLIENT_THREADS 64 |
49 | |
50 | #define XDR_CFG_DEST_AEROSPIKE "aerospike" |
51 | #define XDR_CFG_DEST_HTTP "http" |
52 | |
53 | #define XDR_CFG_HTTP_VERSION_1 "v1" |
54 | #define XDR_CFG_HTTP_VERSION_2 "v2" |
55 | #define XDR_CFG_HTTP_VERSION_2_PRIOR_KNOWLEDGE "v2-prior-knowledge" |
56 | |
57 | typedef struct xdr_node_lst_s { |
58 | cf_node node; |
59 | uint64_t time[DC_MAX_NUM]; |
60 | } xdr_node_lst; |
61 | |
62 | typedef struct node_addr_port_s { |
63 | char *addr; |
64 | char *tls_name; |
65 | int port; |
66 | } node_addr_port; |
67 | |
68 | // Config option in case the configuration value is changed |
69 | typedef struct xdr_new_config_s { |
70 | bool skip_outstanding; |
71 | } xdr_new_config; |
72 | |
73 | // Config option which is maintained both by the server and the XDR module |
74 | typedef struct xdr_config_s { |
75 | |
76 | bool xdr_section_configured; |
77 | bool xdr_global_enabled; |
78 | bool xdr_enable_change_notification; |
79 | |
80 | // Ring buffer configuration |
81 | char *xdr_digestlog_path; |
82 | uint64_t xdr_digestlog_file_size; |
83 | |
84 | uint32_t xdr_info_port; |
85 | uint32_t xdr_max_ship_throughput; |
86 | uint32_t xdr_max_ship_bandwidth; |
87 | uint32_t xdr_min_dlog_free_pct; |
88 | uint32_t xdr_hotkey_time_ms; |
89 | uint32_t xdr_read_threads; |
90 | uint32_t xdr_write_timeout; |
91 | uint32_t xdr_client_threads; |
92 | uint32_t xdr_forward_xdrwrites; |
93 | uint32_t xdr_internal_shipping_delay; |
94 | uint32_t xdr_info_request_timeout_ms; |
95 | uint32_t xdr_compression_threshold; |
96 | uint32_t xdr_digestlog_iowait_ms; |
97 | |
98 | bool xdr_shipping_enabled; |
99 | bool xdr_delete_shipping_enabled; |
100 | bool xdr_nsup_deletes_enabled; |
101 | bool xdr_ship_bins; |
102 | bool xdr_handle_failednode; |
103 | bool xdr_handle_linkdown; |
104 | |
105 | // Internal |
106 | bool xdr_conf_change_flag; |
107 | xdr_new_config xdr_new_cfg; |
108 | } xdr_config; |
109 | |
110 | typedef struct xdr_security_config_s { |
111 | char *sec_config_file; |
112 | char *username; |
113 | char *password; |
114 | } xdr_security_config; |
115 | |
116 | typedef enum { |
117 | XDR_AUTH_MODE_INTERNAL, |
118 | XDR_AUTH_MODE_EXTERNAL, |
119 | XDR_AUTH_MODE_EXTERNAL_INSECURE |
120 | } xdr_dest_aero_auth_mode; |
121 | |
122 | typedef struct xdr_dest_aero_config_s { |
123 | cf_vector dc_nodes; |
124 | cf_vector dc_addr_map_v; |
125 | uint32_t dc_connections; |
126 | uint32_t dc_connections_idle_ms; |
127 | bool dc_use_alternate_services; |
128 | xdr_dest_aero_auth_mode auth_mode; |
129 | } xdr_dest_aero_config; |
130 | |
131 | typedef struct xdr_dest_http_config_s { |
132 | cf_vector urls; |
133 | char *version_str; |
134 | bool verbose; |
135 | } xdr_dest_http_config; |
136 | |
137 | typedef struct xdr_dest_config_s { |
138 | char *dc_type; |
139 | char *name; |
140 | int id; |
141 | char *dc_tls_spec_name; |
142 | cf_tls_spec *dc_tls_spec; |
143 | bool dc_ship_bins; |
144 | xdr_security_config dc_security_cfg; |
145 | |
146 | struct xdr_dest_aero_config_s aero; |
147 | struct xdr_dest_http_config_s http; |
148 | } xdr_dest_config; |
149 | |
150 | //========================================================== |
151 | // Public API. |
152 | // |
153 | |
154 | void xdr_config_defaults(); |
155 | void xdr_config_dest_defaults(xdr_dest_config *dest_conf); |
156 | bool xdr_read_security_configfile(xdr_security_config* sc); |
157 | |
158 | extern xdr_config g_xcfg; |
159 | extern int g_dc_count; |
160 | extern xdr_dest_config g_dest_xcfg_opt[DC_MAX_NUM]; |
161 | |