CUBRID Engine  latest
broker_config.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include "porting.h"
#include "cas_common.h"
#include "broker_config.h"
#include "broker_shm.h"
#include "broker_filename.h"
#include "broker_util.h"
#include "cas_sql_log2.h"
#include "shard_shm.h"
#include "shard_metadata.h"
#include "util_func.h"
#include "ini_parser.h"

Go to the source code of this file.

Classes

struct  t_conf_table
 

Macros

#define DEFAULT_ADMIN_LOG_FILE   "log/broker/cubrid_broker.log"
 
#define DEFAULT_SESSION_TIMEOUT   "5min"
 
#define DEFAULT_MAX_QUERY_TIMEOUT   "0"
 
#define DEFAULT_MYSQL_READ_TIMEOUT   "0"
 
#define DEFAULT_MYSQL_KEEPALIVE_INTERVAL   "1800" /* 30m */
 
#define DEFAULT_JOB_QUEUE_SIZE   1024
 
#define DEFAULT_APPL_SERVER   "CAS"
 
#define DEFAULT_EMPTY_STRING   "\0"
 
#define DEFAULT_FILE_UPLOAD_DELIMITER   "^^"
 
#define DEFAULT_SQL_LOG_MODE   "ALL"
 
#define DEFAULT_KEEP_CONNECTION   "AUTO"
 
#define DEFAULT_JDBC_CACHE_LIFE_TIME   1000
 
#define DEFAULT_PROXY_MAX_PREPARED_STMT_COUNT   10000
 
#define DEFAULT_CAS_MAX_PREPARED_STMT_COUNT   2000
 
#define DEFAULT_MONITOR_HANG_INTERVAL   60
 
#define DEFAULT_HANG_TIMEOUT   60
 
#define DEFAULT_RECONNECT_TIME   "600s"
 
#define DEFAULT_SHARD_PROXY_LOG_MODE   "ERROR"
 
#define DEFAULT_SHARD_KEY_MODULAR   256
 
#define DEFAULT_SHARD_PROXY_TIMEOUT   "30s"
 
#define DEFAULT_SHARD_PROXY_CONN_WAIT_TIMEOUT   "8h"
 
#define PORT_NUM_LIMIT   (USHRT_MAX) /* 65535 */
 
#define TRUE   1
 
#define FALSE   0
 
#define MAX_NUM_OF_CONF_FILE_LOADED   5
 
#define PRINTERROR(...)
 

Typedefs

typedef struct t_conf_table T_CONF_TABLE
 

Enumerations

enum  {
  PARAM_NO_ERROR = 0, PARAM_INVAL_SEC = 1, PARAM_BAD_VALUE = 2, PARAM_BAD_RANGE = 3,
  SECTION_NAME_TOO_LONG = 4
}
 

Functions

static void conf_file_has_been_loaded (const char *conf_path)
 
static int check_port_number (T_BROKER_INFO *br_info, int num_brs)
 
static int get_conf_value (const char *string, T_CONF_TABLE *conf_table)
 
static const char * get_conf_string (int value, T_CONF_TABLE *conf_table)
 
void dir_repath (char *path, size_t path_len)
 
static int broker_config_read_internal (const char *conf_file, T_BROKER_INFO *br_info, int *num_broker, int *br_shm_id, char *admin_log_file, char admin_flag, bool *acl_flag, char *acl_file, char *admin_err_msg)
 
int broker_config_read (const char *conf_file, T_BROKER_INFO *br_info, int *num_broker, int *br_shm_id, char *admin_log_file, char admin_flag, bool *acl_flag, char *acl_file, char *admin_err_msg)
 
void broker_config_dump (FILE *fp, const T_BROKER_INFO *br_info, int num_broker, int br_shm_id)
 
int conf_get_value_table_on_off (const char *value)
 
int conf_get_value_sql_log_mode (const char *value)
 
int conf_get_value_keep_con (const char *value)
 
int conf_get_value_access_mode (const char *value)
 
int conf_get_value_connect_order (const char *value)
 
int conf_get_value_proxy_log_mode (const char *value)
 

Variables

static T_CONF_TABLE tbl_appl_server []
 
static T_CONF_TABLE tbl_on_off []
 
static T_CONF_TABLE tbl_sql_log_mode []
 
static T_CONF_TABLE tbl_keep_connection []
 
static T_CONF_TABLE tbl_access_mode []
 
static T_CONF_TABLE tbl_connect_order []
 
static T_CONF_TABLE tbl_proxy_log_mode []
 
static const char SECTION_NAME [] = "broker"
 
static const char * tbl_conf_err_msg []
 
static char * conf_file_loaded [MAX_NUM_OF_CONF_FILE_LOADED]
 
const char * broker_keywords []
 
int broker_keywords_size = sizeof (broker_keywords) / sizeof (char *)
 

Macro Definition Documentation

#define DEFAULT_ADMIN_LOG_FILE   "log/broker/cubrid_broker.log"

Definition at line 56 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_APPL_SERVER   "CAS"

Definition at line 62 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_CAS_MAX_PREPARED_STMT_COUNT   2000

Definition at line 69 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_EMPTY_STRING   "\0"

Definition at line 63 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_FILE_UPLOAD_DELIMITER   "^^"

Definition at line 64 of file broker_config.c.

#define DEFAULT_HANG_TIMEOUT   60

Definition at line 71 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_JDBC_CACHE_LIFE_TIME   1000

Definition at line 67 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_JOB_QUEUE_SIZE   1024

Definition at line 61 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_KEEP_CONNECTION   "AUTO"

Definition at line 66 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_MAX_QUERY_TIMEOUT   "0"

Definition at line 58 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_MONITOR_HANG_INTERVAL   60

Definition at line 70 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_MYSQL_KEEPALIVE_INTERVAL   "1800" /* 30m */

Definition at line 60 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_MYSQL_READ_TIMEOUT   "0"

Definition at line 59 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_PROXY_MAX_PREPARED_STMT_COUNT   10000

Definition at line 68 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_RECONNECT_TIME   "600s"

Definition at line 72 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_SESSION_TIMEOUT   "5min"

Definition at line 57 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_SHARD_KEY_MODULAR   256

Definition at line 75 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_SHARD_PROXY_CONN_WAIT_TIMEOUT   "8h"

Definition at line 77 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_SHARD_PROXY_LOG_MODE   "ERROR"

Definition at line 74 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_SHARD_PROXY_TIMEOUT   "30s"

Definition at line 76 of file broker_config.c.

Referenced by broker_config_read_internal().

#define DEFAULT_SQL_LOG_MODE   "ALL"

Definition at line 65 of file broker_config.c.

Referenced by broker_config_read_internal().

#define FALSE   0

Definition at line 82 of file broker_config.c.

Referenced by broker_config_read_internal(), and check_port_number().

#define MAX_NUM_OF_CONF_FILE_LOADED   5

Definition at line 170 of file broker_config.c.

Referenced by broker_config_dump(), and conf_file_has_been_loaded().

#define PORT_NUM_LIMIT   (USHRT_MAX) /* 65535 */

Definition at line 79 of file broker_config.c.

Referenced by broker_config_read_internal().

#define PRINTERROR (   ...)
Value:
do {\
PRINT_AND_LOG_ERR_MSG(__VA_ARGS__); \
} \
while (0)
#define PRINT_AND_LOG_ERR_MSG(...)
Definition: util_func.h:49
while(1)
Definition: cnvlex.c:816

Referenced by broker_config_read_internal().

#define TRUE   1

Definition at line 81 of file broker_config.c.

Referenced by broker_config_read_internal(), and check_port_number().

Typedef Documentation

typedef struct t_conf_table T_CONF_TABLE

Definition at line 84 of file broker_config.c.

Enumeration Type Documentation

anonymous enum
Enumerator
PARAM_NO_ERROR 
PARAM_INVAL_SEC 
PARAM_BAD_VALUE 
PARAM_BAD_RANGE 
SECTION_NAME_TOO_LONG 

Definition at line 91 of file broker_config.c.

Function Documentation

void broker_config_dump ( FILE *  fp,
const T_BROKER_INFO br_info,
int  num_broker,
int  br_shm_id 
)
int broker_config_read ( const char *  conf_file,
T_BROKER_INFO br_info,
int *  num_broker,
int *  br_shm_id,
char *  admin_log_file,
char  admin_flag,
bool acl_flag,
char *  acl_file,
char *  admin_err_msg 
)

Definition at line 1228 of file broker_config.c.

References basename_r(), broker_config_read_internal(), BROKER_PATH_MAX, envvar_get(), err, FID_CUBRID_BROKER_CONF, get_cubrid_file(), MAX_BROKER_NUM, NULL, and PRINT_AND_LOG_ERR_MSG.

Referenced by admin_common(), and main().

Here is the caller graph for this function:

static int broker_config_read_internal ( const char *  conf_file,
T_BROKER_INFO br_info,
int *  num_broker,
int *  br_shm_id,
char *  admin_log_file,
char  admin_flag,
bool acl_flag,
char *  acl_file,
char *  admin_err_msg 
)
static

Definition at line 385 of file broker_config.c.

References t_broker_info::access_log, t_broker_info::access_log_max_size, t_broker_info::access_mode, t_broker_info::appl_server, t_broker_info::appl_server_hard_limit, t_broker_info::appl_server_max_num, t_broker_info::appl_server_max_size, t_broker_info::appl_server_min_num, t_broker_info::appl_server_num, APPL_SERVER_NUM_LIMIT, appl_server_shm_id, t_broker_info::appl_server_shm_id, t_broker_info::auto_add_appl_server, BROKER_INFO_PATH_MAX, broker_keywords, broker_keywords_size, BROKER_NAME_LEN, BROKER_PATH_MAX, t_broker_info::cache_user_info, t_broker_info::cas_rctime, t_broker_info::cci_default_autocommit, t_broker_info::cci_pconnect, check_port_number(), CLIENT_INFO_SIZE_LIMIT, conf_file_has_been_loaded(), conf_get_value_connect_order(), conf_get_value_keep_con(), conf_get_value_proxy_log_mode(), conf_get_value_sql_log_mode(), conf_get_value_table_on_off(), CONF_LOG_FILE_LEN, t_broker_info::connect_order, CUBRID_BASE_DIR, DEFAULT_ACCESS_LOG_DIR, DEFAULT_ACCESS_LOG_MAX_SIZE, DEFAULT_ADMIN_LOG_FILE, DEFAULT_APPL_SERVER, DEFAULT_AS_MAX_NUM, DEFAULT_AS_MIN_NUM, DEFAULT_CAS_MAX_PREPARED_STMT_COUNT, DEFAULT_EMPTY_STRING, DEFAULT_ERR_DIR, DEFAULT_HANG_TIMEOUT, DEFAULT_JDBC_CACHE_LIFE_TIME, DEFAULT_JOB_QUEUE_SIZE, DEFAULT_KEEP_CONNECTION, DEFAULT_LOG_DIR, DEFAULT_LONG_QUERY_TIME, DEFAULT_LONG_TRANSACTION_TIME, DEFAULT_MAX_NUM_DELAYED_HOSTS_LOOKUP, DEFAULT_MAX_QUERY_TIMEOUT, DEFAULT_MONITOR_HANG_INTERVAL, DEFAULT_MYSQL_KEEPALIVE_INTERVAL, DEFAULT_MYSQL_READ_TIMEOUT, DEFAULT_PROXY_MAX_PREPARED_STMT_COUNT, DEFAULT_RECONNECT_TIME, DEFAULT_SERVER_HARD_LIMIT, DEFAULT_SERVER_MAX_SIZE, DEFAULT_SESSION_TIMEOUT, DEFAULT_SHARD_KEY_MODULAR, DEFAULT_SHARD_MAX_CLIENTS, DEFAULT_SHARD_NUM_PROXY, DEFAULT_SHARD_PROXY_CONN_WAIT_TIMEOUT, DEFAULT_SHARD_PROXY_LOG_DIR, DEFAULT_SHARD_PROXY_LOG_MAX_SIZE, DEFAULT_SHARD_PROXY_LOG_MODE, DEFAULT_SHARD_PROXY_TIMEOUT, DEFAULT_SLOW_LOG_DIR, DEFAULT_SQL_LOG_MAX_SIZE, DEFAULT_SQL_LOG_MODE, DEFAULT_SSL_MODE, DEFAULT_TIME_TO_KILL, dir_repath(), envvar_libdir_file(), FALSE, get_conf_value(), t_broker_info::hang_timeout, i, t_broker_info::ignore_shard_hint, ini_findsec(), ini_gethex(), ini_getint(), ini_getsecname(), ini_getstr(), ini_getuint(), ini_getuint_max(), ini_parser_free(), ini_parser_load(), IS_ABS_PATH, t_broker_info::jdbc_cache, t_broker_info::jdbc_cache_life_time, t_broker_info::jdbc_cache_only_hint, JOB_QUEUE_MAX_SIZE, t_broker_info::job_queue_size, t_broker_info::keep_connection, ini_table::key, ini_table::lineno, t_broker_info::log_backup, t_broker_info::long_query_time, LONG_QUERY_TIME_LIMIT, t_broker_info::long_transaction_time, LONG_TRANSACTION_TIME_LIMIT, MAKE_FILEPATH, MAX_ACCESS_LOG_MAX_SIZE, MAX_BROKER_NUM, t_broker_info::max_client, t_broker_info::max_num_delayed_hosts_lookup, t_broker_info::max_prepared_stmt_count, MAX_PROXY_LOG_MAX_SIZE, MAX_PROXY_NUM, MAX_PROXY_TIMEOUT_LIMIT, MAX_QUERY_TIMEOUT_LIMIT, MAX_SQL_LOG_MAX_SIZE, t_broker_info::max_string_length, MIN_MYSQL_KEEPALIVE_INTERVAL, t_broker_info::monitor_hang_flag, t_broker_info::monitor_hang_interval, t_broker_info::monitor_server_flag, t_broker_info::mysql_keepalive_interval, t_broker_info::mysql_read_timeout, ini_table::nsec, NULL, t_broker_info::num_proxy, ON, PARAM_BAD_RANGE, PARAM_BAD_VALUE, PARAM_INVAL_SEC, t_broker_info::port, PORT_NUM_LIMIT, PRINTERROR, t_broker_info::proxy_conn_wait_timeout, t_broker_info::proxy_log_max_size, t_broker_info::proxy_log_mode, t_broker_info::proxy_max_prepared_stmt_count, proxy_shm_id, t_broker_info::proxy_shm_id, t_broker_info::proxy_timeout, query_timeout, t_broker_info::query_timeout, t_broker_info::reject_client_flag, t_broker_info::replica_only_flag, SECTION_NAME, SECTION_NAME_TOO_LONG, t_broker_info::service_flag, t_broker_info::session_timeout, t_broker_info::shard_flag, t_broker_info::shard_key_modular, ini_table::size, t_broker_info::slow_log_mode, t_broker_info::sql_log2, SQL_LOG2_MAX, SQL_LOG2_NONE, t_broker_info::sql_log_max_size, t_broker_info::sql_log_mode, t_broker_info::statement_pooling, stripped_column_name, t_broker_info::stripped_column_name, strlen, strncpy_bufsize, tbl_conf_err_msg, t_broker_info::time_to_kill, t_broker_info::trigger_action_flag, TRUE, t_broker_info::use_SSL, ut_size_string_to_kbyte(), and ut_time_string_to_sec().

Referenced by broker_config_read().

Here is the caller graph for this function:

static int check_port_number ( T_BROKER_INFO br_info,
int  num_brs 
)
static

Definition at line 289 of file broker_config.c.

References FALSE, i, and TRUE.

Referenced by broker_config_read_internal().

Here is the caller graph for this function:

static void conf_file_has_been_loaded ( const char *  conf_path)
static

Definition at line 267 of file broker_config.c.

References assert, conf_file_loaded, i, MAX_NUM_OF_CONF_FILE_LOADED, NULL, and strdup().

Referenced by broker_config_read_internal().

Here is the caller graph for this function:

int conf_get_value_access_mode ( const char *  value)

Definition at line 1566 of file broker_config.c.

References get_conf_value().

Referenced by admin_conf_change().

Here is the caller graph for this function:

int conf_get_value_connect_order ( const char *  value)

Definition at line 1577 of file broker_config.c.

References get_conf_value().

Referenced by admin_conf_change(), and broker_config_read_internal().

Here is the caller graph for this function:

int conf_get_value_keep_con ( const char *  value)

Definition at line 1555 of file broker_config.c.

References get_conf_value().

Referenced by admin_conf_change(), and broker_config_read_internal().

Here is the caller graph for this function:

int conf_get_value_proxy_log_mode ( const char *  value)

Definition at line 1588 of file broker_config.c.

References get_conf_value().

Referenced by admin_conf_change(), broker_config_read_internal(), and shard_shm_set_param_proxy_internal().

Here is the caller graph for this function:

int conf_get_value_sql_log_mode ( const char *  value)

Definition at line 1544 of file broker_config.c.

References get_conf_value().

Referenced by admin_conf_change(), broker_config_read_internal(), and shard_shm_set_param_as_internal().

Here is the caller graph for this function:

int conf_get_value_table_on_off ( const char *  value)

Definition at line 1533 of file broker_config.c.

References get_conf_value().

Referenced by admin_conf_change(), broker_config_read_internal(), and shard_shm_set_param_as_internal().

Here is the caller graph for this function:

void dir_repath ( char *  path,
size_t  path_len 
)

Definition at line 321 of file broker_config.c.

References assert, BROKER_PATH_MAX, get_cubrid_home(), IS_ABS_PATH, strncpy_bufsize, and trim().

Referenced by broker_config_read_internal(), and proxy_activate().

Here is the caller graph for this function:

static const char * get_conf_string ( int  value,
T_CONF_TABLE conf_table 
)
static

Definition at line 360 of file broker_config.c.

References t_conf_table::conf_str, t_conf_table::conf_value, i, and NULL.

Referenced by broker_config_dump().

Here is the caller graph for this function:

static int get_conf_value ( const char *  string,
T_CONF_TABLE conf_table 
)
static

Variable Documentation

const char* broker_keywords[]

Definition at line 174 of file broker_config.c.

Referenced by broker_config_read_internal().

int broker_keywords_size = sizeof (broker_keywords) / sizeof (char *)

Definition at line 259 of file broker_config.c.

Referenced by broker_config_read_internal().

char* conf_file_loaded[MAX_NUM_OF_CONF_FILE_LOADED]
static

Definition at line 171 of file broker_config.c.

Referenced by broker_config_dump(), and conf_file_has_been_loaded().

const char SECTION_NAME[] = "broker"
static

Definition at line 159 of file broker_config.c.

Referenced by broker_config_read_internal().

T_CONF_TABLE tbl_access_mode[]
static
T_CONF_TABLE tbl_appl_server[]
static
Initial value:
= {
{NULL, 0}
}
#define APPL_SERVER_CAS_TYPE_NAME
Definition: broker_config.h:44
#define APPL_SERVER_CAS
Definition: broker_config.h:34
#define APPL_SERVER_CAS_MYSQL_TYPE_NAME
Definition: broker_config.h:46
#define APPL_SERVER_CAS_ORACLE_TYPE_NAME
Definition: broker_config.h:45
#define APPL_SERVER_CAS_MYSQL
Definition: broker_config.h:37
#define APPL_SERVER_CAS_ORACLE
Definition: broker_config.h:35
#define APPL_SERVER_CAS_MYSQL51_TYPE_NAME
Definition: broker_config.h:47
#define NULL
Definition: freelistheap.h:34
#define APPL_SERVER_CAS_MYSQL51
Definition: broker_config.h:36

Definition at line 102 of file broker_config.c.

const char* tbl_conf_err_msg[]
static
Initial value:
= {
"",
"Cannot find any section in conf file.",
"Value type does not match parameter type.",
"Value is out of range.",
"Section name is too long. Section name must be less than 64."
}

Definition at line 161 of file broker_config.c.

Referenced by broker_config_read_internal().

T_CONF_TABLE tbl_connect_order[]
static
Initial value:

Definition at line 140 of file broker_config.c.

T_CONF_TABLE tbl_keep_connection[]
static
Initial value:
= {
{"ON", KEEP_CON_ON},
{"AUTO", KEEP_CON_AUTO},
{NULL, 0}
}
#define NULL
Definition: freelistheap.h:34

Definition at line 127 of file broker_config.c.

T_CONF_TABLE tbl_on_off[]
static
Initial value:
= {
{"ON", ON},
{"OFF", OFF},
{NULL, 0}
}
#define NULL
Definition: freelistheap.h:34

Definition at line 110 of file broker_config.c.

T_CONF_TABLE tbl_sql_log_mode[]
static