@@ -14,7 +14,6 @@ See the Mulan PSL v2 for more details. */
14
14
15
15
#include " common/init.h"
16
16
17
- #include " common/ini_setting.h"
18
17
#include " common/conf/ini.h"
19
18
#include " common/lang/string.h"
20
19
#include " common/log/log.h"
@@ -24,52 +23,39 @@ See the Mulan PSL v2 for more details. */
24
23
#include " common/os/signal.h"
25
24
#include " common/seda/init.h"
26
25
#include " common/seda/stage_factory.h"
26
+ #include " global_context.h"
27
27
#include " session/session.h"
28
28
#include " session/session_stage.h"
29
- #include " sql/executor/execute_stage.h"
30
- #include " sql/optimizer/optimize_stage.h"
31
- #include " sql/parser/parse_stage.h"
32
- #include " sql/parser/resolve_stage.h"
33
29
#include " sql/plan_cache/plan_cache_stage.h"
34
- #include " sql/query_cache/query_cache_stage.h"
35
30
#include " storage/buffer/disk_buffer_pool.h"
36
31
#include " storage/default/default_handler.h"
37
32
#include " storage/trx/trx.h"
38
- #include " global_context.h"
39
33
34
+ using namespace std ;
40
35
using namespace common ;
41
36
42
37
bool *&_get_init ()
43
38
{
44
- static bool util_init = false ;
39
+ static bool util_init = false ;
45
40
static bool *util_init_p = &util_init;
46
41
return util_init_p;
47
42
}
48
43
49
- bool get_init ()
50
- {
51
- return *_get_init ();
52
- }
44
+ bool get_init () { return *_get_init (); }
53
45
54
- void set_init (bool value)
55
- {
56
- *_get_init () = value;
57
- return ;
58
- }
46
+ void set_init (bool value) { *_get_init () = value; }
59
47
60
48
void sig_handler (int sig)
61
49
{
62
50
// Signal handler will be add in the next step.
63
51
// Add action to shutdown
64
52
65
53
LOG_INFO (" Receive one signal of %d." , sig);
66
-
67
- return ;
68
54
}
69
55
70
56
int init_log (ProcessParam *process_cfg, Ini &properties)
71
57
{
72
- const std:: string &proc_name = process_cfg->get_process_name ();
58
+ const string &proc_name = process_cfg->get_process_name ();
73
59
try {
74
60
// we had better alloc one lock to do so, but simplify the logic
75
61
if (g_log) {
@@ -78,35 +64,36 @@ int init_log(ProcessParam *process_cfg, Ini &properties)
78
64
79
65
auto log_context_getter = []() { return reinterpret_cast <intptr_t >(Session::current_session ()); };
80
66
81
- const std:: string log_section_name = " LOG" ;
82
- std:: map<std:: string, std:: string> log_section = properties.get (log_section_name);
67
+ const string log_section_name = " LOG" ;
68
+ map<string, string> log_section = properties.get (log_section_name);
83
69
84
- std:: string log_file_name;
70
+ string log_file_name;
85
71
86
72
// get log file name
87
- std::string key = " LOG_FILE_NAME" ;
88
- std::map<std::string, std::string>::iterator it = log_section.find (key);
73
+ string key = " LOG_FILE_NAME" ;
74
+
75
+ map<string, string>::iterator it = log_section.find (key);
89
76
if (it == log_section.end ()) {
90
77
log_file_name = proc_name + " .log" ;
91
- std:: cout << " Not set log file name, use default " << log_file_name << std:: endl;
78
+ cout << " Not set log file name, use default " << log_file_name << endl;
92
79
} else {
93
80
log_file_name = it->second ;
94
81
}
95
82
96
83
log_file_name = getAboslutPath (log_file_name.c_str ());
97
84
98
85
LOG_LEVEL log_level = LOG_LEVEL_INFO;
99
- key = (" LOG_FILE_LEVEL" );
100
- it = log_section.find (key);
86
+ key = (" LOG_FILE_LEVEL" );
87
+ it = log_section.find (key);
101
88
if (it != log_section.end ()) {
102
89
int log = (int )log_level;
103
90
str_to_val (it->second , log );
104
91
log_level = (LOG_LEVEL)log ;
105
92
}
106
93
107
94
LOG_LEVEL console_level = LOG_LEVEL_INFO;
108
- key = (" LOG_CONSOLE_LEVEL" );
109
- it = log_section.find (key);
95
+ key = (" LOG_CONSOLE_LEVEL" );
96
+ it = log_section.find (key);
110
97
if (it != log_section.end ()) {
111
98
int log = (int )console_level;
112
99
str_to_val (it->second , log );
@@ -117,7 +104,7 @@ int init_log(ProcessParam *process_cfg, Ini &properties)
117
104
g_log->set_context_getter (log_context_getter);
118
105
119
106
key = (" DefaultLogModules" );
120
- it = log_section.find (key);
107
+ it = log_section.find (key);
121
108
if (it != log_section.end ()) {
122
109
g_log->set_default_module (it->second );
123
110
}
@@ -127,8 +114,8 @@ int init_log(ProcessParam *process_cfg, Ini &properties)
127
114
}
128
115
129
116
return 0 ;
130
- } catch (std:: exception &e) {
131
- std:: cerr << " Failed to init log for " << proc_name << SYS_OUTPUT_FILE_POS << SYS_OUTPUT_ERROR << std:: endl;
117
+ } catch (exception &e) {
118
+ cerr << " Failed to init log for " << proc_name << SYS_OUTPUT_FILE_POS << SYS_OUTPUT_ERROR << endl;
132
119
return errno;
133
120
}
134
121
@@ -142,7 +129,6 @@ void cleanup_log()
142
129
delete g_log;
143
130
g_log = nullptr ;
144
131
}
145
- return ;
146
132
}
147
133
148
134
int prepare_init_seda ()
@@ -157,11 +143,11 @@ int init_global_objects(ProcessParam *process_param, Ini &properties)
157
143
BufferPoolManager::set_instance (GCTX.buffer_pool_manager_ );
158
144
159
145
GCTX.handler_ = new DefaultHandler ();
160
-
146
+
161
147
DefaultHandler::set_default (GCTX.handler_ );
162
148
163
149
int ret = 0 ;
164
- RC rc = TrxKit::init_global (process_param->trx_kit_name ().c_str ());
150
+ RC rc = TrxKit::init_global (process_param->trx_kit_name ().c_str ());
165
151
if (rc != RC::SUCCESS) {
166
152
LOG_ERROR (" failed to init trx kit. rc=%s" , strrc (rc));
167
153
ret = -1 ;
@@ -196,7 +182,6 @@ int uninit_global_objects()
196
182
int init (ProcessParam *process_param)
197
183
{
198
184
if (get_init ()) {
199
-
200
185
return 0 ;
201
186
}
202
187
@@ -207,7 +192,7 @@ int init(ProcessParam *process_param)
207
192
if (process_param->is_demon ()) {
208
193
rc = daemonize_service (process_param->get_std_out ().c_str (), process_param->get_std_err ().c_str ());
209
194
if (rc != 0 ) {
210
- std:: cerr << " Shutdown due to failed to daemon current process!" << std:: endl;
195
+ cerr << " Shutdown due to failed to daemon current process!" << endl;
211
196
return rc;
212
197
}
213
198
}
@@ -220,18 +205,18 @@ int init(ProcessParam *process_param)
220
205
// Read Configuration files
221
206
rc = get_properties ()->load (process_param->get_conf ());
222
207
if (rc) {
223
- std:: cerr << " Failed to load configuration files" << std:: endl;
208
+ cerr << " Failed to load configuration files" << endl;
224
209
return rc;
225
210
}
226
211
227
212
// Init tracer
228
213
rc = init_log (process_param, *get_properties ());
229
214
if (rc) {
230
- std:: cerr << " Failed to init Log" << std:: endl;
215
+ cerr << " Failed to init Log" << endl;
231
216
return rc;
232
217
}
233
218
234
- std:: string conf_data;
219
+ string conf_data;
235
220
get_properties ()->to_string (conf_data);
236
221
LOG_INFO (" Output configuration \n %s" , conf_data.c_str ());
237
222
@@ -266,7 +251,7 @@ int init(ProcessParam *process_param)
266
251
void cleanup_util ()
267
252
{
268
253
uninit_global_objects ();
269
-
254
+
270
255
if (nullptr != get_properties ()) {
271
256
delete get_properties ();
272
257
get_properties () = nullptr ;
@@ -278,10 +263,6 @@ void cleanup_util()
278
263
cleanup_log ();
279
264
280
265
set_init (false );
281
- return ;
282
266
}
283
267
284
- void cleanup ()
285
- {
286
- cleanup_util ();
287
- }
268
+ void cleanup () { cleanup_util (); }
0 commit comments