Commit d00bb873 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Get DB Connection timeout from Conf file

parent c0a29766
......@@ -9,36 +9,37 @@ UDR =
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if UDR will relying on a DNS to resolve UDM's FQDN
REGISTER_NRF = "@REGISTER_NRF@"; # Set to yes if UDR resgisters to an NRF
USE_HTTP2 = "@USE_HTTP2@"; # Set to yes to enable HTTP2 for UDR server
DATABASE = "MySQL"; # Set to 'MySQL'/'Cassandra' to use MySQL/Cass, enable HTTP2 for UDR server
}
DATABASE = "MySQL"; # Set to 'MySQL'/'Cassandra' to use MySQL/Cassandra
};
INTERFACES:
{
# NUDR Interface (SBI)
NUDR:
{
INTERFACE_NAME = "@UDR_INTERFACE_NAME_FOR_NUDR@"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "@UDR_INTERFACE_NAME_FOR_NUDR@";
IPV4_ADDRESS = "read";
PORT = @UDR_INTERFACE_PORT_FOR_NUDR@; # YOUR NETWORK CONFIG HERE
HTTP2_PORT = @UDR_INTERFACE_HTTP2_PORT_FOR_NUDR@; # YOUR NETWORK CONFIG HERE
API_VERSION = "@UDR_API_VERSION@"; # YOUR NUDR API VERSION CONFIG HERE
PORT = @UDR_INTERFACE_PORT_FOR_NUDR@; # Default value: 80
HTTP2_PORT = @UDR_INTERFACE_HTTP2_PORT_FOR_NUDR@;
API_VERSION = "@UDR_API_VERSION@";
};
};
NRF:
{
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION HERE
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@";
PORT = @NRF_PORT@; # Default value: 80
API_VERSION = "@NRF_API_VERSION@";
FQDN = "@NRF_FQDN@";
};
MYSQL:
{
# MySQL options
MYSQL_SERVER = "@MYSQL_IPV4_ADDRESS@"; # YOUR MYSQL DB ADDRESS HERE
MYSQL_USER = "@MYSQL_USER@"; # YOUR MYSQL USER HERE
MYSQL_PASS = "@MYSQL_PASS@"; # YOUR MYSQL PASSWORD HERE
MYSQL_DB = "@MYSQL_DB@"; # YOUR DATA BASE NAME HERE
MYSQL_SERVER = "@MYSQL_IPV4_ADDRESS@";
MYSQL_USER = "@MYSQL_USER@";
MYSQL_PASS = "@MYSQL_PASS@";
MYSQL_DB = "@MYSQL_DB@";
DB_CONNECTION_TIMEOUT = 10; # Reset the connection to the DB after expiring the timeout (in second)
};
};
......@@ -4,8 +4,8 @@
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -27,7 +27,6 @@
#define HEART_BEAT_TIMER 10
#define DB_CONNECTION_TIMER 1800 // 30 minutes
#define MAX_FIRST_CONNECTION_RETRY 100
#define MAX_CONNECTION_RETRY 1
......
......@@ -110,8 +110,8 @@ void mysql_db::start_event_connection_handling() {
std::chrono::system_clock::now().time_since_epoch())
.count();
struct itimerspec its;
its.it_value.tv_sec = DB_CONNECTION_TIMER; // seconds
its.it_value.tv_nsec = 0; // 100 * 1000 * 1000; //100ms
its.it_value.tv_sec = udr_cfg.mysql.connection_timeout; // seconds
its.it_value.tv_nsec = 0; // 100 * 1000 * 1000; //100ms
const uint64_t interval =
its.it_value.tv_sec * 1000 +
its.it_value.tv_nsec / 1000000; // convert sec, nsec to msec
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
* Licensed to the OpenAirInterface (OAI) Software Alliance mysql_conf_tunder
*one or more contributor license agreements. See the NOTICE file distributed
*with this work for additional information regarding copyright ownership. The
*OpenAirInterface Software Alliance licenses this file to You under the OAI
*Public License, Version 1.1 (the "License"); you may not use this file except
*in compliance with the License. You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -223,6 +222,9 @@ int udr_config::load(const std ::string& config_file) {
mysql_cfg.lookupValue(UDR_CONFIG_STRING_MYSQL_USER, mysql.mysql_user);
mysql_cfg.lookupValue(UDR_CONFIG_STRING_MYSQL_PASS, mysql.mysql_pass);
mysql_cfg.lookupValue(UDR_CONFIG_STRING_MYSQL_DB, mysql.mysql_db);
mysql_cfg.lookupValue(
UDR_CONFIG_STRING_MYSQL_DB_CONNECTION_TIMEOUT,
mysql.connection_timeout);
} catch (const SettingNotFoundException& nfex) {
Logger::udr_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
......@@ -336,6 +338,8 @@ void udr_config::display() {
" Password ..............: %s", mysql.mysql_pass.c_str());
Logger::config().info(
" Database ..............: %s", mysql.mysql_db.c_str());
Logger::config().info(
" DB Timeout ............: %d (seconds)", mysql.connection_timeout);
} else if (db_type == DB_TYPE_CASSANDRA) {
Logger::config().info("- Cassandra:");
Logger::config().info(
......
......@@ -58,6 +58,7 @@
#define UDR_CONFIG_STRING_MYSQL_USER "MYSQL_USER"
#define UDR_CONFIG_STRING_MYSQL_PASS "MYSQL_PASS"
#define UDR_CONFIG_STRING_MYSQL_DB "MYSQL_DB"
#define UDR_CONFIG_STRING_MYSQL_DB_CONNECTION_TIMEOUT "DB_CONNECTION_TIMEOUT"
using namespace libconfig;
......@@ -68,6 +69,7 @@ typedef struct {
std::string mysql_user;
std::string mysql_pass;
std::string mysql_db;
uint32_t connection_timeout;
} mysql_conf_t;
typedef struct interface_cfg_s {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment