CUBRID Engine  latest
master_heartbeat.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <errno.h>
#include <sys/wait.h>
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <syslog.h>
#include "connection_cl.h"
#include "dbi.h"
#include "environment_variable.h"
#include "error_context.hpp"
#include "heartbeat.h"
#include "master_util.h"
#include "master_heartbeat.h"
#include "master_request.h"
#include "message_catalog.h"
#include "object_representation.h"
#include "porting.h"
#include "tcp.h"
#include "utility.h"

Go to the source code of this file.

Classes

struct  hb_deactivate_info
 

Macros

#define HB_INFO_STR_MAX   8192
 
#define SERVER_DEREG_MAX_POLL_COUNT   10
 
#define ENTER_FUNC()
 
#define EXIT_FUNC()
 
#define HA_NODE_INFO_FORMAT_STRING   " HA-Node Info (current %s, state %s)\n"
 
#define HA_NODE_FORMAT_STRING   " Node %s (priority %d, state %s)\n"
 
#define HA_UI_NODE_FORMAT_STRING   " * Node %s (ip %s, group %s, state %s)\n"
 
#define HA_NODE_SCORE_FORMAT_STRING   " - score %d\n"
 
#define HA_NODE_HEARTBEAT_GAP_FORMAT_STRING   " - missed heartbeat %d\n"
 
#define HA_PROCESS_INFO_FORMAT_STRING   " HA-Process Info (master %d, state %s)\n"
 
#define HA_SERVER_PROCESS_FORMAT_STRING   " Server %s (pid %d, state %s)\n"
 
#define HA_COPYLOG_PROCESS_FORMAT_STRING   " Copylogdb %s (pid %d, state %s)\n"
 
#define HA_APPLYLOG_PROCESS_FORMAT_STRING   " Applylogdb %s (pid %d, state %s)\n"
 
#define HA_PROCESS_EXEC_PATH_FORMAT_STRING   " - exec-path [%s] \n"
 
#define HA_PROCESS_ARGV_FORMAT_STRING   " - argv [%s] \n"
 
#define HA_PROCESS_REGISTER_TIME_FORMAT_STRING   " - registered-time %s\n"
 
#define HA_PROCESS_DEREGISTER_TIME_FORMAT_STRING   " - deregistered-time %s\n"
 
#define HA_PROCESS_SHUTDOWN_TIME_FORMAT_STRING   " - shutdown-time %s\n"
 
#define HA_PROCESS_START_TIME_FORMAT_STRING   " - start-time %s\n"
 
#define HA_PING_HOSTS_INFO_FORMAT_STRING   " HA-Ping Host Info (PING check %s)\n"
 
#define HA_PING_HOSTS_FORMAT_STRING   " %-20s %s\n"
 
#define HA_ADMIN_INFO_FORMAT_STRING   " HA-Admin Info\n"
 
#define HA_ADMIN_INFO_NOLOG_FORMAT_STRING   " Error Logging: disabled\n"
 
#define HA_ADMIN_INFO_NOLOG_EVENT_FORMAT_STRING   " %s\n"
 
#define PING_COMMAND_FORMAT
 

Typedefs

typedef struct hb_deactivate_info HB_DEACTIVATE_INFO
 

Functions

static void hb_list_add (HB_LIST **p, HB_LIST *n)
 
static void hb_list_remove (HB_LIST *n)
 
static void hb_list_move (HB_LIST **dest_pp, HB_LIST **source_pp)
 
static void hb_add_timeval (struct timeval *tv_p, unsigned int msec)
 
static int hb_compare_timeval (struct timeval *arg1, struct timeval *arg2)
 
static const char * hb_strtime (char *s, unsigned int max, struct timeval *tv_p)
 
static int hb_job_queue (HB_JOB *jobs, unsigned int job_type, HB_JOB_ARG *arg, unsigned int msec)
 
static HB_JOB_ENTRYhb_job_dequeue (HB_JOB *jobs)
 
static void hb_job_set_expire_and_reorder (HB_JOB *jobs, unsigned int job_type, unsigned int msec)
 
static void hb_job_shutdown (HB_JOB *jobs)
 
static void hb_cluster_job_init (HB_JOB_ARG *arg)
 
static void hb_cluster_job_heartbeat (HB_JOB_ARG *arg)
 
static void hb_cluster_job_calc_score (HB_JOB_ARG *arg)
 
static void hb_cluster_job_failover (HB_JOB_ARG *arg)
 
static void hb_cluster_job_failback (HB_JOB_ARG *arg)
 
static void hb_cluster_job_check_ping (HB_JOB_ARG *arg)
 
static void hb_cluster_job_check_valid_ping_server (HB_JOB_ARG *arg)
 
static void hb_cluster_job_demote (HB_JOB_ARG *arg)
 
static void hb_cluster_request_heartbeat_to_all (void)
 
static int hb_cluster_send_heartbeat_req (char *dest_host_name)
 
static int hb_cluster_send_heartbeat_resp (struct sockaddr_in *saddr, socklen_t saddr_len, char *dest_host_name)
 
static int hb_cluster_send_heartbeat_internal (struct sockaddr_in *saddr, socklen_t saddr_len, char *dest_host_name, bool is_req)
 
static void hb_cluster_receive_heartbeat (char *buffer, int len, struct sockaddr_in *from, socklen_t from_len)
 
static bool hb_cluster_is_isolated (void)
 
static bool hb_cluster_is_received_heartbeat_from_all (void)
 
static bool hb_cluster_check_valid_ping_server (void)
 
static int hb_cluster_calc_score (void)
 
static int hb_set_net_header (HBP_HEADER *header, unsigned char type, bool is_req, unsigned short len, unsigned int seq, char *dest_host_name)
 
static int hb_hostname_to_sin_addr (const char *host, struct in_addr *addr)
 
static int hb_hostname_n_port_to_sockaddr (const char *host, int port, struct sockaddr *saddr, socklen_t *slen)
 
static int hb_check_ping (const char *host)
 
static HB_JOB_ENTRYhb_cluster_job_dequeue (void)
 
static int hb_cluster_job_queue (unsigned int job_type, HB_JOB_ARG *arg, unsigned int msec)
 
static int hb_cluster_job_set_expire_and_reorder (unsigned int job_type, unsigned int msec)
 
static void hb_cluster_job_shutdown (void)
 
static HB_NODE_ENTRYhb_add_node_to_cluster (char *host_name, unsigned short priority)
 
static void hb_remove_node (HB_NODE_ENTRY *entry_p)
 
static void hb_cluster_remove_all_nodes (HB_NODE_ENTRY *first)
 
static HB_NODE_ENTRYhb_return_node_by_name (char *name)
 
static HB_NODE_ENTRYhb_return_node_by_name_except_me (char *name)
 
static HB_UI_NODE_ENTRYhb_return_ui_node (char *host_name, char *group_id, struct sockaddr_in saddr)
 
static HB_UI_NODE_ENTRYhb_add_ui_node (char *host_name, char *group_id, struct sockaddr_in saddr, int state)
 
static void hb_remove_ui_node (HB_UI_NODE_ENTRY *node)
 
static void hb_cleanup_ui_nodes (HB_UI_NODE_ENTRY *first)
 
static void hb_cluster_remove_all_ui_nodes (HB_UI_NODE_ENTRY *first)
 
static int hb_is_heartbeat_valid (char *host_name, char *group_id, struct sockaddr_in *from)
 
static const char * hb_valid_result_string (int v_result)
 
static int hb_cluster_load_group_and_node_list (char *ha_node_list, char *ha_replica_list)
 
static HB_PING_HOST_ENTRYhb_add_ping_host (char *host_name)
 
static void hb_remove_ping_host (HB_PING_HOST_ENTRY *entry_p)
 
static void hb_cluster_remove_all_ping_hosts (HB_PING_HOST_ENTRY *first)
 
static void hb_resource_job_proc_start (HB_JOB_ARG *arg)
 
static void hb_resource_job_proc_dereg (HB_JOB_ARG *arg)
 
static void hb_resource_job_confirm_start (HB_JOB_ARG *arg)
 
static void hb_resource_job_confirm_dereg (HB_JOB_ARG *arg)
 
static void hb_resource_job_change_mode (HB_JOB_ARG *arg)
 
static void hb_resource_job_demote_start_shutdown (HB_JOB_ARG *arg)
 
static void hb_resource_job_demote_confirm_shutdown (HB_JOB_ARG *arg)
 
static void hb_resource_job_cleanup_all (HB_JOB_ARG *arg)
 
static void hb_resource_job_confirm_cleanup_all (HB_JOB_ARG *arg)
 
static void hb_resource_demote_start_shutdown_server_proc (void)
 
static bool hb_resource_demote_confirm_shutdown_server_proc (void)
 
static void hb_resource_demote_kill_server_proc (void)
 
static HB_JOB_ENTRYhb_resource_job_dequeue (void)
 
static int hb_resource_job_queue (unsigned int job_type, HB_JOB_ARG *arg, unsigned int msec)
 
static int hb_resource_job_set_expire_and_reorder (unsigned int job_type, unsigned int msec)
 
static void hb_resource_job_shutdown (void)
 
static HB_PROC_ENTRYhb_alloc_new_proc (void)
 
static void hb_remove_proc (HB_PROC_ENTRY *entry_p)
 
static void hb_remove_all_procs (HB_PROC_ENTRY *first)
 
static HB_PROC_ENTRYhb_return_proc_by_args (char *args)
 
static HB_PROC_ENTRYhb_return_proc_by_pid (int pid)
 
static HB_PROC_ENTRYhb_return_proc_by_fd (int sfd)
 
static void hb_proc_make_arg (char **arg, char *args)
 
static HB_JOB_ARGhb_deregister_process (HB_PROC_ENTRY *proc)
 
static int hb_resource_send_changemode (HB_PROC_ENTRY *proc)
 
static void hb_resource_send_get_eof (void)
 
static bool hb_resource_check_server_log_grow (void)
 
static void * hb_thread_cluster_worker (void *arg)
 
static void * hb_thread_cluster_reader (void *arg)
 
static void * hb_thread_resource_worker (void *arg)
 
static void * hb_thread_check_disk_failure (void *arg)
 
static int hb_cluster_initialize (const char *nodes, const char *replicas)
 
static int hb_cluster_job_initialize (void)
 
static int hb_resource_initialize (void)
 
static int hb_resource_job_initialize (void)
 
static int hb_thread_initialize (void)
 
static void hb_resource_cleanup (void)
 
static void hb_resource_shutdown_all_ha_procs (void)
 
static void hb_cluster_cleanup (void)
 
static void hb_kill_process (pid_t *pids, int count)
 
static const char * hb_node_state_string (int nstate)
 
static const char * hb_process_state_string (unsigned char ptype, int pstate)
 
static const char * hb_ping_result_string (int ping_result)
 
static int hb_reload_config (void)
 
static int hb_help_sprint_processes_info (char *buffer, int max_length)
 
static int hb_help_sprint_nodes_info (char *buffer, int max_length)
 
static int hb_help_sprint_jobs_info (HB_JOB *jobs, char *buffer, int max_length)
 
static int hb_help_sprint_ping_host_info (char *buffer, int max_length)
 
static int hb_cluster_load_ping_host_list (char *ha_ping_host_list)
 
void hb_cleanup_conn_and_start_process (CSS_CONN_ENTRY *conn, SOCKET sfd)
 
bool hb_is_registered_process (CSS_CONN_ENTRY *conn, char *args)
 
void hb_register_new_process (CSS_CONN_ENTRY *conn)
 
void hb_resource_receive_changemode (CSS_CONN_ENTRY *conn)
 
void hb_resource_receive_get_eof (CSS_CONN_ENTRY *conn)
 
int hb_master_init (void)
 
void hb_resource_shutdown_and_cleanup (void)
 
void hb_cluster_shutdown_and_cleanup (void)
 
void hb_get_admin_info_string (char **str)
 
void hb_get_ping_host_info_string (char **str)
 
void hb_get_node_info_string (char **str, bool verbose_yn)
 
void hb_get_process_info_string (char **str, bool verbose_yn)
 
void hb_kill_all_heartbeat_process (char **str)
 
void hb_deregister_by_pid (pid_t pid)
 
void hb_deregister_by_args (char *args)
 
void hb_reconfig_heartbeat (char **str)
 
int hb_prepare_deactivate_heartbeat (void)
 
int hb_deactivate_heartbeat (void)
 
int hb_activate_heartbeat (void)
 
int hb_start_util_process (char *args)
 
void hb_enable_er_log (void)
 
void hb_disable_er_log (int reason, const char *msg_fmt,...)
 
int hb_check_request_eligibility (SOCKET sd)
 
void hb_start_deactivate_server_info (void)
 
bool hb_is_deactivation_started (void)
 
bool hb_is_deactivation_ready (void)
 
int hb_get_deactivating_server_count (void)
 
void hb_finish_deactivate_server_info (void)
 
int hb_return_proc_state_by_fd (int sfd)
 
bool hb_is_hang_process (int sfd)
 

Variables

HB_CLUSTERhb_Cluster = NULL
 
HB_RESOURCEhb_Resource = NULL
 
HB_JOBcluster_Jobs = NULL
 
HB_JOBresource_Jobs = NULL
 
bool hb_Deactivate_immediately = false
 
static char hb_Nolog_event_msg [LINE_MAX] = ""
 
static HB_DEACTIVATE_INFO hb_Deactivate_info = { NULL, 0, false }
 
static bool hb_Is_activated = true
 
static HB_JOB_FUNC hb_cluster_jobs []
 
static HB_JOB_FUNC hb_resource_jobs []
 

Macro Definition Documentation

#define ENTER_FUNC ( )
Value:
do { \
MASTER_ER_LOG_DEBUG (ARG_FILE_LINE, "%s : enter", __func__); \
} while(0);
#define MASTER_ER_LOG_DEBUG(...)
Definition: master_util.h:65
#define ARG_FILE_LINE
Definition: error_manager.h:44

Definition at line 66 of file master_heartbeat.c.

Referenced by hb_cluster_job_calc_score(), hb_cluster_job_check_ping(), hb_cluster_job_demote(), hb_cluster_job_failback(), and hb_cluster_job_failover().

#define EXIT_FUNC ( )
Value:
do { \
MASTER_ER_LOG_DEBUG (ARG_FILE_LINE, "%s : exit", __func__); \
} while(0);
#define MASTER_ER_LOG_DEBUG(...)
Definition: master_util.h:65
#define ARG_FILE_LINE
Definition: error_manager.h:44

Definition at line 71 of file master_heartbeat.c.

Referenced by hb_cluster_job_check_ping().

#define HA_ADMIN_INFO_FORMAT_STRING   " HA-Admin Info\n"

Definition at line 316 of file master_heartbeat.c.

Referenced by hb_get_admin_info_string().

#define HA_ADMIN_INFO_NOLOG_EVENT_FORMAT_STRING   " %s\n"

Definition at line 320 of file master_heartbeat.c.

Referenced by hb_get_admin_info_string().

#define HA_ADMIN_INFO_NOLOG_FORMAT_STRING   " Error Logging: disabled\n"

Definition at line 318 of file master_heartbeat.c.

Referenced by hb_get_admin_info_string().

#define HA_APPLYLOG_PROCESS_FORMAT_STRING   " Applylogdb %s (pid %d, state %s)\n"

Definition at line 296 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_COPYLOG_PROCESS_FORMAT_STRING   " Copylogdb %s (pid %d, state %s)\n"

Definition at line 294 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_NODE_FORMAT_STRING   " Node %s (priority %d, state %s)\n"

Definition at line 281 of file master_heartbeat.c.

Referenced by hb_get_node_info_string().

#define HA_NODE_HEARTBEAT_GAP_FORMAT_STRING   " - missed heartbeat %d\n"

Definition at line 287 of file master_heartbeat.c.

Referenced by hb_get_node_info_string().

#define HA_NODE_INFO_FORMAT_STRING   " HA-Node Info (current %s, state %s)\n"

Definition at line 279 of file master_heartbeat.c.

Referenced by hb_get_node_info_string().

#define HA_NODE_SCORE_FORMAT_STRING   " - score %d\n"

Definition at line 285 of file master_heartbeat.c.

Referenced by hb_get_node_info_string().

#define HA_PING_HOSTS_FORMAT_STRING   " %-20s %s\n"

Definition at line 313 of file master_heartbeat.c.

Referenced by hb_get_ping_host_info_string().

#define HA_PING_HOSTS_INFO_FORMAT_STRING   " HA-Ping Host Info (PING check %s)\n"

Definition at line 311 of file master_heartbeat.c.

Referenced by hb_get_ping_host_info_string().

#define HA_PROCESS_ARGV_FORMAT_STRING   " - argv [%s] \n"

Definition at line 300 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_PROCESS_DEREGISTER_TIME_FORMAT_STRING   " - deregistered-time %s\n"

Definition at line 304 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_PROCESS_EXEC_PATH_FORMAT_STRING   " - exec-path [%s] \n"

Definition at line 298 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_PROCESS_INFO_FORMAT_STRING   " HA-Process Info (master %d, state %s)\n"

Definition at line 290 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_PROCESS_REGISTER_TIME_FORMAT_STRING   " - registered-time %s\n"

Definition at line 302 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_PROCESS_SHUTDOWN_TIME_FORMAT_STRING   " - shutdown-time %s\n"

Definition at line 306 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_PROCESS_START_TIME_FORMAT_STRING   " - start-time %s\n"

Definition at line 308 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_SERVER_PROCESS_FORMAT_STRING   " Server %s (pid %d, state %s)\n"

Definition at line 292 of file master_heartbeat.c.

Referenced by hb_get_process_info_string().

#define HA_UI_NODE_FORMAT_STRING   " * Node %s (ip %s, group %s, state %s)\n"

Definition at line 283 of file master_heartbeat.c.

Referenced by hb_get_node_info_string().

#define PING_COMMAND_FORMAT
Value:
"ping -w 1 -c 1 %s >/dev/null 2>&1; " \
"echo $?"

Referenced by hb_check_ping().

#define SERVER_DEREG_MAX_POLL_COUNT   10

Definition at line 64 of file master_heartbeat.c.

Typedef Documentation

Definition at line 76 of file master_heartbeat.c.

Function Documentation

static HB_PING_HOST_ENTRY * hb_add_ping_host ( char *  host_name)
static
static void hb_add_timeval ( struct timeval *  tv_p,
unsigned int  msec 
)
static

Definition at line 394 of file master_heartbeat.c.

References NULL.

Referenced by hb_job_queue(), and hb_job_set_expire_and_reorder().

Here is the caller graph for this function:

void hb_cleanup_conn_and_start_process ( CSS_CONN_ENTRY conn,
SOCKET  sfd 
)
static void hb_cleanup_ui_nodes ( HB_UI_NODE_ENTRY first)
static

Definition at line 2375 of file master_heartbeat.c.

References HB_GET_ELAPSED_TIME, hb_remove_ui_node(), HB_UI_NODE_CLEANUP_TIME_IN_MSECS, hb_ui_node_entry::last_recv_time, hb_ui_node_entry::next, and NULL.

Referenced by hb_get_node_info_string().

Here is the caller graph for this function:

static bool hb_cluster_is_isolated ( void  )
static
static bool hb_cluster_is_received_heartbeat_from_all ( void  )
static
static HB_JOB_ENTRY * hb_cluster_job_dequeue ( void  )
static

Definition at line 1929 of file master_heartbeat.c.

References hb_job_dequeue().

Referenced by hb_thread_cluster_worker().

Here is the caller graph for this function:

static int hb_cluster_job_set_expire_and_reorder ( unsigned int  job_type,
unsigned int  msec 
)
static
static void hb_cluster_job_shutdown ( void  )
static

Definition at line 1980 of file master_heartbeat.c.

References hb_job_shutdown().

Referenced by hb_cluster_shutdown_and_cleanup(), and hb_master_init().

Here is the caller graph for this function:

static int hb_cluster_load_group_and_node_list ( char *  ha_node_list,
char *  ha_replica_list 
)
static
static int hb_cluster_load_ping_host_list ( char *  ha_ping_host_list)
static

Definition at line 2147 of file master_heartbeat.c.

References hb_add_ping_host(), NULL, and strncpy_bufsize.

Referenced by hb_cluster_initialize(), and hb_reload_config().

Here is the caller graph for this function:

static void hb_cluster_remove_all_nodes ( HB_NODE_ENTRY first)
static

Definition at line 2060 of file master_heartbeat.c.

References hb_remove_node(), and hb_node_entry::next.

Referenced by hb_cluster_cleanup(), and hb_reload_config().

Here is the caller graph for this function:

static void hb_cluster_remove_all_ping_hosts ( HB_PING_HOST_ENTRY first)
static

Definition at line 2129 of file master_heartbeat.c.

References hb_remove_ping_host(), host, and hb_ping_host_entry::next.

Referenced by hb_cluster_cleanup(), and hb_reload_config().

Here is the caller graph for this function:

static void hb_cluster_remove_all_ui_nodes ( HB_UI_NODE_ENTRY first)
static

Definition at line 2400 of file master_heartbeat.c.

References hb_remove_ui_node(), hb_ui_node_entry::next, and NULL.

Referenced by hb_cluster_cleanup().

Here is the caller graph for this function:

static int hb_cluster_send_heartbeat_internal ( struct sockaddr_in *  saddr,
socklen_t  saddr_len,
char *  dest_host_name,
bool  is_req 
)
static
static int hb_cluster_send_heartbeat_req ( char *  dest_host_name)
static
static int hb_cluster_send_heartbeat_resp ( struct sockaddr_in *  saddr,
socklen_t  saddr_len,
char *  dest_host_name 
)
static

Definition at line 1570 of file master_heartbeat.c.

References hb_cluster_send_heartbeat_internal().

Referenced by hb_cluster_receive_heartbeat().

Here is the caller graph for this function:

void hb_cluster_shutdown_and_cleanup ( void  )

Definition at line 5128 of file master_heartbeat.c.

References hb_cluster_cleanup(), and hb_cluster_job_shutdown().

Referenced by css_process_kill_master(), and hb_deactivate_heartbeat().

Here is the caller graph for this function:

static int hb_compare_timeval ( struct timeval *  arg1,
struct timeval *  arg2 
)
static

Definition at line 415 of file master_heartbeat.c.

References NULL.

Referenced by hb_job_dequeue(), hb_job_queue(), and hb_job_set_expire_and_reorder().

Here is the caller graph for this function:

void hb_disable_er_log ( int  reason,
const char *  msg_fmt,
  ... 
)
void hb_enable_er_log ( void  )

Definition at line 6252 of file master_heartbeat.c.

References css_Master_er_log_enable_lock, css_Master_er_log_enabled, hb_Nolog_event_msg, pthread_mutex_lock, pthread_mutex_unlock, and rv.

Referenced by hb_master_init().

Here is the caller graph for this function:

void hb_finish_deactivate_server_info ( void  )
int hb_get_deactivating_server_count ( void  )
static int hb_help_sprint_jobs_info ( HB_JOB jobs,
char *  buffer,
int  max_length 
)
static
static int hb_help_sprint_ping_host_info ( char *  buffer,
int  max_length 
)
static
static int hb_hostname_n_port_to_sockaddr ( const char *  host,
int  port,
struct sockaddr *  saddr,
socklen_t *  slen 
)
static

Definition at line 1896 of file master_heartbeat.c.

References error(), hb_hostname_to_sin_addr(), htons(), INVALID_SOCKET, and NO_ERROR.

Referenced by hb_cluster_send_heartbeat_req().

Here is the caller graph for this function:

static int hb_hostname_to_sin_addr ( const char *  host,
struct in_addr *  addr 
)
static
bool hb_is_deactivation_ready ( void  )
bool hb_is_deactivation_started ( void  )

Definition at line 6625 of file master_heartbeat.c.

References hb_deactivate_info::info_started.

Referenced by css_process_deact_stop_all(), and css_send_to_existing_server().

Here is the caller graph for this function:

bool hb_is_hang_process ( int  sfd)

Definition at line 6748 of file master_heartbeat.c.

References hb_return_proc_by_fd(), hb_resource::lock, NULL, pthread_mutex_lock, pthread_mutex_unlock, rv, and HB_PROC_ENTRY::server_hang.

Referenced by css_send_to_existing_server().

Here is the caller graph for this function:

static int hb_is_heartbeat_valid ( char *  host_name,
char *  group_id,
struct sockaddr_in *  from 
)
static
bool hb_is_registered_process ( CSS_CONN_ENTRY conn,
char *  args 
)

Definition at line 3855 of file master_heartbeat.c.

References hb_return_proc_by_args(), hb_resource::lock, NULL, pthread_mutex_lock, pthread_mutex_unlock, and hb_resource::shutdown.

Referenced by css_process_is_registered_ha_proc().

Here is the caller graph for this function:

static HB_JOB_ENTRY * hb_job_dequeue ( HB_JOB jobs)
static

Definition at line 550 of file master_heartbeat.c.

References hb_compare_timeval(), hb_list_remove(), hb_job::jobs, hb_job::lock, NULL, pthread_mutex_lock, pthread_mutex_unlock, rv, and hb_job::shutdown.

Referenced by hb_cluster_job_dequeue(), and hb_resource_job_dequeue().

Here is the caller graph for this function:

static void hb_job_set_expire_and_reorder ( HB_JOB jobs,
unsigned int  job_type,
unsigned int  msec 
)
static
static void hb_job_shutdown ( HB_JOB jobs)
static
static void hb_kill_process ( pid_t *  pids,
int  count 
)
static

Definition at line 5771 of file master_heartbeat.c.

References cubregex::count(), error(), i, and SLEEP_MILISEC.

Referenced by hb_cluster_job_failback().

Here is the caller graph for this function:

static void hb_list_add ( HB_LIST **  p,
HB_LIST n 
)
static

Definition at line 333 of file master_heartbeat.c.

References hb_list::next, p, and hb_list::prev.

Referenced by hb_add_node_to_cluster(), hb_add_ping_host(), hb_add_ui_node(), hb_alloc_new_proc(), hb_job_queue(), and hb_job_set_expire_and_reorder().

Here is the caller graph for this function:

static void hb_list_move ( HB_LIST **  dest_pp,
HB_LIST **  source_pp 
)
static

Definition at line 371 of file master_heartbeat.c.

References NULL, and hb_list::prev.

Referenced by hb_reload_config().

Here is the caller graph for this function:

static void hb_list_remove ( HB_LIST n)
static

Definition at line 350 of file master_heartbeat.c.

References if(), hb_list::next, NULL, and hb_list::prev.

Referenced by hb_job_dequeue(), hb_job_set_expire_and_reorder(), hb_job_shutdown(), hb_remove_node(), hb_remove_ping_host(), hb_remove_proc(), and hb_remove_ui_node().

Here is the caller graph for this function:

static const char* hb_node_state_string ( int  nstate)
static
const char * hb_ping_result_string ( int  ping_result)
static
static void hb_proc_make_arg ( char **  arg,
char *  args 
)
static

Definition at line 3713 of file master_heartbeat.c.

References NULL.

Referenced by hb_resource_job_proc_start().

Here is the caller graph for this function:

void hb_reconfig_heartbeat ( char **  str)
static void hb_remove_all_procs ( HB_PROC_ENTRY first)
static

Definition at line 3626 of file master_heartbeat.c.

References hb_remove_proc(), and HB_PROC_ENTRY::next.

Referenced by hb_resource_cleanup().

Here is the caller graph for this function:

static void hb_remove_node ( HB_NODE_ENTRY entry_p)
static

Definition at line 2043 of file master_heartbeat.c.

References free_and_init, and hb_list_remove().

Referenced by hb_cluster_remove_all_nodes().

Here is the caller graph for this function:

static void hb_remove_ping_host ( HB_PING_HOST_ENTRY entry_p)
static

Definition at line 2112 of file master_heartbeat.c.

References free_and_init, and hb_list_remove().

Referenced by hb_cluster_remove_all_ping_hosts().

Here is the caller graph for this function:

static void hb_remove_proc ( HB_PROC_ENTRY entry_p)
static

Definition at line 3609 of file master_heartbeat.c.

References free_and_init, and hb_list_remove().

Referenced by hb_remove_all_procs(), hb_resource_job_confirm_cleanup_all(), hb_resource_job_confirm_dereg(), and hb_resource_job_proc_dereg().

Here is the caller graph for this function:

static void hb_remove_ui_node ( HB_UI_NODE_ENTRY node)
static

Definition at line 2355 of file master_heartbeat.c.

References assert, free_and_init, hb_list_remove(), and hb_cluster::num_ui_nodes.

Referenced by hb_cleanup_ui_nodes(), hb_cluster_receive_heartbeat(), and hb_cluster_remove_all_ui_nodes().

Here is the caller graph for this function:

static bool hb_resource_demote_confirm_shutdown_server_proc ( void  )
static
static HB_JOB_ENTRY * hb_resource_job_dequeue ( void  )
static

Definition at line 3510 of file master_heartbeat.c.

References hb_job_dequeue().

Referenced by hb_thread_resource_worker().

Here is the caller graph for this function:

static int hb_resource_job_set_expire_and_reorder ( unsigned int  job_type,
unsigned int  msec 
)
static

Definition at line 3543 of file master_heartbeat.c.

References ARG_FILE_LINE, ER_FAILED, hb_job_set_expire_and_reorder(), HB_RJOB_MAX, MASTER_ER_LOG_DEBUG, and NO_ERROR.

Referenced by hb_cluster_job_failover().

Here is the caller graph for this function:

static void hb_resource_job_shutdown ( void  )
static

Definition at line 3562 of file master_heartbeat.c.

References hb_job_shutdown().

Referenced by hb_master_init(), and hb_resource_shutdown_and_cleanup().

Here is the caller graph for this function:

static void hb_resource_send_get_eof ( void  )
static
void hb_resource_shutdown_and_cleanup ( void  )

Definition at line 5066 of file master_heartbeat.c.

References hb_resource_cleanup(), and hb_resource_job_shutdown().

Referenced by css_process_kill_master(), and hb_deactivate_heartbeat().

Here is the caller graph for this function:

static HB_NODE_ENTRY * hb_return_node_by_name ( char *  name)
static

Definition at line 2182 of file master_heartbeat.c.

References are_hostnames_equal(), hb_node_entry::host_name, hb_node_entry::next, hb_cluster::nodes, and NULL.

Referenced by hb_reload_config().

Here is the caller graph for this function:

static HB_NODE_ENTRY * hb_return_node_by_name_except_me ( char *  name)
static

Definition at line 2206 of file master_heartbeat.c.

References are_hostnames_equal(), hb_node_entry::host_name, hb_cluster::host_name, hb_node_entry::next, hb_cluster::nodes, and NULL.

Referenced by hb_cluster_receive_heartbeat(), and hb_is_heartbeat_valid().

Here is the caller graph for this function:

static HB_PROC_ENTRY * hb_return_proc_by_args ( char *  args)
static
static HB_PROC_ENTRY * hb_return_proc_by_fd ( int  sfd)
static
static HB_PROC_ENTRY * hb_return_proc_by_pid ( int  pid)
static

Definition at line 3666 of file master_heartbeat.c.

References HB_PROC_ENTRY::next, NULL, HB_PROC_ENTRY::pid, and hb_resource::procs.

Referenced by hb_deregister_by_pid(), hb_resource_job_confirm_dereg(), and hb_resource_job_proc_dereg().

Here is the caller graph for this function:

int hb_return_proc_state_by_fd ( int  sfd)
static HB_UI_NODE_ENTRY * hb_return_ui_node ( char *  host_name,
char *  group_id,
struct sockaddr_in  saddr 
)
static
static int hb_set_net_header ( HBP_HEADER header,
unsigned char  type,
bool  is_req,
unsigned short  len,
unsigned int  seq,
char *  dest_host_name 
)
static
void hb_start_deactivate_server_info ( void  )

Definition at line 6611 of file master_heartbeat.c.

References assert, free_and_init, hb_deactivate_info::info_started, NULL, hb_deactivate_info::server_count, and hb_deactivate_info::server_pid_list.

Referenced by css_process_deact_stop_all().

Here is the caller graph for this function:

static const char * hb_strtime ( char *  s,
unsigned int  max,
struct timeval *  tv_p 
)
static

Definition at line 464 of file master_heartbeat.c.

References NULL.

Referenced by hb_disable_er_log(), and hb_get_process_info_string().

Here is the caller graph for this function:

static void * hb_thread_cluster_reader ( void *  arg)
static
static void * hb_thread_cluster_worker ( void *  arg)
static
static void * hb_thread_resource_worker ( void *  arg)
static

Variable Documentation

HB_JOB* cluster_Jobs = NULL

Definition at line 242 of file master_heartbeat.c.

Referenced by css_process_kill_master().

HB_CLUSTER* hb_Cluster = NULL

Definition at line 240 of file master_heartbeat.c.

Referenced by css_process_kill_master().

HB_JOB_FUNC hb_cluster_jobs[]
static
Initial value:
= {
}
static void hb_cluster_job_failover(HB_JOB_ARG *arg)
static void hb_cluster_job_heartbeat(HB_JOB_ARG *arg)
static void hb_cluster_job_init(HB_JOB_ARG *arg)
static void hb_cluster_job_check_valid_ping_server(HB_JOB_ARG *arg)
static void hb_cluster_job_demote(HB_JOB_ARG *arg)
#define NULL
Definition: freelistheap.h:34
static void hb_cluster_job_calc_score(HB_JOB_ARG *arg)
static void hb_cluster_job_check_ping(HB_JOB_ARG *arg)
static void hb_cluster_job_failback(HB_JOB_ARG *arg)

Definition at line 253 of file master_heartbeat.c.

Referenced by hb_cluster_job_initialize().

bool hb_Deactivate_immediately = false
HB_DEACTIVATE_INFO hb_Deactivate_info = { NULL, 0, false }
static

Definition at line 248 of file master_heartbeat.c.

bool hb_Is_activated = true
static

Definition at line 250 of file master_heartbeat.c.

Referenced by hb_activate_heartbeat(), and hb_deactivate_heartbeat().

char hb_Nolog_event_msg[LINE_MAX] = ""
static
HB_RESOURCE* hb_Resource = NULL

Definition at line 241 of file master_heartbeat.c.

Referenced by css_process_kill_master().

HB_JOB_FUNC hb_resource_jobs[]
static
Initial value:
= {
}
static void hb_resource_job_change_mode(HB_JOB_ARG *arg)
static void hb_resource_job_cleanup_all(HB_JOB_ARG *arg)
static void hb_resource_job_proc_start(HB_JOB_ARG *arg)
static void hb_resource_job_demote_confirm_shutdown(HB_JOB_ARG *arg)
static void hb_resource_job_demote_start_shutdown(HB_JOB_ARG *arg)
#define NULL
Definition: freelistheap.h:34
static void hb_resource_job_proc_dereg(HB_JOB_ARG *arg)
static void hb_resource_job_confirm_start(HB_JOB_ARG *arg)
static void hb_resource_job_confirm_cleanup_all(HB_JOB_ARG *arg)
static void hb_resource_job_confirm_dereg(HB_JOB_ARG *arg)

Definition at line 266 of file master_heartbeat.c.

Referenced by hb_resource_job_initialize().

HB_JOB* resource_Jobs = NULL

Definition at line 243 of file master_heartbeat.c.

Referenced by css_process_kill_master().