CUBRID Engine
latest
|
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <assert.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "environment_variable.h"
#include "error_context.hpp"
#include "porting.h"
#include "system_parameter.h"
#include "error_manager.h"
#include "connection_defs.h"
#include "connection_support.h"
#include "tcp.h"
#include "release_string.h"
#include "heartbeat.h"
Go to the source code of this file.
Variables | |
static pthread_t | hb_Master_mon_th |
static CSS_CONN_ENTRY * | hb_Conn = NULL |
static char | hb_Exec_path [PATH_MAX] |
static char ** | hb_Argv |
bool | hb_Proc_shutdown = false |
SOCKET | hb_Pipe_to_master = INVALID_SOCKET |
CSS_CONN_ENTRY* css_connect_to_master_server | ( | int | master_port_id, |
const char * | server_name, | ||
int | name_length | ||
) |
Definition at line 861 of file connection_cl.c.
References ARG_FILE_LINE, css_common_connect(), css_free_conn(), css_make_conn(), css_net_send(), css_open_server_connection_socket(), css_readn(), css_send_data(), css_Server_inhibit_connection_socket, css_Server_use_new_connection_protocol, css_Service_id, css_tcp_listen_server_datagram(), css_tcp_setup_server_datagram(), CUB_MAXHOSTNAMELEN, ER_ERROR_SEVERITY, er_set(), er_set_with_oserror(), ERR_CSS_APPLYLOG_ALREADY_EXISTS, ERR_CSS_COPYLOG_ALREADY_EXISTS, ERR_CSS_ERROR_DURING_SERVER_CONNECT, ERR_CSS_SERVER_ALREADY_EXISTS, css_conn_entry::fd, GET_REAL_MASTER_CONN_NAME, GETHOSTNAME, htonl(), IS_MASTER_CONN_NAME_HA_APPLYLOG, IS_MASTER_CONN_NAME_HA_COPYLOG, IS_MASTER_CONN_NAME_HA_SERVER, NO_ERRORS, ntohl(), NULL, SERVER_ALREADY_EXISTS, SERVER_REQUEST, SERVER_REQUEST_ACCEPTED, SERVER_REQUEST_ACCEPTED_NEW, SERVER_REQUEST_NEW, and TRACE.
Referenced by css_init(), css_reestablish_connection_to_master(), and hb_connect_to_master().
int css_receive_heartbeat_data | ( | CSS_CONN_ENTRY * | conn, |
char * | data, | ||
int | size | ||
) |
Definition at line 230 of file heartbeat.c.
References CONNECTION_CLOSED, css_readn(), ERROR_ON_READ, css_conn_entry::fd, IS_INVALID_SOCKET, NO_ERRORS, THREAD_CALLING_CONVENTION, and THREAD_RET_T.
Referenced by css_process_deregister_ha_process(), hb_register_new_process(), hb_resource_receive_changemode(), and hb_resource_receive_get_eof().
int css_receive_heartbeat_request | ( | CSS_CONN_ENTRY * | conn, |
int * | command | ||
) |
Definition at line 202 of file heartbeat.c.
References CONNECTION_CLOSED, css_readn(), ERROR_ON_READ, css_conn_entry::fd, IS_INVALID_SOCKET, NO_ERRORS, and ntohl().
Referenced by css_process_heartbeat_request(), and hb_process_master_request_info().
int css_send_heartbeat_data | ( | CSS_CONN_ENTRY * | conn, |
const char * | data, | ||
int | size | ||
) |
Definition at line 178 of file heartbeat.c.
References CONNECTION_CLOSED, ERROR_ON_WRITE, css_conn_entry::fd, IS_INVALID_SOCKET, and NO_ERRORS.
Referenced by css_process_change_server_ha_mode_request(), css_process_get_eof_request(), hb_deregister_from_master(), hb_register_to_master(), and hb_resource_send_changemode().
int css_send_heartbeat_request | ( | CSS_CONN_ENTRY * | conn, |
int | command | ||
) |
Definition at line 151 of file heartbeat.c.
References CONNECTION_CLOSED, ERROR_ON_WRITE, css_conn_entry::fd, htonl(), IS_INVALID_SOCKET, and NO_ERRORS.
Referenced by css_process_change_server_ha_mode_request(), css_process_get_eof_request(), hb_deregister_from_master(), hb_register_to_master(), hb_resource_send_changemode(), and hb_resource_send_get_eof().
void css_shutdown_conn | ( | CSS_CONN_ENTRY * | conn | ) |
Definition at line 127 of file connection_cl.c.
References css_conn_entry::abort_queue, assert, css_conn_entry::buffer_queue, CONN_CLOSED, CONN_CLOSING, CONN_OPEN, css_finalize_list(), css_free_net_header_list(), css_free_queue_entry_list(), css_free_wait_queue_list(), css_remove_all_unexpected_packets(), css_shutdown_socket(), css_conn_entry::data_queue, DB_EMPTY_SESSION, css_conn_entry::error_queue, css_conn_entry::fd, free_and_init, INVALID_SOCKET, IS_INVALID_SOCKET, NO_ERROR, NULL, css_conn_entry::request_queue, rmutex_lock, rmutex_unlock, css_conn_entry::session_id, css_conn_entry::status, and THREAD_STOP_WORKERS_EXCEPT_LOGWR.
Referenced by css_close_conn(), css_close_connection_to_master(), css_final_conn_list(), css_free_conn(), css_master_thread(), css_read_header(), css_refuse_connection_request(), css_send_close_request(), css_send_io_vector(), and hb_process_term().
|
static |
Definition at line 579 of file heartbeat.c.
References css_connect_to_master_server(), css_conn_entry::fd, free_and_init, hb_pack_server_name(), hb_Pipe_to_master, NULL, and prm_get_master_port_id().
Referenced by hb_process_init().
|
static |
Definition at line 609 of file heartbeat.c.
References ARG_FILE_LINE, ER_CSS_PTHREAD_ATTR_INIT, ER_CSS_PTHREAD_ATTR_SETDETACHSTATE, ER_CSS_PTHREAD_ATTR_SETSCOPE, ER_CSS_PTHREAD_ATTR_SETSTACKSIZE, ER_CSS_PTHREAD_CREATE, ER_ERROR_SEVERITY, ER_FAILED, er_set_with_oserror(), hb_thread_master_reader(), NO_ERROR, NULL, prm_get_bigint_value(), prm_get_bool_value(), PRM_ID_PTHREAD_SCOPE_PROCESS, PRM_ID_THREAD_STACKSIZE, and rv.
Referenced by hb_process_init().
int hb_deregister_from_master | ( | void | ) |
Definition at line 321 of file heartbeat.c.
References css_send_heartbeat_data(), css_send_heartbeat_request(), ER_FAILED, css_conn_entry::fd, htonl(), IS_INVALID_SOCKET, NO_ERROR, NO_ERRORS, NULL, pid, and SERVER_DEREGISTER_HA_PROCESS.
|
static |
Definition at line 286 of file heartbeat.c.
References ARG_FILE_LINE, hbp_proc_register::args, argv, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), hbp_proc_register::exec_path, hb_Argv, hb_Exec_path, htonl(), NULL, p, hbp_proc_register::pid, strncpy_bufsize, and hbp_proc_register::type.
Referenced by hb_register_to_master().
const char* hb_node_state_string | ( | HB_NODE_STATE_TYPE | nstate | ) |
Definition at line 752 of file heartbeat.c.
References HB_NSTATE_MASTER, HB_NSTATE_MASTER_STR, HB_NSTATE_REPLICA, HB_NSTATE_REPLICA_STR, HB_NSTATE_SLAVE, HB_NSTATE_SLAVE_STR, HB_NSTATE_TO_BE_MASTER, HB_NSTATE_TO_BE_MASTER_STR, HB_NSTATE_TO_BE_SLAVE, HB_NSTATE_TO_BE_SLAVE_STR, HB_NSTATE_UNKNOWN, and HB_NSTATE_UNKNOWN_STR.
|
static |
Definition at line 510 of file heartbeat.c.
References ARG_FILE_LINE, assert, envvar_root(), ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), free_and_init, HB_PTYPE_APPLYLOGDB, HB_PTYPE_COPYLOGDB, NULL, rel_major_release_string(), and strlen.
Referenced by hb_connect_to_master().
int hb_process_init | ( | const char * | server_name, |
const char * | log_path, | ||
HB_PROC_TYPE | type | ||
) |
Definition at line 682 of file heartbeat.c.
References ARG_FILE_LINE, ER_FAILED, er_log_debug, error(), hb_Argv, hb_connect_to_master(), hb_create_master_reader(), hb_Exec_path, hb_register_to_master(), hb_type_to_str(), and NO_ERROR.
Referenced by applylogdb(), and copylogdb().
int hb_process_master_request | ( | void | ) |
Definition at line 447 of file heartbeat.c.
References ARG_FILE_LINE, css_platform_independent_poll(), ER_FAILED, er_log_debug, error(), css_conn_entry::fd, hb_Proc_shutdown, hb_process_master_request_info(), IS_INVALID_SOCKET, NO_ERROR, NULL, prm_get_integer_value(), and PRM_ID_TCP_CONNECTION_TIMEOUT.
Referenced by hb_thread_master_reader().
|
static |
Definition at line 402 of file heartbeat.c.
References ARG_FILE_LINE, css_receive_heartbeat_request(), ER_FAILED, er_log_debug, NO_ERROR, NO_ERRORS, NULL, and rc.
Referenced by hb_process_master_request().
void hb_process_term | ( | void | ) |
Definition at line 735 of file heartbeat.c.
References css_shutdown_conn(), hb_Proc_shutdown, and NULL.
Referenced by hb_thread_master_reader().
const char* hb_process_type_string | ( | int | ptype | ) |
Definition at line 104 of file heartbeat.c.
References HB_PTYPE_APPLYLOGDB, HB_PTYPE_APPLYLOGDB_STR, HB_PTYPE_COPYLOGDB, HB_PTYPE_COPYLOGDB_STR, HB_PTYPE_SERVER, and HB_PTYPE_SERVER_STR.
Referenced by hb_help_sprint_processes_info().
int hb_register_to_master | ( | CSS_CONN_ENTRY * | conn, |
int | type | ||
) |
Definition at line 355 of file heartbeat.c.
References ARG_FILE_LINE, css_send_heartbeat_data(), css_send_heartbeat_request(), ER_FAILED, er_log_debug, error(), css_conn_entry::fd, free_and_init, hb_make_set_hbp_register(), IS_INVALID_SOCKET, NO_ERROR, NO_ERRORS, NULL, and SERVER_REGISTER_HA_PROCESS.
Referenced by css_init(), and hb_process_init().
void hb_set_argv | ( | char ** | argv | ) |
Definition at line 137 of file heartbeat.c.
Referenced by applylogdb(), copylogdb(), and main().
void hb_set_exec_path | ( | char * | exec_path | ) |
Definition at line 125 of file heartbeat.c.
References hb_Exec_path.
Referenced by applylogdb(), copylogdb(), and main().
|
static |
Definition at line 253 of file heartbeat.c.
References error(), hb_process_master_request(), hb_process_term(), NO_ERROR, and THREAD_RET_T.
Referenced by hb_create_master_reader().
|
static |
Definition at line 424 of file heartbeat.c.
References HB_PTYPE_APPLYLOGDB, and HB_PTYPE_COPYLOGDB.
Referenced by hb_process_init().
|
static |
Definition at line 91 of file heartbeat.c.
Referenced by hb_make_set_hbp_register(), hb_process_init(), and hb_set_argv().
|
static |
Definition at line 89 of file heartbeat.c.
|
static |
Definition at line 90 of file heartbeat.c.
Referenced by hb_make_set_hbp_register(), hb_process_init(), and hb_set_exec_path().
|
static |
Definition at line 87 of file heartbeat.c.
SOCKET hb_Pipe_to_master = INVALID_SOCKET |
Definition at line 95 of file heartbeat.c.
Referenced by hb_connect_to_master().
bool hb_Proc_shutdown = false |
Definition at line 93 of file heartbeat.c.
Referenced by applylogdb(), copylogdb(), hb_process_master_request(), hb_process_term(), and la_apply_log_file().