Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef QE_OPTIONS_H_ 7 : #define QE_OPTIONS_H_ 8 : 9 : #include <boost/program_options.hpp> 10 : #include "io/event_manager.h" 11 : #include "sandesh/sandesh.h" 12 : 13 : #define ANALYTICS_DATA_TTL_DEFAULT 48 // g_viz_constants.AnalyticsTTL 14 : 15 : // Process command line/configuration file options for collector. 16 : class Options { 17 : public: 18 : Options(); 19 : bool Parse(EventManager &evm, int argc, char **argv); 20 : 21 78 : const std::vector<std::string> cassandra_server_list() const { 22 78 : return cassandra_server_list_; 23 : } 24 71 : const std::vector<std::string> collector_server_list() const { 25 71 : return collector_server_list_; 26 : } 27 0 : const std::vector<std::string> default_collector_server_list() const { 28 0 : return default_collector_server_list_; 29 : } 30 44 : std::vector<std::string> randomized_collector_server_list() const { 31 44 : return randomized_collector_server_list_; 32 : } 33 44 : const bool collectors_configured() const { 34 44 : return collector_server_list_.size() > 0; 35 : } 36 22 : const std::vector<std::string> config_file() const { 37 22 : return config_file_; 38 : } 39 76 : const std::vector<std::string> redis_server_list() const { 40 76 : return redis_server_list_; 41 : } 42 : 43 : const std::string redis_server() const { return redis_server_; } 44 6 : const uint16_t redis_port() const { return redis_port_; } 45 47 : const std::string redis_password() const { return redis_password_; } 46 47 : const bool redis_ssl_enable() const { return redis_ssl_enable_; } 47 45 : const std::string redis_keyfile() const { return redis_keyfile_; } 48 45 : const std::string redis_certfile() const { return redis_certfile_; } 49 45 : const std::string redis_ca_cert() const { return redis_ca_cert_; } 50 94 : const std::string hostname() const { return hostname_; } 51 50 : const std::string host_ip() const { return host_ip_; } 52 94 : const uint16_t http_server_port() const { return http_server_port_; } 53 6 : const uint64_t start_time() const { return start_time_; } 54 50 : const int max_tasks() const { return max_tasks_; } 55 94 : const int max_slice() const { return max_slice_; } 56 50 : const std::string log_category() const { return log_category_; } 57 44 : const std::string log_property_file() const { return log_property_file_; } 58 50 : const bool log_disable() const { return log_disable_; } 59 50 : const std::string log_file() const { return log_file_; } 60 50 : const int log_files_count() const { return log_files_count_; } 61 50 : const long log_file_size() const { return log_file_size_; } 62 94 : const std::string log_level() const { return log_level_; } 63 50 : const bool log_local() const { return log_local_; } 64 44 : const bool use_syslog() const { return use_syslog_; } 65 44 : const std::string syslog_facility() const { return syslog_facility_; } 66 6 : const int analytics_data_ttl() const { return analytics_data_ttl_; } 67 6 : const bool test_mode() const { return test_mode_; } 68 25 : const std::string cluster_id() const { return cluster_id_; } 69 46 : const std::string cassandra_user() const { return cassandra_user_; } 70 46 : const std::string cassandra_password() const { return cassandra_password_; } 71 50 : const bool cassandra_use_ssl() const { return cassandra_use_ssl_; } 72 46 : const std::string cassandra_ca_certs() const { return cassandra_ca_certs_; } 73 54 : const SandeshConfig &sandesh_config() const { return sandesh_config_; } 74 : 75 : void ParseReConfig(); 76 : 77 : private: 78 : 79 : void Process(int argc, char *argv[], 80 : boost::program_options::options_description &cmdline_options); 81 : void Initialize(EventManager &evm, 82 : boost::program_options::options_description &options); 83 : uint32_t GenerateHash(std::vector<std::string> &); 84 : 85 : std::vector<std::string> config_file_; 86 : std::vector<std::string> redis_server_list_; 87 : std::string redis_server_; 88 : uint16_t redis_port_; 89 : std::string redis_password_; 90 : bool redis_ssl_enable_; 91 : std::string redis_keyfile_; 92 : std::string redis_certfile_; 93 : std::string redis_ca_cert_; 94 : std::string hostname_; 95 : std::string host_ip_; 96 : uint16_t http_server_port_; 97 : std::string log_category_; 98 : std::string log_property_file_; 99 : bool log_disable_; 100 : std::string log_file_; 101 : int log_files_count_; 102 : long log_file_size_; 103 : std::string log_level_; 104 : bool log_local_; 105 : bool use_syslog_; 106 : std::string syslog_facility_; 107 : uint64_t start_time_; 108 : int max_tasks_; 109 : int max_slice_; 110 : bool test_mode_; 111 : int analytics_data_ttl_; 112 : uint32_t send_ratelimit_; 113 : std::vector<std::string> cassandra_server_list_; 114 : std::vector<std::string> collector_server_list_; 115 : std::vector<std::string> randomized_collector_server_list_; 116 : uint32_t collector_chksum_; 117 : std::vector<std::string> default_collector_server_list_; 118 : SandeshConfig sandesh_config_; 119 : 120 : boost::program_options::options_description config_file_options_; 121 : std::string cluster_id_; 122 : std::string cassandra_user_; 123 : std::string cassandra_password_; 124 : bool cassandra_use_ssl_; 125 : std::string cassandra_ca_certs_; 126 : }; 127 : 128 : #endif /* QE_OPTIONS_H_ */