CUBRID Engine  latest
heartbeat.h File Reference
#include "connection_defs.h"
Include dependency graph for heartbeat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hbp_header
 
struct  hbp_proc_register
 

Macros

#define HB_DEFAULT_HA_PORT_ID   (59901)
 
#define HB_DEFAULT_APPLY_MAX_MEM_SIZE   (500)
 
#define HB_DEFAULT_INIT_TIMER_IN_MSECS   (10*1000)
 
#define HB_DEFAULT_HEARTBEAT_INTERVAL_IN_MSECS   (500)
 
#define HB_DEFAULT_CALC_SCORE_INTERVAL_IN_MSECS   (3*1000)
 
#define HB_DEFAULT_CHECK_VALID_PING_SERVER_INTERVAL_IN_MSECS   (1*60*60*1000)
 
#define HB_TEMP_CHECK_VALID_PING_SERVER_INTERVAL_IN_MSECS   (5*60*1000)
 
#define HB_DEFAULT_FAILOVER_WAIT_TIME_IN_MSECS   (3*1000)
 
#define HB_DEFAULT_START_CONFIRM_INTERVAL_IN_MSECS   (3*1000)
 
#define HB_DEFAULT_DEREG_CONFIRM_INTERVAL_IN_MSECS   (500)
 
#define HB_DEFAULT_MAX_PROCESS_START_CONFIRM   (20)
 
#define HB_DEFAULT_MAX_PROCESS_DEREG_CONFIRM   (120)
 
#define HB_DEFAULT_UNACCEPTABLE_PROC_RESTART_TIMEDIFF_IN_MSECS   (2*60*1000)
 
#define HB_DEFAULT_CHANGEMODE_INTERVAL_IN_MSECS   (5*1000)
 
#define HB_DEFAULT_MAX_HEARTBEAT_GAP   (5)
 
#define HB_MIN_DIFF_CHECK_DISK_FAILURE_INTERVAL_IN_SECS   (10)
 
#define HB_JOB_TIMER_IMMEDIATELY   (0)
 
#define HB_JOB_TIMER_WAIT_A_SECOND   (1*1000)
 
#define HB_JOB_TIMER_WAIT_500_MILLISECOND   (5*100)
 
#define HB_JOB_TIMER_WAIT_100_MILLISECOND   (1*100)
 
#define HB_DISK_FAILURE_CHECK_TIMER_IN_MSECS   (1*100)
 
#define HB_START_WAITING_TIME_IN_SECS   (10)
 
#define HB_STOP_WAITING_TIME_IN_SECS   (1)
 
#define HB_PTYPE_SERVER_STR   "HA-server"
 
#define HB_PTYPE_COPYLOGDB_STR   "HA-copylogdb"
 
#define HB_PTYPE_APPLYLOGDB_STR   "HA-applylogdb"
 
#define HB_PTYPE_STR_SZ   (16)
 
#define HB_MAX_GROUP_ID_LEN   (64)
 
#define HB_MAX_SZ_PROC_EXEC_PATH   (128)
 
#define HB_MAX_NUM_PROC_ARGV   (16)
 
#define HB_MAX_SZ_PROC_ARGV   (64)
 
#define HB_MAX_SZ_PROC_ARGS   (HB_MAX_NUM_PROC_ARGV*HB_MAX_SZ_PROC_ARGV)
 
#define HB_NSTATE_UNKNOWN_STR   "unknown"
 
#define HB_NSTATE_SLAVE_STR   "slave"
 
#define HB_NSTATE_TO_BE_MASTER_STR   "to-be-master"
 
#define HB_NSTATE_TO_BE_SLAVE_STR   "to-be-slave"
 
#define HB_NSTATE_MASTER_STR   "master"
 
#define HB_NSTATE_REPLICA_STR   "replica"
 
#define HB_NSTATE_STR_SZ   (32)
 

Typedefs

typedef enum hb_proc_type HB_PROC_TYPE
 
typedef enum HB_NODE_STATE HB_NODE_STATE_TYPE
 
typedef struct hbp_header HBP_HEADER
 
typedef struct hbp_proc_register HBP_PROC_REGISTER
 

Enumerations

enum  hb_proc_type { HB_PTYPE_SERVER = 0, HB_PTYPE_COPYLOGDB = 1, HB_PTYPE_APPLYLOGDB = 2, HB_PTYPE_MAX }
 
enum  HBP_CLUSTER_MESSAGE { HBP_CLUSTER_HEARTBEAT = 0, HBP_CLUSTER_MSG_MAX }
 
enum  HB_NODE_STATE {
  HB_NSTATE_UNKNOWN = 0, HB_NSTATE_SLAVE = 1, HB_NSTATE_TO_BE_MASTER = 2, HB_NSTATE_TO_BE_SLAVE = 3,
  HB_NSTATE_MASTER = 4, HB_NSTATE_REPLICA = 5, HB_NSTATE_MAX
}
 

Functions

const char * hb_process_type_string (int ptype)
 
void hb_set_exec_path (char *exec_path)
 
void hb_set_argv (char **argv)
 
int css_send_heartbeat_request (CSS_CONN_ENTRY *conn, int command)
 
int css_send_heartbeat_data (CSS_CONN_ENTRY *conn, const char *data, int size)
 
int css_receive_heartbeat_request (CSS_CONN_ENTRY *conn, int *command)
 
int css_receive_heartbeat_data (CSS_CONN_ENTRY *conn, char *data, int size)
 
int hb_process_master_request (void)
 
int hb_register_to_master (CSS_CONN_ENTRY *conn, int type)
 
int hb_deregister_from_master (void)
 
int hb_process_init (const char *server_name, const char *log_path, HB_PROC_TYPE type)
 
void hb_process_term (void)
 
const char * hb_node_state_string (HB_NODE_STATE_TYPE nstate)
 

Variables

bool hb_Proc_shutdown
 

Macro Definition Documentation

#define HB_DEFAULT_APPLY_MAX_MEM_SIZE   (500)

Definition at line 33 of file heartbeat.h.

#define HB_DEFAULT_CALC_SCORE_INTERVAL_IN_MSECS   (3*1000)

Definition at line 37 of file heartbeat.h.

#define HB_DEFAULT_CHANGEMODE_INTERVAL_IN_MSECS   (5*1000)

Definition at line 46 of file heartbeat.h.

#define HB_DEFAULT_CHECK_VALID_PING_SERVER_INTERVAL_IN_MSECS   (1*60*60*1000)

Definition at line 38 of file heartbeat.h.

Referenced by hb_cluster_job_check_valid_ping_server().

#define HB_DEFAULT_DEREG_CONFIRM_INTERVAL_IN_MSECS   (500)

Definition at line 42 of file heartbeat.h.

#define HB_DEFAULT_FAILOVER_WAIT_TIME_IN_MSECS   (3*1000)

Definition at line 40 of file heartbeat.h.

#define HB_DEFAULT_HA_PORT_ID   (59901)

Definition at line 32 of file heartbeat.h.

#define HB_DEFAULT_HEARTBEAT_INTERVAL_IN_MSECS   (500)

Definition at line 36 of file heartbeat.h.

#define HB_DEFAULT_INIT_TIMER_IN_MSECS   (10*1000)

Definition at line 35 of file heartbeat.h.

#define HB_DEFAULT_MAX_HEARTBEAT_GAP   (5)

Definition at line 47 of file heartbeat.h.

#define HB_DEFAULT_MAX_PROCESS_DEREG_CONFIRM   (120)

Definition at line 44 of file heartbeat.h.

#define HB_DEFAULT_MAX_PROCESS_START_CONFIRM   (20)

Definition at line 43 of file heartbeat.h.

#define HB_DEFAULT_START_CONFIRM_INTERVAL_IN_MSECS   (3*1000)

Definition at line 41 of file heartbeat.h.

#define HB_DEFAULT_UNACCEPTABLE_PROC_RESTART_TIMEDIFF_IN_MSECS   (2*60*1000)

Definition at line 45 of file heartbeat.h.

#define HB_DISK_FAILURE_CHECK_TIMER_IN_MSECS   (1*100)

Definition at line 54 of file heartbeat.h.

Referenced by hb_thread_check_disk_failure().

#define HB_JOB_TIMER_WAIT_100_MILLISECOND   (1*100)

Definition at line 53 of file heartbeat.h.

Referenced by hb_cluster_job_calc_score().

#define HB_JOB_TIMER_WAIT_500_MILLISECOND   (5*100)
#define HB_JOB_TIMER_WAIT_A_SECOND   (1*1000)
#define HB_MAX_GROUP_ID_LEN   (64)

Definition at line 79 of file heartbeat.h.

Referenced by hb_get_node_info_string().

#define HB_MAX_NUM_PROC_ARGV   (16)

Definition at line 81 of file heartbeat.h.

Referenced by hb_resource_job_proc_start(), and hb_start_util_process().

#define HB_MAX_SZ_PROC_ARGV   (64)

Definition at line 82 of file heartbeat.h.

Referenced by hb_start_util_process().

#define HB_MAX_SZ_PROC_EXEC_PATH   (128)

Definition at line 80 of file heartbeat.h.

Referenced by hb_get_process_info_string().

#define HB_MIN_DIFF_CHECK_DISK_FAILURE_INTERVAL_IN_SECS   (10)

Definition at line 48 of file heartbeat.h.

Referenced by prm_tune_parameters().

#define HB_NSTATE_MASTER_STR   "master"

Definition at line 101 of file heartbeat.h.

Referenced by hb_node_state_string().

#define HB_NSTATE_REPLICA_STR   "replica"

Definition at line 102 of file heartbeat.h.

Referenced by hb_node_state_string().

#define HB_NSTATE_SLAVE_STR   "slave"

Definition at line 98 of file heartbeat.h.

Referenced by hb_node_state_string().

#define HB_NSTATE_STR_SZ   (32)

Definition at line 104 of file heartbeat.h.

Referenced by hb_get_node_info_string(), and hb_get_process_info_string().

#define HB_NSTATE_TO_BE_MASTER_STR   "to-be-master"

Definition at line 99 of file heartbeat.h.

Referenced by hb_node_state_string().

#define HB_NSTATE_TO_BE_SLAVE_STR   "to-be-slave"

Definition at line 100 of file heartbeat.h.

Referenced by hb_node_state_string().

#define HB_NSTATE_UNKNOWN_STR   "unknown"

Definition at line 97 of file heartbeat.h.

Referenced by hb_node_state_string().

#define HB_PTYPE_APPLYLOGDB_STR   "HA-applylogdb"

Definition at line 70 of file heartbeat.h.

Referenced by hb_process_type_string().

#define HB_PTYPE_COPYLOGDB_STR   "HA-copylogdb"

Definition at line 69 of file heartbeat.h.

Referenced by hb_process_type_string().

#define HB_PTYPE_SERVER_STR   "HA-server"

Definition at line 68 of file heartbeat.h.

Referenced by hb_process_type_string().

#define HB_PTYPE_STR_SZ   (16)

Definition at line 71 of file heartbeat.h.

#define HB_START_WAITING_TIME_IN_SECS   (10)
#define HB_STOP_WAITING_TIME_IN_SECS   (1)

Definition at line 57 of file heartbeat.h.

Referenced by process_heartbeat_stop().

#define HB_TEMP_CHECK_VALID_PING_SERVER_INTERVAL_IN_MSECS   (5*60*1000)

Definition at line 39 of file heartbeat.h.

Referenced by hb_cluster_job_check_valid_ping_server().

Typedef Documentation

Definition at line 106 of file heartbeat.h.

typedef enum hb_proc_type HB_PROC_TYPE

Definition at line 67 of file heartbeat.h.

typedef struct hbp_header HBP_HEADER

Definition at line 113 of file heartbeat.h.

Definition at line 137 of file heartbeat.h.

Enumeration Type Documentation

Enumerator
HB_NSTATE_UNKNOWN 
HB_NSTATE_SLAVE 
HB_NSTATE_TO_BE_MASTER 
HB_NSTATE_TO_BE_SLAVE 
HB_NSTATE_MASTER 
HB_NSTATE_REPLICA 
HB_NSTATE_MAX 

Definition at line 86 of file heartbeat.h.

Enumerator
HB_PTYPE_SERVER 
HB_PTYPE_COPYLOGDB 
HB_PTYPE_APPLYLOGDB 
HB_PTYPE_MAX 

Definition at line 60 of file heartbeat.h.

Enumerator
HBP_CLUSTER_HEARTBEAT 
HBP_CLUSTER_MSG_MAX 

Definition at line 73 of file heartbeat.h.

Function Documentation

int css_receive_heartbeat_data ( CSS_CONN_ENTRY conn,
char *  data,
int  size 
)
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().

Here is the caller graph for this function:

int css_send_heartbeat_data ( CSS_CONN_ENTRY conn,
const char *  data,
int  size 
)
int css_send_heartbeat_request ( CSS_CONN_ENTRY conn,
int  command 
)
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().

Here is the caller graph for this function:

int hb_process_master_request ( void  )
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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

int hb_register_to_master ( CSS_CONN_ENTRY conn,
int  type 
)
void hb_set_argv ( char **  argv)

Definition at line 137 of file heartbeat.c.

References argv, and hb_Argv.

Referenced by applylogdb(), copylogdb(), and main().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

Variable Documentation

bool hb_Proc_shutdown