5 #include "getpot/GetPot" 15 #define CONF_ENTRY_INTEGER(name, section, string) 22 #define CONF_DERECHO_LEADER_IP "DERECHO/leader_ip" 23 #define CONF_DERECHO_LEADER_GMS_PORT "DERECHO/leader_gms_port" 24 #define CONF_DERECHO_LOCAL_ID "DERECHO/local_id" 25 #define CONF_DERECHO_LOCAL_IP "DERECHO/local_ip" 26 #define CONF_DERECHO_GMS_PORT "DERECHO/gms_port" 27 #define CONF_DERECHO_RPC_PORT "DERECHO/rpc_port" 28 #define CONF_DERECHO_SST_PORT "DERECHO/sst_port" 29 #define CONF_DERECHO_RDMC_PORT "DERECHO/rdmc_port" 30 #define CONF_DERECHO_HEARTBEAT_MS "DERECHO/heartbeat_ms" 31 #define CONF_DERECHO_SST_POLL_CQ_TIMEOUT_MS "DERECHO/sst_poll_cq_timeout_ms" 32 #define CONF_DERECHO_DISABLE_PARTITIONING_SAFETY "DERECHO/disable_partitioning_safety" 34 #define CONF_DERECHO_MAX_P2P_REQUEST_PAYLOAD_SIZE "DERECHO/max_p2p_request_payload_size" 35 #define CONF_DERECHO_MAX_P2P_REPLY_PAYLOAD_SIZE "DERECHO/max_p2p_reply_payload_size" 36 #define CONF_DERECHO_P2P_WINDOW_SIZE "DERECHO/p2p_window_size" 38 #define CONF_SUBGROUP_DEFAULT_MAX_PAYLOAD_SIZE "SUBGROUP/DEFAULT/max_payload_size" 39 #define CONF_SUBGROUP_DEFAULT_MAX_REPLY_PAYLOAD_SIZE "SUBGROUP/DEFAULT/max_reply_payload_size" 40 #define CONF_SUBGROUP_DEFAULT_MAX_SMC_PAYLOAD_SIZE "SUBGROUP/DEFAULT/max_smc_payload_size" 41 #define CONF_SUBGROUP_DEFAULT_BLOCK_SIZE "SUBGROUP/DEFAULT/block_size" 42 #define CONF_SUBGROUP_DEFAULT_WINDOW_SIZE "SUBGROUP/DEFAULT/window_size" 43 #define CONF_SUBGROUP_DEFAULT_RDMC_SEND_ALGORITHM "SUBGROUP/DEFAULT/rdmc_send_algorithm" 45 #define CONF_RDMA_PROVIDER "RDMA/provider" 46 #define CONF_RDMA_DOMAIN "RDMA/domain" 47 #define CONF_RDMA_TX_DEPTH "RDMA/tx_depth" 48 #define CONF_RDMA_RX_DEPTH "RDMA/rx_depth" 49 #define CONF_PERS_FILE_PATH "PERS/file_path" 50 #define CONF_PERS_RAMDISK_PATH "PERS/ramdisk_path" 51 #define CONF_PERS_RESET "PERS/reset" 52 #define CONF_PERS_MAX_LOG_ENTRY "PERS/max_log_entry" 53 #define CONF_PERS_MAX_DATA_SIZE "PERS/max_data_size" 54 #define CONF_LOGGER_DEFAULT_LOG_NAME "LOGGER/default_log_name" 55 #define CONF_LOGGER_DEFAULT_LOG_LEVEL "LOGGER/default_log_level" 57 std::map<const std::string, std::string>
config = {
108 if(getpotcfg !=
nullptr) {
109 for(
const std::string& key : getpotcfg->get_variable_names()) {
110 this->config[key] = (*getpotcfg)(key,
"");
116 int option_index = 0;
118 c = getopt_long(argc, argv,
"",
long_options, &option_index);
132 std::cerr <<
"ignore unknown commandline code:" << c << std::endl;
137 const std::string&
getString(
const std::string& key)
const {
138 return this->config.at(key);
140 const int16_t
getInt16(
const std::string& key)
const {
141 return (
const int16_t)std::stoi(this->config.at(key));
143 const uint16_t
getUInt16(
const std::string& key)
const {
144 return (
const uint16_t)std::stoi(this->config.at(key));
146 const int32_t
getInt32(
const std::string& key)
const {
147 return (
const int32_t)std::stoi(this->config.at(key));
149 const uint32_t
getUInt32(
const std::string& key)
const {
150 return (
const uint32_t)std::stoi(this->config.at(key));
152 const int64_t
getInt64(
const std::string& key)
const {
153 return (
const int64_t)std::stoll(this->config.at(key));
155 const uint64_t
getUInt64(
const std::string& key)
const {
156 return (
const uint64_t)std::stoll(this->config.at(key));
158 const float getFloat(
const std::string& key)
const {
159 return (
const float)std::stof(this->config.at(key));
162 return (
const float)std::stod(this->config.at(key));
165 return (this->config.at(key) ==
"true") || (this->config.at(key) ==
"yes") || (this->config.at(key) ==
"1");
170 return (this->config.find(key) != this->config.end());
182 const char* conf_file =
nullptr);
183 static const Conf*
get() noexcept;
#define CONF_SUBGROUP_DEFAULT_MAX_SMC_PAYLOAD_SIZE
#define CONF_SUBGROUP_DEFAULT_MAX_PAYLOAD_SIZE
const uint16_t getUInt16(const std::string &key) const
const uint16_t getConfUInt16(const std::string &key)
#define CONF_SUBGROUP_DEFAULT_RDMC_SEND_ALGORITHM
const int32_t getInt32(const std::string &key) const
static const std::vector< std::string > subgroupProfileFields
const std::string & getConfString(const std::string &key)
const bool hasCustomizedKey(const std::string &key) const
#define CONF_PERS_MAX_DATA_SIZE
const int32_t getConfInt32(const std::string &key)
static struct option long_options[]
#define CONF_DERECHO_MAX_P2P_REPLY_PAYLOAD_SIZE
const int16_t getConfInt16(const std::string &key)
const float getFloat(const std::string &key) const
const uint32_t getConfUInt32(const std::string &key)
#define CONF_SUBGROUP_DEFAULT_MAX_REPLY_PAYLOAD_SIZE
#define CONF_SUBGROUP_DEFAULT_WINDOW_SIZE
#define CONF_DERECHO_SST_POLL_CQ_TIMEOUT_MS
#define CONF_DERECHO_SST_PORT
#define CONF_RDMA_PROVIDER
static void initialize(int argc, char *argv[], const char *conf_file=nullptr)
const uint32_t getUInt32(const std::string &key) const
#define CONF_DERECHO_DISABLE_PARTITIONING_SAFETY
#define CONF_DERECHO_LEADER_GMS_PORT
const bool getBoolean(const std::string &key) const
const int64_t getInt64(const std::string &key) const
const uint64_t getUInt64(const std::string &key) const
#define CONF_RDMA_RX_DEPTH
#define CONF_DERECHO_LOCAL_IP
#define CONF_DERECHO_HEARTBEAT_MS
const int16_t getInt16(const std::string &key) const
#define CONF_DERECHO_RPC_PORT
#define CONF_DERECHO_P2P_WINDOW_SIZE
const int64_t getConfInt64(const std::string &key)
static std::atomic< uint32_t > singleton_initialized_flag
#define CONF_DERECHO_GMS_PORT
The single configuration file for derecho.
#define CONF_DERECHO_MAX_P2P_REQUEST_PAYLOAD_SIZE
#define CONF_RDMA_TX_DEPTH
const bool getConfBoolean(const std::string &key)
#define CONF_SUBGROUP_DEFAULT_BLOCK_SIZE
#define CONF_DERECHO_RDMC_PORT
#define CONF_LOGGER_DEFAULT_LOG_LEVEL
std::map< const std::string, std::string > config
#define CONF_PERS_MAX_LOG_ENTRY
#define CONF_DERECHO_LOCAL_ID
#define CONF_LOGGER_DEFAULT_LOG_NAME
#define CONF_PERS_RAMDISK_PATH
Conf(int argc, char *argv[], GetPot *getpotcfg=nullptr) noexcept
Constructor: Conf can read configure from multiple sources.
static std::unique_ptr< Conf > singleton
const double getDouble(const std::string &key) const
const float getConfFloat(const std::string &key)
const double getConfDouble(const std::string &key)
#define CONF_PERS_FILE_PATH
#define CONF_DERECHO_LEADER_IP
const uint64_t getConfUInt64(const std::string &key)
const bool hasCustomizedConfKey(const std::string &key)
const std::string & getString(const std::string &key) const
get configuration