CUBRID Engine  latest
server_support.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * server_support.h -
22  */
23 
24 #ifndef _SERVER_SUPPORT_H_
25 #define _SERVER_SUPPORT_H_
26 
27 #if !defined (SERVER_MODE) && !defined (SA_MODE)
28 #error server_support.h belongs to server or stand-alone modules
29 #endif // not SERVER_MODE and not SA_MODE
30 
31 #include "connection_defs.h"
32 #include "connection_sr.h"
33 #include "thread_entry.hpp"
34 #include "thread_entry_task.hpp"
35 
37 {
40 };
41 
42 extern void css_block_all_active_conn (unsigned short stop_phase);
43 
45 
46 extern unsigned int css_send_error_to_client (CSS_CONN_ENTRY * conn, unsigned int eid, char *buffer, int buffer_size);
47 extern unsigned int css_send_data_to_client (CSS_CONN_ENTRY * conn, unsigned int eid, char *buffer, int buffer_size);
48 extern unsigned int css_send_reply_and_data_to_client (CSS_CONN_ENTRY * conn, unsigned int eid, char *reply,
49  int reply_size, char *buffer, int buffer_size);
50 #if 0
51 extern unsigned int css_send_reply_and_large_data_to_client (unsigned int eid, char *reply, int reply_size,
52  char *buffer, INT64 buffer_size);
53 #endif
54 extern unsigned int css_send_reply_and_2_data_to_client (CSS_CONN_ENTRY * conn, unsigned int eid, char *reply,
55  int reply_size, char *buffer1, int buffer1_size, char *buffer2,
56  int buffer2_size);
57 extern unsigned int css_send_reply_and_3_data_to_client (CSS_CONN_ENTRY * conn, unsigned int eid, char *reply,
58  int reply_size, char *buffer1, int buffer1_size, char *buffer2,
59  int buffer2_size, char *buffer3, int buffer3_size);
60 extern unsigned int css_receive_data_from_client (CSS_CONN_ENTRY * conn, unsigned int eid, char **buffer, int *size);
61 extern unsigned int css_receive_data_from_client_with_timeout (CSS_CONN_ENTRY * conn, unsigned int eid, char **buffer,
62  int *size, int timeout);
63 extern unsigned int css_send_abort_to_client (CSS_CONN_ENTRY * conn, unsigned int eid);
64 extern void
65 css_initialize_server_interfaces (int (*request_handler)
66  (THREAD_ENTRY * thrd, unsigned int eid, int request, int size, char *buffer),
67  CSS_THREAD_FN connection_error_handler);
68 extern char *css_pack_server_name (const char *server_name, int *name_length);
69 extern int css_init (THREAD_ENTRY * thread_p, char *server_name, int server_name_length, int connection_id);
70 extern char *css_add_client_version_string (THREAD_ENTRY * thread_p, const char *version_string);
71 #if defined (ENABLE_UNUSED_FUNCTION)
72 extern char *css_get_client_version_string (void);
73 #endif
74 extern void css_cleanup_server_queues (unsigned int eid);
75 extern void css_end_server_request (CSS_CONN_ENTRY * conn);
76 extern bool css_is_shutdown_timeout_expired (void);
77 
78 #if defined (SERVER_MODE)
79 extern bool css_is_shutdowning_server ();
80 extern void css_start_shutdown_server ();
81 #endif // SERVER_MODE
82 
83 extern void css_set_ha_num_of_hosts (int num);
84 extern int css_get_ha_num_of_hosts (void);
86 extern bool css_is_ha_repl_delayed (void);
87 extern void css_set_ha_repl_delayed (void);
88 extern void css_unset_ha_repl_delayed (void);
89 extern int css_check_ha_server_state_for_client (THREAD_ENTRY * thread_p, int whence);
90 extern int css_change_ha_server_state (THREAD_ENTRY * thread_p, HA_SERVER_STATE state, bool force, int timeout,
91  bool heartbeat);
93 
95 extern void css_get_thread_stats (UINT64 * stats_out);
96 extern size_t css_get_num_request_workers (void);
97 extern size_t css_get_num_connection_workers (void);
98 extern size_t css_get_num_total_workers (void);
100 extern size_t css_count_transaction_worker_threads (THREAD_ENTRY * thread_p, int tran_index, int client_id);
101 
102 extern void css_set_thread_info (THREAD_ENTRY * thread_p, int client_id, int rid, int tran_index,
103  int net_request_index);
104 extern int css_get_client_id (THREAD_ENTRY * thread_p);
105 extern unsigned int css_get_comm_request_id (THREAD_ENTRY * thread_p);
106 extern struct css_conn_entry *css_get_current_conn_entry (void);
107 
108 #if defined (SERVER_MODE)
109 extern int css_job_queues_start_scan (THREAD_ENTRY * thread_p, int show_type, DB_VALUE ** arg_values, int arg_cnt,
110  void **ptr);
111 #else // not SERVER_MODE = SA_MODE
112 // SA_MODE does not have access to server_support.c, but job scan is a common function
113 // however, on SA_MODE, the result is always empty list
114 inline int
115 css_job_queues_start_scan (THREAD_ENTRY * thread_p, int show_type, DB_VALUE ** arg_values, int arg_cnt, void **ptr)
116 {
117  // suppress all unused parameter warnings
118  (void) thread_p;
119  (void) show_type;
120  (void) arg_values;
121  (void) arg_cnt;
122 
123  *ptr = NULL;
124  return NO_ERROR;
125 }
126 #endif // not SERVER_MODE = SA_MODE
127 
128 #endif /* _SERVER_SUPPORT_H_ */
void css_initialize_server_interfaces(int(*request_handler)(THREAD_ENTRY *thrd, unsigned int eid, int request, int size, char *buffer), CSS_THREAD_FN connection_error_handler)
#define NO_ERROR
Definition: error_code.h:46
unsigned int css_send_reply_and_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *reply, int reply_size, char *buffer, int buffer_size)
unsigned int css_get_comm_request_id(THREAD_ENTRY *thread_p)
int(* CSS_THREAD_FN)(THREAD_ENTRY *thrd, CSS_THREAD_ARG)
THREAD_RET_T THREAD_CALLING_CONVENTION css_master_thread(void)
void css_set_ha_repl_delayed(void)
bool css_is_shutdown_timeout_expired(void)
void css_push_external_task(CSS_CONN_ENTRY *conn, cubthread::entry_task *task)
unsigned int css_receive_data_from_client_with_timeout(CSS_CONN_ENTRY *conn, unsigned int eid, char **buffer, int *size, int timeout)
int css_notify_ha_log_applier_state(THREAD_ENTRY *thread_p, HA_LOG_APPLIER_STATE state)
void css_set_ha_num_of_hosts(int num)
size_t css_count_transaction_worker_threads(THREAD_ENTRY *thread_p, int tran_index, int client_id)
static int eid
Definition: cas_error_log.c:61
bool css_are_all_request_handlers_suspended(void)
unsigned int css_receive_data_from_client(CSS_CONN_ENTRY *conn, unsigned int eid, char **buffer, int *size)
void THREAD_ENTRY
size_t css_get_num_connection_workers(void)
bool css_is_ha_repl_delayed(void)
int css_init(THREAD_ENTRY *thread_p, char *server_name, int server_name_length, int connection_id)
void css_cleanup_server_queues(unsigned int eid)
#define THREAD_RET_T
Definition: porting.h:713
int css_get_client_id(THREAD_ENTRY *thread_p)
void css_get_thread_stats(UINT64 *stats_out)
bool css_is_shutdowning_server()
unsigned int css_send_reply_and_2_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *reply, int reply_size, char *buffer1, int buffer1_size, char *buffer2, int buffer2_size)
enum ha_log_applier_state HA_LOG_APPLIER_STATE
unsigned int css_send_abort_to_client(CSS_CONN_ENTRY *conn, unsigned int eid)
#define NULL
Definition: freelistheap.h:34
void css_unset_ha_repl_delayed(void)
HA_SERVER_STATE css_ha_server_state(void)
int css_change_ha_server_state(THREAD_ENTRY *thread_p, HA_SERVER_STATE state, bool force, int timeout, bool heartbeat)
char * css_pack_server_name(const char *server_name, int *name_length)
void css_block_all_active_conn(unsigned short stop_phase)
unsigned int css_send_reply_and_3_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *reply, int reply_size, char *buffer1, int buffer1_size, char *buffer2, int buffer2_size, char *buffer3, int buffer3_size)
int css_check_ha_server_state_for_client(THREAD_ENTRY *thread_p, int whence)
struct css_conn_entry * css_get_current_conn_entry(void)
int css_job_queues_start_scan(THREAD_ENTRY *thread_p, int show_type, DB_VALUE **arg_values, int arg_cnt, void **ptr)
void css_start_shutdown_server()
int css_get_ha_num_of_hosts(void)
char * css_add_client_version_string(THREAD_ENTRY *thread_p, const char *version_string)
void css_set_thread_info(THREAD_ENTRY *thread_p, int client_id, int rid, int tran_index, int net_request_index)
css_thread_stop_type
enum ha_server_state HA_SERVER_STATE
Definition: boot.h:126
#define THREAD_CALLING_CONVENTION
Definition: porting.h:714
size_t css_get_num_request_workers(void)
size_t css_get_num_total_workers(void)
unsigned int css_send_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *buffer, int buffer_size)
void css_end_server_request(CSS_CONN_ENTRY *conn)
unsigned int css_send_error_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *buffer, int buffer_size)