UltraMonkey-L7 V3(multi-thread implementation)
Revision | bc58556291a17434f4d6daab880e93a251e6d5fd (tree) |
---|---|
Zeit | 2012-09-11 19:15:27 |
Autor | hibari <l05102@shib...> |
Commiter | hibari |
Add session_thread_pool_size option for l7vsadm and l7directord.
@@ -56,3 +56,4 @@ virtual = 192.168.0.50:80 | ||
56 | 56 | #accesslog_rotate_max_filesize = 100M |
57 | 57 | #accesslog_rotate_rotation_timing = month |
58 | 58 | #accesslog_rotate_rotation_timing_value = "1 23:59" |
59 | + #session_thread_pool_size = 32 |
@@ -138,6 +138,7 @@ our %VIRTUAL = ( | ||
138 | 138 | accesslog_rotate_max_filesize => undef, |
139 | 139 | accesslog_rotate_rotation_timing => undef, |
140 | 140 | accesslog_rotate_rotation_timing_value => undef, |
141 | + session_thread_pool_size => undef, | |
141 | 142 | other_virtual_key => undef, |
142 | 143 | # can override |
143 | 144 | checkcount => undef, |
@@ -1060,6 +1061,11 @@ sub validate_config { | ||
1060 | 1061 | config_error($line, 'ERR0129', $config); |
1061 | 1062 | } |
1062 | 1063 | } |
1064 | + elsif ($name eq 'session_thread_pool_size') { | |
1065 | + if (!defined $value || $value !~ /^\d+$/ || $value == 0 ) { | |
1066 | + config_error($line, 'ERR0101', $config); | |
1067 | + } | |
1068 | + } | |
1063 | 1069 | } |
1064 | 1070 | |
1065 | 1071 | return ($name, $value); |
@@ -1400,6 +1406,13 @@ sub ld_setup { | ||
1400 | 1406 | if ( $option_key_flag == 0 ) { |
1401 | 1407 | $v->{other_virtual_key} .= ' none'; |
1402 | 1408 | } |
1409 | + if ( defined $v->{session_thread_pool_size} ) { | |
1410 | + $v->{option}{flags} .= ' --session-thread-pool-size ' . $v->{session_thread_pool_size}; | |
1411 | + $v->{other_virtual_key} .= ' ' . $v->{session_thread_pool_size}; | |
1412 | + } | |
1413 | + else { | |
1414 | + $v->{other_virtual_key} .= ' none'; | |
1415 | + } | |
1403 | 1416 | } |
1404 | 1417 | |
1405 | 1418 | if ( !defined $v->{fallback} && defined $CONFIG{fallback} ) { |
@@ -4998,6 +5011,11 @@ FORMAT: B<"HH:mm"> | ||
4998 | 5011 | |
4999 | 5012 | FORMAT: B<"mm"> |
5000 | 5013 | |
5014 | +Defines the size each of session_thread_pool_size. | |
5015 | +Default is session_thread_pool_size parameter at l7vs.cf. | |
5016 | + | |
5017 | +=item B<session_thread_pool_size = >I<n> | |
5018 | + | |
5001 | 5019 | =back |
5002 | 5020 | |
5003 | 5021 | =back |
@@ -286,6 +286,8 @@ protected: | ||
286 | 286 | bool parse_opt_vs_access_log_logrotate_func(int &, int, char*[]); |
287 | 287 | //! virtualservice option socket option function |
288 | 288 | bool parse_opt_vs_socket_func(int &, int, char*[]); |
289 | + //! virtualservice option session thread pool size function | |
290 | + bool parse_opt_vs_session_thread_pool_size_func(int &, int, char*[]); | |
289 | 291 | // realserver option function |
290 | 292 | //! realserver weight set |
291 | 293 | bool parse_opt_rs_weight_func(int &, int, char*[]); |
@@ -68,6 +68,7 @@ public: | ||
68 | 68 | unsigned long long qos_downstream; |
69 | 69 | unsigned long long throughput_upstream; |
70 | 70 | unsigned long long throughput_downstream; |
71 | + unsigned long long session_thread_pool_size; | |
71 | 72 | |
72 | 73 | std::string ssl_file_name; |
73 | 74 |
@@ -99,6 +100,7 @@ public: | ||
99 | 100 | qos_downstream(0ULL), |
100 | 101 | throughput_upstream(0ULL), |
101 | 102 | throughput_downstream(0ULL), |
103 | + session_thread_pool_size(0), | |
102 | 104 | access_log_flag(0), |
103 | 105 | socket_option_tcp_defer_accept(0), |
104 | 106 | socket_option_tcp_nodelay(0), |
@@ -122,6 +124,7 @@ public: | ||
122 | 124 | qos_downstream(in.qos_downstream), |
123 | 125 | throughput_upstream(in.throughput_upstream), |
124 | 126 | throughput_downstream(in.throughput_downstream), |
127 | + session_thread_pool_size(in.session_thread_pool_size), | |
125 | 128 | ssl_file_name(in.ssl_file_name), |
126 | 129 | access_log_flag(in.access_log_flag), |
127 | 130 | access_log_file_name(in.access_log_file_name), |
@@ -164,6 +167,7 @@ public: | ||
164 | 167 | qos_downstream = in.qos_downstream; |
165 | 168 | throughput_upstream = in.throughput_upstream; |
166 | 169 | throughput_downstream = in.throughput_downstream; |
170 | + session_thread_pool_size = in.session_thread_pool_size; | |
167 | 171 | access_log_flag = in.access_log_flag; |
168 | 172 | ssl_file_name = in.ssl_file_name; |
169 | 173 | access_log_file_name = in.access_log_file_name; |
@@ -205,6 +209,7 @@ public: | ||
205 | 209 | elem1.qos_downstream == elem2.qos_downstream && |
206 | 210 | elem1.throughput_upstream == elem2.throughput_upstream && |
207 | 211 | elem1.throughput_downstream == elem2.throughput_downstream && |
212 | + elem1.session_thread_pool_size == elem2.session_thread_pool_size && | |
208 | 213 | elem1.access_log_flag == elem2.access_log_flag && |
209 | 214 | elem1.ssl_file_name == elem2.ssl_file_name && |
210 | 215 | elem1.access_log_file_name == elem2.access_log_file_name && |
@@ -265,6 +270,7 @@ public: | ||
265 | 270 | elem1.qos_downstream == elem2.qos_downstream && |
266 | 271 | elem1.throughput_upstream == elem2.throughput_upstream && |
267 | 272 | elem1.throughput_downstream == elem2.throughput_downstream && |
273 | + elem1.session_thread_pool_size == elem2.session_thread_pool_size && | |
268 | 274 | elem1.access_log_flag == elem2.access_log_flag && |
269 | 275 | elem1.ssl_file_name == elem2.ssl_file_name && |
270 | 276 | elem1.access_log_file_name == elem2.access_log_file_name && |
@@ -368,6 +374,7 @@ public: | ||
368 | 374 | "qos_downstream=%d, " |
369 | 375 | "throughput_upstream=%d, " |
370 | 376 | "throughput_downstream=%d, " |
377 | + "session_thread_pool_size=%d, " | |
371 | 378 | "access_log_flag=%d, " |
372 | 379 | "ssl_file_name=%s, " |
373 | 380 | "access_log_file_name=%s, " |
@@ -392,6 +399,7 @@ public: | ||
392 | 399 | % elem.qos_downstream |
393 | 400 | % elem.throughput_upstream |
394 | 401 | % elem.throughput_downstream |
402 | + % elem.session_thread_pool_size | |
395 | 403 | % elem.access_log_flag |
396 | 404 | % elem.ssl_file_name |
397 | 405 | % elem.access_log_file_name |
@@ -440,6 +448,7 @@ private: | ||
440 | 448 | ar &qos_downstream; |
441 | 449 | ar &throughput_upstream; |
442 | 450 | ar &throughput_downstream; |
451 | + ar &session_thread_pool_size; | |
443 | 452 | ar &access_log_flag; |
444 | 453 | ar &ssl_file_name; |
445 | 454 | ar &access_log_file_name; |
@@ -1185,6 +1185,40 @@ bool l7vs::l7vsadm::parse_opt_vs_socket_func(int &pos, int argc, char *argv[]) | ||
1185 | 1185 | return true; |
1186 | 1186 | |
1187 | 1187 | } |
1188 | +//! virtualservice option session_thread_pool_size function | |
1189 | +//! @param[in] argument position | |
1190 | +//! @param[in] argument count | |
1191 | +//! @param[in] argument value | |
1192 | +bool l7vs::l7vsadm::parse_opt_vs_session_thread_pool_size_func(int &pos, int argc, char *argv[]) | |
1193 | +{ | |
1194 | + Logger logger(LOG_CAT_L7VSADM_COMMON, 10, "l7vsadm::parse_opt_vs_session_thread_pool_size_func", __FILE__, __LINE__); | |
1195 | + if (++pos >= argc) { | |
1196 | + // session_thread_pool_size is not specified. | |
1197 | + std::string buf("session_thread_pool_size is not specified.(--session-thread-pool-size)"); | |
1198 | + l7vsadm_err.setter(true, buf); | |
1199 | + Logger::putLogError(LOG_CAT_L7VSADM_PARSE, /* fix me */999, buf, __FILE__, __LINE__); | |
1200 | + return false; | |
1201 | + } | |
1202 | + try { | |
1203 | + virtualservice_element &elem = request.vs_element; // request virtualservice element reference get. | |
1204 | + std::string tmp = argv[pos]; | |
1205 | + unsigned long long ullval = boost::lexical_cast<unsigned long long> (argv[pos]); | |
1206 | + if (ullval < 1) { | |
1207 | + std::string buf("session-thread-pool-size is too small.(--session-thread-pool-size)"); | |
1208 | + l7vsadm_err.setter(true, buf); | |
1209 | + Logger::putLogError(LOG_CAT_L7VSADM_PARSE, /* fix me */999, buf, __FILE__, __LINE__); | |
1210 | + return false; | |
1211 | + } | |
1212 | + elem.session_thread_pool_size = ullval; // set session_thread_pool_size | |
1213 | + } catch (boost::bad_lexical_cast &ex) { | |
1214 | + std::string buf("invalid session-thread-pool-size.(--session-thiread-pool-size)"); | |
1215 | + l7vsadm_err.setter(true, buf); | |
1216 | + Logger::putLogError(LOG_CAT_L7VSADM_PARSE, /* fix me */999, buf, __FILE__, __LINE__); | |
1217 | + return false; | |
1218 | + } | |
1219 | + return true; | |
1220 | +} | |
1221 | + | |
1188 | 1222 | //! realserver command parsing. |
1189 | 1223 | //! @param[in] request command |
1190 | 1224 | //! @param[in] argument count |
@@ -2258,6 +2292,7 @@ bool l7vs::l7vsadm::parse_help_func(l7vs::l7vsadm_request::COMMAND_CODE_TAG cmd, | ||
2258 | 2292 | " --access-log -L access-log-flag access log flag 0(none) or 1(output)\n" |
2259 | 2293 | " --access-log-name -a access-log-file access log file\n" |
2260 | 2294 | " [logrotate-args]\n" |
2295 | + " --session-thread-pool-size val-size set session_thread_pool_size\n" | |
2261 | 2296 | " --real-server -r server-address server-address is host:port\n" |
2262 | 2297 | " --weight -w weight scheduling weight set to real server\n" |
2263 | 2298 | " --tproxy set real server connection to IP transparent mode.\n" |
@@ -2291,6 +2326,7 @@ std::string l7vs::l7vsadm::usage() | ||
2291 | 2326 | " [-s scheduler] [-u connection-count] [-b sorry-server] [--masq|tproxy]\n" |
2292 | 2327 | " [-f sorry-flag] [-Q QoSval-up] [-q QoSval-down] [-z ssl-config-file]\n" |
2293 | 2328 | " [-O socket-option] [-L access-log-flag] [-a access-log-file [logrotate-args]]\n" |
2329 | + " [--session-thread-pool-size val-size]\n" | |
2294 | 2330 | " l7vsadm -E -t service-address -m proto-module [module-args]\n" |
2295 | 2331 | " [-s scheduler] [-u connection-count] [-b sorry-server] [--masq|tproxy]\n" |
2296 | 2332 | " [-f sorry-flag] [-Q QoSval-up] [-q QoSval-down] [-L access-log-flag]\n" |
@@ -2682,6 +2718,7 @@ l7vs::l7vsadm::l7vsadm() | ||
2682 | 2718 | vs_option_dic["--access-log"] = boost::bind(&l7vsadm::parse_opt_vs_access_log_func, this, _1, _2, _3); |
2683 | 2719 | vs_option_dic["-a"] = boost::bind(&l7vsadm::parse_opt_vs_access_log_logrotate_func, this, _1, _2, _3); |
2684 | 2720 | vs_option_dic["--access-log-name"] = boost::bind(&l7vsadm::parse_opt_vs_access_log_logrotate_func, this, _1, _2, _3); |
2721 | + vs_option_dic["--session-thread-pool-size"] = boost::bind(&l7vsadm::parse_opt_vs_session_thread_pool_size_func, this, _1, _2, _3); | |
2685 | 2722 | |
2686 | 2723 | // create realserver option dictionary |
2687 | 2724 | rs_option_dic["-t"] = boost::bind(&l7vsadm::parse_opt_vs_target_func, this, _1, _2, _3); |
@@ -798,7 +798,13 @@ void l7vs::virtualservice_tcp::initialize(l7vs::error_code &err) | ||
798 | 798 | |
799 | 799 | //create session pool |
800 | 800 | { |
801 | - for (int i = 0; i < param_data.session_pool_size; ++i) { | |
801 | + int session_pool_size; | |
802 | + if (element.session_thread_pool_size > 0) { | |
803 | + session_pool_size = element.session_thread_pool_size; | |
804 | + } else { | |
805 | + session_pool_size = param_data.session_pool_size; | |
806 | + } | |
807 | + for (int i = 0; i < session_pool_size; ++i) { | |
802 | 808 | try { |
803 | 809 | tcp_session *sess = new tcp_session(*this, |
804 | 810 | *dispatcher, |