| 1 | /* |
| 2 | * xdr_config.c |
| 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 | /* |
| 24 | * Configuration file-related routines shared between the server and XDR. |
| 25 | */ |
| 26 | |
| 27 | #include <string.h> |
| 28 | |
| 29 | #include "citrusleaf/alloc.h" |
| 30 | |
| 31 | #include "fault.h" |
| 32 | |
| 33 | #include "base/xdr_config.h" |
| 34 | |
| 35 | void |
| 36 | xdr_config_defaults() |
| 37 | { |
| 38 | xdr_config *c = &g_xcfg; |
| 39 | memset(c, 0, sizeof(xdr_config)); |
| 40 | |
| 41 | c->xdr_section_configured = false; // Indicates if XDR is configured or not |
| 42 | c->xdr_global_enabled = false; // This config option overrides the enable-xdr setting of the namespace(s) |
| 43 | c->xdr_enable_change_notification = false; // Static config which spawns http machinery and also checks feature key |
| 44 | c->xdr_digestlog_path = NULL; // Path where the digest information is written to the disk |
| 45 | c->xdr_info_port = 0; |
| 46 | c->xdr_max_ship_throughput = 0; // XDR TPS limit |
| 47 | c->xdr_max_ship_bandwidth = 0; // XDR bandwidth limit |
| 48 | c->xdr_min_dlog_free_pct = 0; // Namespace writes are stopped below this limit |
| 49 | c->xdr_hotkey_time_ms = 100; // Expiration time for the de-duplication cache |
| 50 | c->xdr_read_threads = 4; // Number of XDR read threads. |
| 51 | c->xdr_write_timeout = 10000; // Timeout for each element that is shipped. |
| 52 | c->xdr_client_threads = 3; // Number of async client threads (event loops) |
| 53 | c->xdr_forward_xdrwrites = false; // If the writes due to xdr should be forwarded |
| 54 | c->xdr_nsup_deletes_enabled = false;// Shall XDR ship deletes of evictions or expiration |
| 55 | c->xdr_internal_shipping_delay = 0; // Default sleep between shipping each batch is 0 seconds |
| 56 | c->xdr_conf_change_flag = false; |
| 57 | c->xdr_shipping_enabled = true; |
| 58 | c->xdr_delete_shipping_enabled = true; |
| 59 | c->xdr_ship_bins = false; |
| 60 | c->xdr_info_request_timeout_ms = 10000; |
| 61 | c->xdr_compression_threshold = 0; // 0 disables compressed shipping, > 0 specifies minimum request size for compression |
| 62 | c->xdr_handle_failednode = true; |
| 63 | c->xdr_handle_linkdown = true; |
| 64 | c->xdr_digestlog_iowait_ms = 500; |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | xdr_config_dest_defaults(xdr_dest_config *dest_cfg) |
| 69 | { |
| 70 | // Assume its aerospike dest type unless otherwise specified |
| 71 | dest_cfg->dc_type = XDR_CFG_DEST_AEROSPIKE; |
| 72 | |
| 73 | // Common |
| 74 | dest_cfg->dc_security_cfg.sec_config_file = NULL; |
| 75 | dest_cfg->dc_tls_spec_name = NULL; |
| 76 | dest_cfg->dc_tls_spec = NULL; |
| 77 | dest_cfg->dc_ship_bins = true; |
| 78 | |
| 79 | // Aerospike destination |
| 80 | cf_vector_pointer_init(&dest_cfg->aero.dc_nodes, 10, 0); |
| 81 | xdr_dest_aero_config *aero_conf = &dest_cfg->aero; |
| 82 | aero_conf->dc_use_alternate_services = false; |
| 83 | aero_conf->dc_connections = 64; |
| 84 | aero_conf->dc_connections_idle_ms = 55000; |
| 85 | cf_vector_pointer_init(&aero_conf->dc_addr_map_v, 10, 0); |
| 86 | |
| 87 | // HTTP destination |
| 88 | xdr_dest_http_config *http_conf = &dest_cfg->http; |
| 89 | http_conf->verbose = false; |
| 90 | http_conf->version_str = cf_strdup(XDR_CFG_HTTP_VERSION_2); |
| 91 | cf_vector_init(&http_conf->urls, sizeof(void *), 10, 0); // pointer vector |
| 92 | } |
| 93 | |
| 94 | xdr_config g_xcfg = { 0 }; |
| 95 | xdr_dest_config g_dest_xcfg_opt[DC_MAX_NUM]; |
| 96 | int g_dc_count = 0; |
| 97 | |