CUBRID Engine  latest
broker_admin_pub.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <assert.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <math.h>
#include "porting.h"
#include "cas_common.h"
#include "broker_shm.h"
#include "shard_metadata.h"
#include "shard_shm.h"
#include "shard_key_func.h"
#include "broker_util.h"
#include "broker_env_def.h"
#include "broker_process_size.h"
#include "broker_admin_pub.h"
#include "broker_filename.h"
#include "broker_error.h"
#include "cas_sql_log2.h"
#include "broker_acl.h"
#include "chartype.h"
#include "cubrid_getopt.h"
#include "dbtype_def.h"

Go to the source code of this file.

Macros

#define ADMIN_ERR_MSG_SIZE   BROKER_PATH_MAX * 2
 
#define MAKE_VERSION(MAJOR, MINOR)   (((MAJOR) << 8) | (MINOR))
 
#define SHM_OPEN_ERR_MSG(BUF, ERRCODE, OSERRCODE)
 
#define MEMBER_SIZE(TYPE, MEMBER)   ((int) sizeof(((TYPE *)0)->MEMBER))
 
#define NUM_OF_DIGITS(NUMBER)   (int)log10(NUMBER) + 1
 
#define ALL_PROXY   -1
 
#define ALL_SHARD   -1
 
#define ALL_AS   -1
 

Functions

static int shard_shm_set_param_proxy (T_SHM_PROXY *proxy_p, const char *param_name, const char *param_value, int proxy_id)
 
static int shard_shm_set_param_proxy_internal (T_PROXY_INFO *proxy_info_p, const char *param_name, const char *param_value)
 
static int shard_shm_set_param_as (T_PROXY_INFO *proxy_info_p, T_SHARD_INFO *shard_info_p, const char *param_name, const char *param_value, int as_number)
 
static int shard_shm_set_param_as_internal (T_APPL_SERVER_INFO *as_info, const char *param_name, const char *param_value)
 
static int shard_shm_set_param_as_in_shard (T_PROXY_INFO *proxy_info_p, const char *param_name, const char *param_value, int shard_id, int as_number)
 
static int shard_shm_set_param_as_in_proxy (T_SHM_PROXY *proxy_p, const char *param_name, const char *param_value, int proxy_id, int shard_id, int as_number)
 
static int shard_shm_check_max_file_open_limit (T_BROKER_INFO *br_info, T_SHM_PROXY *proxy_p)
 
static void get_shard_db_password (T_BROKER_INFO *br_info_p)
 
static void get_upper_str (char *upper_str, int len, char *value)
 
static void rename_error_log_file_name (char *error_log_file, struct tm *ct)
 
static int br_activate (T_BROKER_INFO *br_info, int master_shm_id, T_SHM_BROKER *shm_br)
 
static int br_inactivate (T_BROKER_INFO *)
 
static void as_activate (T_SHM_BROKER *shm_br, T_BROKER_INFO *br_info, T_SHM_APPL_SERVER *shm_as_p, T_APPL_SERVER_INFO *as_info_p, int as_idex, char **env, int env_num)
 
static void as_inactivate (T_APPL_SERVER_INFO *as_info_p, char *broker_name, int shard_flag)
 
static int check_shard_conn (T_SHM_APPL_SERVER *shm_as_p, T_SHM_PROXY *shm_proxy_p)
 
static int check_shard_as_conn (T_SHM_APPL_SERVER *shm_as_p, T_SHARD_INFO *shard_info_p)
 
static void free_env (char **env, int env_num)
 
static char ** make_env (char *env_file, int *env_num)
 
static int broker_create_dir (const char *new_dir)
 
static int proxy_activate (T_BROKER_INFO *br_info_p, T_SHM_PROXY *shm_proxy_p, T_SHM_APPL_SERVER *shm_as_p, char **env, int env_num)
 
static int proxy_activate_internal (int proxy_shm_id, T_SHM_APPL_SERVER *shm_as_p, T_SHM_PROXY *shm_proxy_p, int proxy_id, char **env, int env_num)
 
static void proxy_inactivate (T_BROKER_INFO *br_info_p, T_PROXY_INFO *proxy_info_p)
 
int admin_start_cmd (T_BROKER_INFO *br_info, int br_num, int master_shm_id, bool acl_flag, char *acl_file)
 
int admin_stop_cmd (int master_shm_id)
 
int admin_add_cmd (int master_shm_id, const char *broker)
 
int admin_restart_cmd (int master_shm_id, const char *broker, int as_index)
 
int admin_drop_cmd (int master_shm_id, const char *broker)
 
int admin_on_cmd (int master_shm_id, const char *broker_name)
 
int admin_off_cmd (int master_shm_id, const char *broker_name)
 
int admin_reset_cmd (int master_shm_id, const char *broker_name)
 
int admin_info_cmd (int master_shm_id)
 
static bool key_isdigit (const char *value)
 
static int make_sp_value (SP_VALUE *value_p, char *shard_key)
 
static void print_usage (void)
 
int admin_getid_cmd (int master_shm_id, int argc, const char **argv)
 
int admin_conf_change (int master_shm_id, const char *br_name, const char *conf_name, const char *conf_value, int as_number)
 
int admin_del_cas_log (int master_shmid, const char *broker, int asid)
 
void admin_init_env ()
 
int admin_acl_status_cmd (int master_shm_id, const char *broker_name)
 
int admin_acl_reload_cmd (int master_shm_id, const char *broker_name)
 

Variables

T_SHM_PROXYshm_proxy_p = NULL
 
static char shard_db_password_env_str [MAX_BROKER_NUM][128]
 
char admin_err_msg [ADMIN_ERR_MSG_SIZE]
 
char ** environ
 

Macro Definition Documentation

#define ADMIN_ERR_MSG_SIZE   BROKER_PATH_MAX * 2
#define ALL_AS   -1

Definition at line 107 of file broker_admin_pub.c.

Referenced by admin_conf_change().

#define ALL_PROXY   -1

Definition at line 105 of file broker_admin_pub.c.

Referenced by admin_conf_change().

#define ALL_SHARD   -1

Definition at line 106 of file broker_admin_pub.c.

Referenced by admin_conf_change().

#define MAKE_VERSION (   MAJOR,
  MINOR 
)    (((MAJOR) << 8) | (MINOR))

Definition at line 83 of file broker_admin_pub.c.

Referenced by make_env().

#define MEMBER_SIZE (   TYPE,
  MEMBER 
)    ((int) sizeof(((TYPE *)0)->MEMBER))

Definition at line 102 of file broker_admin_pub.c.

Referenced by admin_start_cmd().

#define NUM_OF_DIGITS (   NUMBER)    (int)log10(NUMBER) + 1

Definition at line 103 of file broker_admin_pub.c.

Referenced by admin_start_cmd().

#define SHM_OPEN_ERR_MSG (   BUF,
  ERRCODE,
  OSERRCODE 
)
Value:
do { \
int _err = ERRCODE, _os_err = OSERRCODE; \
int _msglen = 0; \
char *_msg = NULL; \
sprintf(BUF, "Cannot open shared memory (Version mismatched)"); \
} \
if (_os_err > 0) \
_msg = strerror(_os_err); \
_msglen = sprintf(BUF, "Cannot open shared memory"); \
if (_msg != NULL) \
_msglen += sprintf(BUF + _msglen, " (os error = %s)", _msg); \
} \
} while (0)
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958
else
#define UW_ER_SHM_OPEN_MAGIC
Definition: broker_error.h:82

Definition at line 85 of file broker_admin_pub.c.

Referenced by admin_acl_reload_cmd(), admin_acl_status_cmd(), admin_add_cmd(), admin_conf_change(), admin_drop_cmd(), admin_info_cmd(), admin_off_cmd(), admin_on_cmd(), admin_reset_cmd(), admin_restart_cmd(), admin_stop_cmd(), and br_inactivate().

Function Documentation

int admin_conf_change ( int  master_shm_id,
const char *  br_name,
const char *  conf_name,
const char *  conf_value,
int  as_number 
)

Definition at line 1528 of file broker_admin_pub.c.

References t_broker_info::access_log, t_shm_appl_server::access_log, t_broker_info::access_log_max_size, t_shm_appl_server::access_log_max_size, t_broker_info::access_mode, t_shm_appl_server::access_mode, admin_err_msg, ALL_AS, ALL_PROXY, ALL_SHARD, t_broker_info::appl_server_hard_limit, t_shm_appl_server::appl_server_hard_limit, t_broker_info::appl_server_max_num, t_broker_info::appl_server_max_size, t_shm_appl_server::appl_server_max_size, APPL_SERVER_NUM_LIMIT, t_broker_info::appl_server_shm_id, t_shm_appl_server::as_info, assert, br_index, t_shm_broker::br_info, br_info_p, broker_create_dir(), BROKER_INFO_NAME_MAX, BROKER_PATH_MAX, t_broker_info::cache_user_info, t_shm_appl_server::cache_user_info, t_appl_server_info::cas_err_log_reset, t_appl_server_info::cas_log_reset, CAS_LOG_RESET_REOPEN, t_broker_info::cas_rctime, t_shm_appl_server::cas_rctime, t_appl_server_info::cas_slow_log_reset, t_broker_info::cci_pconnect, t_shm_appl_server::cci_pconnect, conf_get_value_access_mode(), 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, t_shm_appl_server::connect_order, t_appl_server_info::cur_slow_log_mode, t_appl_server_info::cur_sql_log_mode, DEFAULT_MAX_NUM_DELAYED_HOSTS_LOOKUP, t_broker_info::err_log_dir, t_shm_appl_server::err_log_dir, i, t_broker_info::jdbc_cache, t_shm_appl_server::jdbc_cache, t_broker_info::jdbc_cache_life_time, t_shm_appl_server::jdbc_cache_life_time, t_broker_info::jdbc_cache_only_hint, t_shm_appl_server::jdbc_cache_only_hint, t_broker_info::keep_connection, t_shm_appl_server::keep_connection, t_broker_info::log_backup, t_broker_info::log_dir, t_shm_appl_server::log_dir, t_broker_info::long_query_time, t_shm_appl_server::long_query_time, LONG_QUERY_TIME_LIMIT, t_broker_info::long_transaction_time, t_shm_appl_server::long_transaction_time, LONG_TRANSACTION_TIME_LIMIT, MAKE_FILEPATH, MAX_ACCESS_LOG_MAX_SIZE, t_broker_info::max_num_delayed_hosts_lookup, t_shm_appl_server::max_num_delayed_hosts_lookup, t_broker_info::max_prepared_stmt_count, t_shm_appl_server::max_prepared_stmt_count, MAX_PROXY_LOG_MAX_SIZE, MAX_QUERY_TIMEOUT_LIMIT, MAX_SQL_LOG_MAX_SIZE, MIN_MYSQL_KEEPALIVE_INTERVAL, t_broker_info::monitor_server_flag, t_shm_appl_server::monitor_server_flag, t_broker_info::mysql_keepalive_interval, t_shm_appl_server::mysql_keepalive_interval, t_broker_info::mysql_read_timeout, t_shm_appl_server::mysql_read_timeout, t_broker_info::name, NULL, t_shm_appl_server::num_appl_server, t_shm_broker::num_broker, OFF, ON, ONE_K, parse_int(), t_broker_info::preferred_hosts, t_shm_appl_server::preferred_hosts, t_broker_info::proxy_log_max_size, t_shm_appl_server::proxy_log_max_size, t_broker_info::proxy_log_mode, t_broker_info::proxy_shm_id, t_broker_info::query_timeout, t_shm_appl_server::query_timeout, t_appl_server_info::reset_flag, t_broker_info::service_flag, t_broker_info::session_timeout, t_shm_appl_server::session_timeout, t_broker_info::shard_flag, shard_shm_set_param_as_in_proxy(), shard_shm_set_param_proxy(), SHM_APPL_SERVER, SHM_APPL_SERVER_NAME_MAX, shm_as_p, shm_br, SHM_BROKER, SHM_MODE_ADMIN, SHM_OPEN_ERR_MSG, SHM_PROXY, t_broker_info::slow_log_dir, t_shm_appl_server::slow_log_dir, t_broker_info::slow_log_mode, t_shm_appl_server::slow_log_mode, t_broker_info::sql_log2, t_shm_appl_server::sql_log2, SQL_LOG2_MAX, t_broker_info::sql_log_max_size, t_shm_appl_server::sql_log_max_size, t_broker_info::sql_log_mode, t_shm_appl_server::sql_log_mode, t_broker_info::statement_pooling, t_shm_appl_server::statement_pooling, strlen, t_broker_info::time_to_kill, t_broker_info::trigger_action_flag, t_shm_appl_server::trigger_action_flag, TRUE, ut_cd_root_dir(), ut_cd_work_dir(), ut_size_string_to_kbyte(), ut_time_string_to_sec(), uw_get_error_code(), uw_get_os_error_code(), uw_shm_detach(), and uw_shm_open().

Referenced by main(), and uc_changer_internal().

Here is the caller graph for this function:

int admin_info_cmd ( int  master_shm_id)
void admin_init_env ( void  )
int admin_restart_cmd ( int  master_shm_id,
const char *  broker,
int  as_index 
)

Definition at line 594 of file broker_admin_pub.c.

References admin_err_msg, ADMIN_ERR_MSG_SIZE, t_broker_info::appl_server, t_broker_info::appl_server_max_num, t_shm_appl_server::appl_server_name, APPL_SERVER_NAME_MAX_SIZE, t_broker_info::appl_server_shm_id, APPL_SERVER_SHM_KEY_STR, t_shm_appl_server::as_info, br_index, t_shm_broker::br_info, t_appl_server_info::cas_clt_ip, t_appl_server_info::cas_clt_port, t_appl_server_info::clt_appl_name, t_appl_server_info::clt_req_path_info, t_appl_server_info::database_host, t_appl_server_info::database_name, t_appl_server_info::driver_version, environ, FALSE, free_env(), getsize(), i, IS_APPL_SERVER_TYPE_CAS, t_appl_server_info::last_access_time, t_appl_server_info::last_connect_time, make_env(), t_appl_server_info::mutex_flag, t_appl_server_info::mutex_turn, t_broker_info::name, NULL, t_shm_broker::num_broker, ON, t_appl_server_info::pid, pid, t_appl_server_info::psize, t_appl_server_info::psize_time, t_appl_server_info::reset_flag, t_appl_server_info::service_flag, SERVICE_ON, t_appl_server_info::service_ready_flag, t_broker_info::shard_flag, t_shm_appl_server::shard_flag, shm_appl, SHM_APPL_SERVER, shm_br, SHM_BROKER, SHM_MODE_ADMIN, SHM_MUTEX_ADMIN, SHM_MUTEX_BROKER, SHM_OPEN_ERR_MSG, SLEEP_SEC, snprintf_dots_truncate, t_broker_info::source_env, t_appl_server_info::transaction_start_time, TRUE, ut_is_appl_server_ready(), ut_kill_as_process(), t_appl_server_info::uts_status, UTS_STATUS_BUSY, UTS_STATUS_IDLE, uw_get_error_code(), uw_get_os_error_code(), uw_shm_detach(), and uw_shm_open().

Referenced by main(), and uc_restart().

Here is the caller graph for this function:

static void as_activate ( T_SHM_BROKER shm_br,
T_BROKER_INFO br_info,
T_SHM_APPL_SERVER shm_as_p,
T_APPL_SERVER_INFO as_info_p,
int  as_idex,
char **  env,
int  env_num 
)
static

Definition at line 3154 of file broker_admin_pub.c.

References t_broker_info::appl_server, APPL_SERVER_CAS_ORACLE, t_shm_appl_server::appl_server_name, APPL_SERVER_NAME_MAX_SIZE, t_broker_info::appl_server_shm_id, APPL_SERVER_SHM_KEY_STR, AS_ID_ENV_STR, t_shm_appl_server::broker_name, BROKER_PATH_MAX, t_appl_server_info::cas_clt_ip, t_appl_server_info::cas_clt_port, t_appl_server_info::clt_appl_name, t_appl_server_info::clt_req_path_info, CON_STATUS_LOCK_INIT, t_appl_server_info::cur_slow_log_mode, t_appl_server_info::cur_sql_log_mode, t_appl_server_info::driver_version, environ, FALSE, getsize(), i, t_appl_server_info::last_access_time, t_appl_server_info::mutex_flag, t_appl_server_info::mutex_turn, t_broker_info::name, NULL, t_appl_server_info::num_request, OFF, ON, t_appl_server_info::pid, pid, t_appl_server_info::proxy_id, t_appl_server_info::psize, t_appl_server_info::psize_time, t_appl_server_info::reset_flag, t_appl_server_info::service_flag, SERVICE_ON, t_appl_server_info::service_ready_flag, t_appl_server_info::shard_cas_id, t_broker_info::shard_flag, t_appl_server_info::shard_id, SHM_MUTEX_ADMIN, SHM_MUTEX_BROKER, t_shm_appl_server::slow_log_mode, t_shm_appl_server::sql_log_mode, t_appl_server_info::transaction_start_time, ut_get_as_port_name(), ut_is_appl_server_ready(), t_appl_server_info::uts_status, UTS_STATUS_CON_WAIT, UTS_STATUS_IDLE, UTS_STATUS_START, and uw_shm_detach().

Referenced by admin_add_cmd(), and br_activate().

Here is the caller graph for this function:

static void as_inactivate ( T_APPL_SERVER_INFO as_info_p,
char *  broker_name,
int  shard_flag 
)
static
static int broker_create_dir ( const char *  new_dir)
static

Definition at line 184 of file broker_admin_pub.c.

References BROKER_PATH_MAX, NULL, p, shm_br, SHM_BROKER, SHM_MODE_ADMIN, strlen, trim(), uw_shm_detach(), and uw_shm_open().

Referenced by admin_conf_change(), and admin_start_cmd().

Here is the caller graph for this function:

static int check_shard_as_conn ( T_SHM_APPL_SERVER shm_as_p,
T_SHARD_INFO shard_info_p 
)
static
static void free_env ( char **  env,
int  env_num 
)
static

Definition at line 3509 of file broker_admin_pub.c.

References FREE_MEM, i, and NULL.

Referenced by admin_add_cmd(), admin_restart_cmd(), and br_activate().

Here is the caller graph for this function:

static void get_shard_db_password ( T_BROKER_INFO br_info_p)
static

Definition at line 3997 of file broker_admin_pub.c.

References BROKER_NAME_LEN, get_upper_str(), t_broker_info::name, NULL, p, and t_broker_info::shard_db_password.

Referenced by admin_start_cmd().

Here is the caller graph for this function:

static void get_upper_str ( char *  upper_str,
int  len,
char *  value 
)
static

Definition at line 4017 of file broker_admin_pub.c.

References i.

Referenced by admin_on_cmd(), admin_start_cmd(), and get_shard_db_password().

Here is the caller graph for this function:

static bool key_isdigit ( const char *  value)
static

Definition at line 1212 of file broker_admin_pub.c.

References char_isdigit(), and p.

Referenced by make_sp_value().

Here is the caller graph for this function:

static char ** make_env ( char *  env_file,
int *  env_num 
)
static

Definition at line 3526 of file broker_admin_pub.c.

References FREE_MEM, MAKE_VERSION, NULL, p, and strlen.

Referenced by admin_add_cmd(), admin_restart_cmd(), and br_activate().

Here is the caller graph for this function:

static int make_sp_value ( SP_VALUE value_p,
char *  shard_key 
)
static

Definition at line 1232 of file broker_admin_pub.c.

References sp_value::integer, key_isdigit(), sp_value::length, NULL, sp_value::string, strlen, sp_value::type, sp_value::value, VT_INTEGER, and VT_STRING.

Referenced by admin_getid_cmd().

Here is the caller graph for this function:

static void print_usage ( void  )
static

Definition at line 1265 of file broker_admin_pub.c.

Referenced by admin_getid_cmd(), and main().

Here is the caller graph for this function:

static int proxy_activate ( T_BROKER_INFO br_info_p,
T_SHM_PROXY shm_proxy_p,
T_SHM_APPL_SERVER shm_as_p,
char **  env,
int  env_num 
)
static
static void proxy_inactivate ( T_BROKER_INFO br_info_p,
T_PROXY_INFO proxy_info_p 
)
static

Definition at line 3494 of file broker_admin_pub.c.

References t_proxy_info::cur_client, t_broker_info::name, t_proxy_info::pid, t_proxy_info::proxy_id, and ut_kill_proxy_process().

Referenced by br_inactivate().

Here is the caller graph for this function:

static void rename_error_log_file_name ( char *  error_log_file,
struct tm *  ct 
)
static

Definition at line 3627 of file broker_admin_pub.c.

Referenced by br_inactivate().

Here is the caller graph for this function:

static int shard_shm_check_max_file_open_limit ( T_BROKER_INFO br_info,
T_SHM_PROXY proxy_p 
)
static

Definition at line 3943 of file broker_admin_pub.c.

References admin_err_msg, error(), t_shard_info::max_appl_server, NULL, PROXY_RESERVED_FD, shard_shm_find_proxy_info(), and shard_shm_find_shard_info().

Referenced by admin_on_cmd(), and admin_start_cmd().

Here is the caller graph for this function:

static int shard_shm_set_param_as ( T_PROXY_INFO proxy_info_p,
T_SHARD_INFO shard_info_p,
const char *  param_name,
const char *  param_value,
int  as_number 
)
static
static int shard_shm_set_param_as_in_proxy ( T_SHM_PROXY proxy_p,
const char *  param_name,
const char *  param_value,
int  proxy_id,
int  shard_id,
int  as_number 
)
static

Definition at line 3905 of file broker_admin_pub.c.

References admin_err_msg, NULL, t_shm_proxy::num_proxy, shard_shm_find_proxy_info(), and shard_shm_set_param_as_in_shard().

Referenced by admin_conf_change().

Here is the caller graph for this function:

static int shard_shm_set_param_as_in_shard ( T_PROXY_INFO proxy_info_p,
const char *  param_name,
const char *  param_value,
int  shard_id,
int  as_number 
)
static

Definition at line 3867 of file broker_admin_pub.c.

References admin_err_msg, NULL, t_proxy_info::num_shard_conn, shard_shm_find_shard_info(), and shard_shm_set_param_as().

Referenced by shard_shm_set_param_as_in_proxy().

Here is the caller graph for this function:

static int shard_shm_set_param_as_internal ( T_APPL_SERVER_INFO as_info,
const char *  param_name,
const char *  param_value 
)
static
static int shard_shm_set_param_proxy ( T_SHM_PROXY proxy_p,
const char *  param_name,
const char *  param_value,
int  proxy_id 
)
static

Definition at line 3637 of file broker_admin_pub.c.

References admin_err_msg, NULL, t_shm_proxy::num_proxy, proxy_info_p, shard_shm_find_proxy_info(), and shard_shm_set_param_proxy_internal().

Referenced by admin_conf_change().

Here is the caller graph for this function:

Variable Documentation

char shard_db_password_env_str[MAX_BROKER_NUM][128]
static

Definition at line 162 of file broker_admin_pub.c.

Referenced by admin_on_cmd(), and admin_start_cmd().

T_SHM_PROXY* shm_proxy_p = NULL

Definition at line 109 of file broker_admin_pub.c.