CUBRID Engine  latest
cas_runner.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <math.h>
#include <pthread.h>
#include <unistd.h>
#include "cubrid_getopt.h"
#include "cas_common.h"
#include "porting.h"
#include "cas_cci.h"
#include "broker_log_util.h"
Include dependency graph for cas_runner.c:

Go to the source code of this file.

Classes

struct  t_bind_info
 
struct  t_node_info
 

Macros

#define PRINT_CCI_ERROR(ERRCODE, CCI_ERROR, result_fp)
 
#define FREE_BIND_INFO(NUM_BIND, BIND_INFO)
 
#define MAX_NODE_INFO   100
 
#define MAX_IGN_SRV_ERR   100
 
#define THREAD_FUNC   void*
 
#define SLEEP_SEC(X)   sleep(X)
 
#define SLEEP_MILISEC(sec, msec)
 
#define STRDUP(TARGET, SOURCE)
 
#define SERVER_HANDLE_ALLOC_SIZE   (MAX_SERVER_H_ID + 1)
 

Typedefs

typedef struct t_bind_info T_BIND_INFO
 
typedef struct t_node_info T_NODE_INFO
 

Functions

static double calc_stddev (double *t, double avg, int count)
 
static double calc_avg (double *t, int count)
 
static void calc_min_max (double *t, int count, double *min, double *max)
 
static int get_args (int argc, char *argv[])
 
static int read_conf (void)
 
static void cas_runner (FILE *fp, FILE *result_fp, double *ret_exec_time, double *ret_prepare_time)
 
static THREAD_FUNC thr_main (void *arg)
 
static int process_execute (char *msg, int *req_h, int num_bind, T_BIND_INFO *bind_info, FILE *result_fp, double *sum_execute_time)
 
static int process_bind (char *msg, int *num_bind_p, T_BIND_INFO *bind_info)
 
static int process_endtran (int con_h, int *req_h, FILE *result_fp)
 
static int process_close_req (char *linebuf, int *req_h, FILE *result_fp)
 
static void print_result (int cci_res, int req_id, FILE *fp)
 
static void free_node (T_NODE_INFO *node)
 
static int make_node_info (T_NODE_INFO *node, char *node_name, char *info_str)
 
static int set_args_with_node_info (char *node_name)
 
static int ignore_error (int code)
 
static char * make_sql_stmt (char *src)
 
int main (int argc, char *argv[])
 

Variables

const char * cci_client_name = "JDBC"
 
static char * broker_host = NULL
 
static int broker_port = 0
 
static char * dbname = NULL
 
static char * dbuser = NULL
 
static char * dbpasswd = NULL
 
static int num_thread = 1
 
static int repeat_count = 1
 
static char * exec_script_file
 
static int batch_mode = 0
 
static char * result_file = NULL
 
static char * cas_err_file = NULL
 
static int fork_delay = 0
 
static char * node_name = NULL
 
static int think_time = 0
 
static int qa_test_flag = 0
 
static int num_replica = 1
 
static int dump_query_plan = 0
 
static int autocommit_mode = 0
 
static int statdump_mode = 0
 
static double * run_time_exec
 
static FILE * cas_error_fp
 
static int cas_error_flag = 0
 
static int cubrid_manager_run = 0
 
static T_NODE_INFO node_table [MAX_NODE_INFO]
 
static int num_node = 0
 
static int ign_srv_err_list [MAX_IGN_SRV_ERR]
 
static int num_ign_srv_err = 0
 

Macro Definition Documentation

#define FREE_BIND_INFO (   NUM_BIND,
  BIND_INFO 
)
Value:
do { \
int i; \
for (i=0 ; i < NUM_BIND ; i++) { \
FREE_MEM(BIND_INFO[i].value); \
} \
NUM_BIND = 0; \
} while (0)
#define FREE_MEM(PTR)
Definition: cas_common.h:58
int i
Definition: dynamic_load.c:954
for(p=libs;*p;p++)
Definition: dynamic_load.c:968

Definition at line 82 of file cas_runner.c.

Referenced by cas_runner().

#define MAX_IGN_SRV_ERR   100

Definition at line 92 of file cas_runner.c.

Referenced by read_conf().

#define MAX_NODE_INFO   100

Definition at line 91 of file cas_runner.c.

Referenced by read_conf().

#define PRINT_CCI_ERROR (   ERRCODE,
  CCI_ERROR,
  result_fp 
)
#define SERVER_HANDLE_ALLOC_SIZE   (MAX_SERVER_H_ID + 1)

Definition at line 120 of file cas_runner.c.

Referenced by cas_runner(), process_close_req(), process_endtran(), and process_execute().

#define SLEEP_MILISEC (   sec,
  msec 
)
Value:
do { \
struct timeval sleep_time_val; \
sleep_time_val.tv_sec = sec; \
sleep_time_val.tv_usec = (msec) * 1000; \
select(0, 0, 0, 0, &sleep_time_val); \
} while(0)

Definition at line 105 of file cas_runner.c.

#define SLEEP_SEC (   X)    sleep(X)

Definition at line 104 of file cas_runner.c.

Referenced by main(), and thr_main().

#define STRDUP (   TARGET,
  SOURCE 
)
Value:
do { \
if(TARGET != NULL) free(TARGET); \
TARGET = strdup (SOURCE); \
} while(0)
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958
while(1)
Definition: cnvlex.c:816
char * strdup(const char *str)
Definition: porting.c:901

Definition at line 114 of file cas_runner.c.

Referenced by get_args(), and read_conf().

#define THREAD_FUNC   void*

Definition at line 103 of file cas_runner.c.

Referenced by get_args().

Typedef Documentation

typedef struct t_bind_info T_BIND_INFO

Definition at line 122 of file cas_runner.c.

typedef struct t_node_info T_NODE_INFO

Definition at line 130 of file cas_runner.c.

Function Documentation

static double calc_avg ( double *  t,
int  count 
)
static

Definition at line 454 of file cas_runner.c.

References cubregex::count(), and i.

Referenced by main().

Here is the caller graph for this function:

static void calc_min_max ( double *  t,
int  count,
double *  min,
double *  max 
)
static

Definition at line 433 of file cas_runner.c.

References cubregex::count(), and i.

Referenced by main().

Here is the caller graph for this function:

static double calc_stddev ( double *  t,
double  avg,
int  count 
)
static

Definition at line 466 of file cas_runner.c.

References cubregex::count(), and i.

Referenced by main().

Here is the caller graph for this function:

static void cas_runner ( FILE *  fp,
FILE *  result_fp,
double *  ret_exec_time,
double *  ret_prepare_time 
)
static
static void free_node ( T_NODE_INFO node)
static
static int get_args ( int  argc,
char *  argv[] 
)
static
static int ignore_error ( int  code)
static

Definition at line 1485 of file cas_runner.c.

References i, ign_srv_err_list, and num_ign_srv_err.

static int make_node_info ( T_NODE_INFO node,
char *  node_name,
char *  info_str 
)
static

Definition at line 1389 of file cas_runner.c.

References t_node_info::dbname, t_node_info::dbpasswd, t_node_info::dbuser, err, FREE_MEM, free_node(), i, t_node_info::ip, t_node_info::node_name, NULL, p, t_node_info::port, strdup(), and trim().

Referenced by read_conf().

Here is the caller graph for this function:

static char * make_sql_stmt ( char *  src)
static

Definition at line 1497 of file cas_runner.c.

References cubrid_manager_run, FREE_MEM, i, NULL, num_replica, p, strlen, and trim().

Referenced by cas_runner().

Here is the caller graph for this function:

static void print_result ( int  cci_res,
int  req_id,
FILE *  fp 
)
static

Definition at line 1292 of file cas_runner.c.

References cas_error_fp, dump_query_plan, i, NULL, and PRINT_CCI_ERROR.

Referenced by process_execute().

Here is the caller graph for this function:

static int process_bind ( char *  msg,
int *  num_bind_p,
T_BIND_INFO bind_info 
)
static

Definition at line 1089 of file cas_runner.c.

References t_bind_info::len, MAX_BIND_VALUE, NULL, p, strdup(), t_bind_info::type, and t_bind_info::value.

Referenced by cas_runner().

Here is the caller graph for this function:

static int process_close_req ( char *  linebuf,
int *  req_h,
FILE *  result_fp 
)
static

Definition at line 1231 of file cas_runner.c.

References cas_error_fp, NULL, PRINT_CCI_ERROR, and SERVER_HANDLE_ALLOC_SIZE.

Referenced by cas_runner().

Here is the caller graph for this function:

static int process_endtran ( int  con_h,
int *  req_h,
FILE *  result_fp 
)
static

Definition at line 1256 of file cas_runner.c.

References autocommit_mode, cas_error_fp, i, NULL, PRINT_CCI_ERROR, SERVER_HANDLE_ALLOC_SIZE, and ut_diff_time().

Referenced by cas_runner().

Here is the caller graph for this function:

static int process_execute ( char *  msg,
int *  req_h,
int  num_bind,
T_BIND_INFO bind_info,
FILE *  result_fp,
double *  sum_execute_time 
)
static
static int read_conf ( void  )
static
static int set_args_with_node_info ( char *  node_name)
static

Definition at line 1454 of file cas_runner.c.

References broker_host, broker_port, t_node_info::dbname, dbname, t_node_info::dbpasswd, dbpasswd, t_node_info::dbuser, dbuser, i, t_node_info::ip, NULL, num_node, and t_node_info::port.

Referenced by main().

Here is the caller graph for this function:

static THREAD_FUNC thr_main ( void *  arg)
static

Definition at line 579 of file cas_runner.c.

References cas_runner(), exec_script_file, i, NULL, p, repeat_count, result_file, run_time_exec, SLEEP_SEC, and think_time.

Referenced by log_top_query(), and main().

Here is the caller graph for this function:

Variable Documentation

int autocommit_mode = 0
static

Definition at line 179 of file cas_runner.c.

Referenced by cas_runner(), get_args(), and process_endtran().

int batch_mode = 0
static

Definition at line 170 of file cas_runner.c.

Referenced by get_args(), main(), and process_execute().

char* broker_host = NULL
static

Definition at line 162 of file cas_runner.c.

Referenced by cas_runner(), get_args(), main(), read_conf(), and set_args_with_node_info().

int broker_port = 0
static

Definition at line 163 of file cas_runner.c.

Referenced by cas_runner(), get_args(), main(), read_conf(), and set_args_with_node_info().

char* cas_err_file = NULL
static

Definition at line 172 of file cas_runner.c.

Referenced by get_args(), main(), and read_conf().

int cas_error_flag = 0
static

Definition at line 184 of file cas_runner.c.

Referenced by main().

FILE* cas_error_fp
static
const char* cci_client_name = "JDBC"

Definition at line 160 of file cas_runner.c.

int cubrid_manager_run = 0
static

Definition at line 185 of file cas_runner.c.

Referenced by main(), make_sql_stmt(), and process_execute().

char* dbname = NULL
static

Definition at line 164 of file cas_runner.c.

Referenced by cas_runner(), get_args(), main(), read_conf(), and set_args_with_node_info().

char* dbpasswd = NULL
static

Definition at line 166 of file cas_runner.c.

Referenced by cas_runner(), get_args(), main(), read_conf(), and set_args_with_node_info().

char* dbuser = NULL
static

Definition at line 165 of file cas_runner.c.

Referenced by cas_runner(), get_args(), main(), read_conf(), and set_args_with_node_info().

int dump_query_plan = 0
static

Definition at line 178 of file cas_runner.c.

Referenced by get_args(), print_result(), and process_execute().

char* exec_script_file
static

Definition at line 169 of file cas_runner.c.

Referenced by get_args(), and thr_main().

int fork_delay = 0
static

Definition at line 173 of file cas_runner.c.

Referenced by get_args(), main(), and read_conf().

int ign_srv_err_list[MAX_IGN_SRV_ERR]
static

Definition at line 189 of file cas_runner.c.

Referenced by ignore_error(), and read_conf().

T_NODE_INFO node_table[MAX_NODE_INFO]
static

Definition at line 187 of file cas_runner.c.

int num_ign_srv_err = 0
static

Definition at line 190 of file cas_runner.c.

Referenced by ignore_error(), and read_conf().

int num_node = 0
static

Definition at line 188 of file cas_runner.c.

Referenced by read_conf(), and set_args_with_node_info().

int num_replica = 1
static

Definition at line 177 of file cas_runner.c.

Referenced by get_args(), main(), make_sql_stmt(), and process_execute().

int num_thread = 1
static

Definition at line 167 of file cas_runner.c.

Referenced by get_args(), log_top_query(), main(), and read_conf().

int qa_test_flag = 0
static

Definition at line 176 of file cas_runner.c.

Referenced by get_args(), and main().

int repeat_count = 1
static

Definition at line 168 of file cas_runner.c.

Referenced by get_args(), main(), read_conf(), and thr_main().

char* result_file = NULL
static

Definition at line 171 of file cas_runner.c.

Referenced by get_args(), main(), read_conf(), and thr_main().

double* run_time_exec
static

Definition at line 182 of file cas_runner.c.

Referenced by main(), and thr_main().

int statdump_mode = 0
static

Definition at line 180 of file cas_runner.c.

Referenced by cas_runner(), and get_args().

int think_time = 0
static

Definition at line 175 of file cas_runner.c.

Referenced by get_args(), and thr_main().