CUBRID Engine  latest
shard_metadata.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include "dbi.h"
#include "dlfcn.h"
#include "cas_common.h"
#include "broker_filename.h"
#include "broker_admin_pub.h"
#include "broker_util.h"
#include "shard_metadata.h"
Include dependency graph for shard_metadata.c:

Go to the source code of this file.

Macros

#define SHARD_QUERY_BUFFER_SIZE   1024
 
#define SHARD_METADATA_USER_TABLE_NAME   "shard_user"
 
#define SHARD_METADATA_KEY_RANGE_TABLE_NAME   "shard_range"
 
#define SHARD_METADATA_CONN_TABLE_NAME   "shard_conn"
 
#define DEFAULT_NUM_USER   1
 
#define DEFAULT_NUM_KEY   1
 
#define DEFAULT_NUM_CONN   4
 

Functions

static void shard_println_1 (FILE *fp)
 
static void shard_println_2 (FILE *fp)
 
static int shard_metadata_read_user (T_SHM_PROXY *shm_proxy_p, char *db_name, char *db_user, char *db_password)
 
static int shard_metadata_read_key (const char *filename, T_SHM_PROXY *shm_proxy_p)
 
static int shard_metadata_read_conn (const char *filename, T_SHM_PROXY *shm_proxy_p)
 
static int shard_metadata_key_range_comp (const void *p1, const void *p2)
 
static int shard_metadata_conn_comp (const void *p1, const void *p2)
 
static void shard_metadata_sort_key (T_SHM_SHARD_KEY *shm_key_p)
 
static void shard_metadata_sort_conn (T_SHM_SHARD_CONN *shm_conn_p)
 
static void shard_metadata_dump_user (FILE *fp, T_SHM_SHARD_USER *shm_user_p)
 
static void shard_metadata_dump_key (FILE *fp, T_SHM_SHARD_KEY *shm_key_p)
 
static void shard_metadata_dump_conn (FILE *fp, T_SHM_SHARD_CONN *shm_conn_p)
 
static int shard_metadata_validate (T_BROKER_INFO *br_info_p, T_SHM_PROXY *shm_proxy_p)
 
static int shard_metadata_validate_user (T_SHM_SHARD_USER *shm_user_p)
 
static int shard_metadata_validate_key_range_internal (T_SHARD_KEY *key_p, T_SHM_SHARD_CONN *shm_conn_p, int modular)
 
static int shard_metadata_validate_key (T_SHM_SHARD_KEY *shm_key_p, T_SHM_SHARD_CONN *shm_conn_p, int modular)
 
static int shard_metadata_validate_conn (T_SHM_SHARD_CONN *shm_conn_p)
 
static int shard_metadata_validate_key_function (const char *library_name, const char *function_name)
 
T_SHM_SHARD_USERshard_metadata_get_user (T_SHM_PROXY *shm_proxy_p)
 
T_SHM_SHARD_KEYshard_metadata_get_key (T_SHM_PROXY *shm_proxy_p)
 
T_SHM_SHARD_CONNshard_metadata_get_conn (T_SHM_PROXY *shm_proxy_p)
 
int shard_metadata_initialize (T_BROKER_INFO *br_info, T_SHM_PROXY *shm_proxy_p)
 
void shard_metadata_dump_internal (FILE *fp, T_SHM_PROXY *shm_proxy_p)
 
void shard_metadata_dump (FILE *fp, int shmid)
 
T_SHARD_KEYshard_metadata_bsearch_key (T_SHM_SHARD_KEY *shm_key_p, const char *keycolumn)
 
T_SHARD_KEY_RANGEshard_metadata_bsearch_range (T_SHARD_KEY *key_p, unsigned int hash_res)
 
T_SHARD_KEY_RANGEshard_metadata_find_shard_range (T_SHM_SHARD_KEY *shm_key_p, const char *key, unsigned int hash_res)
 
T_SHARD_USERshard_metadata_get_shard_user (T_SHM_SHARD_USER *shm_user_p)
 
T_SHARD_USERshard_metadata_get_shard_user_from_shm (T_SHM_PROXY *shm_proxy_p)
 
int load_shard_key_function (const char *library_name, const char *function_name)
 
void close_shard_key_function (void)
 

Variables

FN_GET_SHARD_KEY fn_get_shard_key = NULL
 
void * handle = NULL
 

Macro Definition Documentation

#define DEFAULT_NUM_CONN   4

Definition at line 59 of file shard_metadata.c.

Referenced by shard_metadata_read_conn().

#define DEFAULT_NUM_KEY   1

Definition at line 58 of file shard_metadata.c.

Referenced by shard_metadata_read_key().

#define DEFAULT_NUM_USER   1

Definition at line 57 of file shard_metadata.c.

#define SHARD_METADATA_CONN_TABLE_NAME   "shard_conn"

Definition at line 55 of file shard_metadata.c.

#define SHARD_METADATA_KEY_RANGE_TABLE_NAME   "shard_range"

Definition at line 54 of file shard_metadata.c.

#define SHARD_METADATA_USER_TABLE_NAME   "shard_user"

Definition at line 53 of file shard_metadata.c.

#define SHARD_QUERY_BUFFER_SIZE   1024

Definition at line 51 of file shard_metadata.c.

Function Documentation

void close_shard_key_function ( void  )

Definition at line 934 of file shard_metadata.c.

References fn_get_shard_key, handle, and NULL.

Referenced by register_fn_get_shard_key(), and shard_metadata_validate_key_function().

Here is the caller graph for this function:

int load_shard_key_function ( const char *  library_name,
const char *  function_name 
)

Definition at line 909 of file shard_metadata.c.

References fn_get_shard_key, handle, and NULL.

Referenced by register_fn_get_shard_key(), and shard_metadata_validate_key_function().

Here is the caller graph for this function:

T_SHARD_KEY* shard_metadata_bsearch_key ( T_SHM_SHARD_KEY shm_key_p,
const char *  keycolumn 
)

Definition at line 798 of file shard_metadata.c.

References t_shard_key::key_column, max, min, NULL, t_shm_shard_key::num_shard_key, and t_shm_shard_key::shard_key.

Referenced by shard_metadata_find_shard_range().

Here is the caller graph for this function:

T_SHARD_KEY_RANGE* shard_metadata_bsearch_range ( T_SHARD_KEY key_p,
unsigned int  hash_res 
)

Definition at line 832 of file shard_metadata.c.

References max, t_shard_key_range::max, min, t_shard_key_range::min, NULL, t_shard_key::num_key_range, and t_shard_key::range.

Referenced by shard_metadata_find_shard_range().

Here is the caller graph for this function:

static int shard_metadata_conn_comp ( const void *  p1,
const void *  p2 
)
static

Definition at line 360 of file shard_metadata.c.

References t_shard_conn::shard_id.

Referenced by shard_metadata_sort_conn().

Here is the caller graph for this function:

void shard_metadata_dump ( FILE *  fp,
int  shmid 
)

Definition at line 596 of file shard_metadata.c.

References NULL, SHARD_ERR, shard_metadata_dump_internal(), SHM_MODE_MONITOR, SHM_PROXY, shm_proxy_p, uw_shm_detach(), and uw_shm_open().

Referenced by broker_config_dump().

Here is the caller graph for this function:

static void shard_metadata_dump_conn ( FILE *  fp,
T_SHM_SHARD_CONN shm_conn_p 
)
static
void shard_metadata_dump_internal ( FILE *  fp,
T_SHM_PROXY shm_proxy_p 
)
static void shard_metadata_dump_user ( FILE *  fp,
T_SHM_SHARD_USER shm_user_p 
)
static
T_SHARD_KEY_RANGE* shard_metadata_find_shard_range ( T_SHM_SHARD_KEY shm_key_p,
const char *  key,
unsigned int  hash_res 
)

Definition at line 865 of file shard_metadata.c.

References NULL, shard_metadata_bsearch_key(), and shard_metadata_bsearch_range().

Referenced by admin_getid_cmd(), proxy_get_range_by_param(), and shard_stmt_change_shard_val_to_id().

Here is the caller graph for this function:

T_SHM_SHARD_CONN* shard_metadata_get_conn ( T_SHM_PROXY shm_proxy_p)
T_SHM_SHARD_KEY* shard_metadata_get_key ( T_SHM_PROXY shm_proxy_p)
T_SHARD_USER* shard_metadata_get_shard_user ( T_SHM_SHARD_USER shm_user_p)

Definition at line 877 of file shard_metadata.c.

References assert, NULL, t_shm_shard_user::num_shard_user, and t_shm_shard_user::shard_user.

Referenced by proxy_check_authorization().

Here is the caller graph for this function:

T_SHARD_USER* shard_metadata_get_shard_user_from_shm ( T_SHM_PROXY shm_proxy_p)
T_SHM_SHARD_USER* shard_metadata_get_user ( T_SHM_PROXY shm_proxy_p)
static int shard_metadata_key_range_comp ( const void *  p1,
const void *  p2 
)
static

Definition at line 340 of file shard_metadata.c.

References t_shard_key_range::min.

Referenced by shard_metadata_sort_key().

Here is the caller graph for this function:

static int shard_metadata_read_conn ( const char *  filename,
T_SHM_PROXY shm_proxy_p 
)
static
static int shard_metadata_read_user ( T_SHM_PROXY shm_proxy_p,
char *  db_name,
char *  db_user,
char *  db_password 
)
static
static void shard_metadata_sort_conn ( T_SHM_SHARD_CONN shm_conn_p)
static

Definition at line 394 of file shard_metadata.c.

References t_shm_shard_conn::num_shard_conn, t_shm_shard_conn::shard_conn, and shard_metadata_conn_comp().

Referenced by shard_metadata_initialize().

Here is the caller graph for this function:

static void shard_metadata_sort_key ( T_SHM_SHARD_KEY shm_key_p)
static
static int shard_metadata_validate_conn ( T_SHM_SHARD_CONN shm_conn_p)
static

Definition at line 759 of file shard_metadata.c.

References assert, i, NULL, t_shm_shard_conn::num_shard_conn, t_shm_shard_conn::shard_conn, SHARD_ERR, and t_shard_conn::shard_id.

Referenced by shard_metadata_validate().

Here is the caller graph for this function:

static int shard_metadata_validate_key ( T_SHM_SHARD_KEY shm_key_p,
T_SHM_SHARD_CONN shm_conn_p,
int  modular 
)
static
static int shard_metadata_validate_key_function ( const char *  library_name,
const char *  function_name 
)
static

Definition at line 782 of file shard_metadata.c.

References close_shard_key_function(), load_shard_key_function(), and SHARD_ERR.

Referenced by shard_metadata_validate().

Here is the caller graph for this function:

static int shard_metadata_validate_key_range_internal ( T_SHARD_KEY key_p,
T_SHM_SHARD_CONN shm_conn_p,
int  modular 
)
static
static int shard_metadata_validate_user ( T_SHM_SHARD_USER shm_user_p)
static

Definition at line 655 of file shard_metadata.c.

References assert, and NULL.

Referenced by shard_metadata_validate().

Here is the caller graph for this function:

static void shard_println_1 ( FILE *  fp)
static

Definition at line 98 of file shard_metadata.c.

References assert.

Referenced by shard_metadata_dump_conn(), shard_metadata_dump_key(), and shard_metadata_dump_user().

Here is the caller graph for this function:

static void shard_println_2 ( FILE *  fp)
static

Definition at line 106 of file shard_metadata.c.

References assert.

Referenced by shard_metadata_dump_conn(), shard_metadata_dump_key(), and shard_metadata_dump_user().

Here is the caller graph for this function:

Variable Documentation