1 #include <boost/asio.hpp>
4 #include "data_buff_base.h"
5 #include "tcp_thread_message.h"
6 #include "tcp_thread_message_que.h"
8 #include "tcp_socket.h"
9 #include "tcp_session.h"
10 #include "udp_session.h"
11 #include "parameter.h"
12 #include "replication.h"
13 #include "protocol_module_control.h"
14 #include "schedule_module_control.h"
17 // protocol_module_control STUB code
18 l7vs::protocol_module_control& l7vs::protocol_module_control::getInstance(){
19 static protocol_module_control instance;
22 void l7vs::protocol_module_control::initialize( const std::string& infile_path ){}
23 void l7vs::protocol_module_control::finalize(){}
24 l7vs::protocol_module_base* l7vs::protocol_module_control::load_module( const std::string& modulename ){
25 l7vs::protocol_module_base* return_value = NULL;
27 // if( !pmcontrol_error_flag )
28 // return_value = new protocol_module_test1;
32 void l7vs::protocol_module_control::unload_module( protocol_module_base* module_ptr ){
36 l7vs::schedule_module_control& l7vs::schedule_module_control::getInstance(){
37 static schedule_module_control instance;
40 void l7vs::schedule_module_control::initialize( const std::string& infile_path ){}
41 void l7vs::schedule_module_control::finalize(){}
42 l7vs::schedule_module_base* l7vs::schedule_module_control::load_module( const std::string& modulename ){
43 l7vs::schedule_module_base* return_value = NULL;
45 // if( !smcontrol_error_flag )
46 // return_value = new schedule_module_test1;
50 void l7vs::schedule_module_control::unload_module( schedule_module_base* module_ptr ){
56 l7vs::Parameter::Parameter(){}
58 l7vs::Parameter::~Parameter(){}
60 bool l7vs::Parameter::read_file( const PARAMETER_COMPONENT_TAG in ){ return true; }
62 int l7vs::Parameter::get_int( const PARAMETER_COMPONENT_TAG in_tag,
63 const std::string& in_str,
66 if( debugg_flug_struct::getInstance().param_exist_flag() ){
67 retval = SESSION_POOL_NUM_PARAM;
69 err.setter( true, "not exist value." );
74 std::string l7vs::Parameter::get_string(const PARAMETER_COMPONENT_TAG in_tag,
75 const std::string& in_str,
81 l7vs::Logger::Logger() :
82 scopedLogCategory(LOG_CAT_L7VSD_LOGGER),
84 scopedLogMessage("Logger Constructor"),
85 scopedLogFile(__FILE__),
86 scopedLogLine(__LINE__) {}
88 l7vs::Logger::Logger( LOG_CATEGORY_TAG cat, const unsigned int id, const std::string& msg, const char* file, int line) :
89 scopedLogCategory(cat),
91 scopedLogMessage(msg),
93 scopedLogLine(line) {}
95 l7vs::Logger::~Logger(){}
97 void l7vs::Logger::loadConf(){}
99 l7vs::LOG_LEVEL_TAG l7vs::Logger::getLogLevel( l7vs::LOG_CATEGORY_TAG ){
100 l7vs::LOG_LEVEL_TAG ret_tag = l7vs::LOG_LV_DEBUG;
104 bool l7vs::Logger::setLogLevel( l7vs::LOG_CATEGORY_TAG cat, l7vs::LOG_LEVEL_TAG level ){
108 void l7vs::Logger::putLogFatal( l7vs::LOG_CATEGORY_TAG, const unsigned int, const std::string& msg, const char*, int ){
109 std::cout << "FATAL : " << msg << std::endl;
112 void l7vs::Logger::putLogError( l7vs::LOG_CATEGORY_TAG, const unsigned int, const std::string& msg, const char*, int ){
113 std::cout << "ERROR : " << msg << std::endl;
116 void l7vs::Logger::putLogWarn( l7vs::LOG_CATEGORY_TAG, const unsigned int, const std::string& msg, const char*, int ){
117 std::cout << "WARN : " << msg << std::endl;
120 void l7vs::Logger::putLogInfo( l7vs::LOG_CATEGORY_TAG, const unsigned int, const std::string& msg, const char*, int ){
121 std::cout << "INFO : " << msg << std::endl;
124 void l7vs::Logger::putLogDebug( l7vs::LOG_CATEGORY_TAG, const unsigned int, const std::string& msg, const char*, int ){
125 std::cout << "DEBUG : " << msg << std::endl;
128 l7vs::l7vsd::l7vsd(){}
129 l7vs::l7vsd::~l7vsd(){}
130 l7vs::l7vsd::vslist_type::iterator l7vs::l7vsd::search_vslist( const virtualservice_element& ) const{
131 return vslist.begin();
134 void l7vs::l7vsd::release_virtual_service( const virtualservice_element& ) const {}
137 int l7vs::replication::initialize(){
140 void l7vs::replication::finalize(){}
141 void l7vs::replication::switch_to_master(){}
142 void l7vs::replication::switch_to_slave(){}
143 void* l7vs::replication::pay_memory( const std::string& inid, unsigned int& outsize ){
146 void l7vs::replication::dump_memory(){}
147 void l7vs::replication::start(){}
148 void l7vs::replication::stop(){}
149 void l7vs::replication::force_replicate(){}
150 void l7vs::replication::reset(){}
151 l7vs::replication::REPLICATION_MODE_TAG l7vs::replication::get_status(){
152 l7vs::replication::REPLICATION_MODE_TAG retmode = l7vs::replication::REPLICATION_OUT;
155 int l7vs::replication::handle_send(){
158 void l7vs::replication::handle_receive( const boost::system::error_code& err, size_t size ){
160 int l7vs::replication::lock( const std::string& inid ){
163 int l7vs::replication::unlock( const std::string& inid ){
166 int l7vs::replication::refer_lock_mutex( const std::string& inid, mutex_ptr& outmutex ){
171 l7vs::data_buff_base::data_buff_base(){}
172 l7vs::data_buff_base::~data_buff_base(){}
173 void l7vs::data_buff_base::initialize(){}
174 std::size_t l7vs::data_buff_base::get_size(){
177 void l7vs::data_buff_base::set_size(const std::size_t set_size){}
178 boost::array< char , MAX_BUFFER_SIZE>& l7vs::data_buff_base::get_data(){
181 void l7vs::data_buff_base::set_data(const boost::array< char , MAX_BUFFER_SIZE>& data){}
182 void l7vs::data_buff_base::set_send_size(const std::size_t set_size){}
183 std::size_t l7vs::data_buff_base::get_send_size(){
187 l7vs::tcp_realserver_connect_socket_list::tcp_realserver_connect_socket_list(){}
189 l7vs::tcp_realserver_connect_socket_list::~tcp_realserver_connect_socket_list(){}
191 void l7vs::tcp_realserver_connect_socket_list::push_back(list_element realserver_socket){}
193 l7vs::tcp_realserver_connect_socket_list::list_element l7vs::tcp_realserver_connect_socket_list::get_socket(){
194 l7vs::tcp_realserver_connect_socket_list::list_element retval;
198 bool l7vs::tcp_realserver_connect_socket_list::empty(){
202 l7vs::tcp_thread_message::tcp_thread_message(){}
203 l7vs::tcp_thread_message::~tcp_thread_message(){}
205 l7vs::tcp_thread_message_que::tcp_thread_message_que(){}
206 l7vs::tcp_thread_message_que::~tcp_thread_message_que(){}
208 void l7vs::tcp_thread_message_que::push(tcp_thread_message_ptr message){}
209 l7vs::tcp_thread_message_que::tcp_thread_message_ptr l7vs::tcp_thread_message_que::front(){
210 return message_que.front();
212 bool l7vs::tcp_thread_message_que::empty(){
215 void l7vs::tcp_thread_message_que::clear(){}
218 l7vs::tcp_data::tcp_data(){}
219 l7vs::tcp_data::~tcp_data(){}
220 void l7vs::tcp_data::initialize(){}
221 void l7vs::tcp_data::set_endpoint(const boost::asio::ip::tcp::endpoint set_endpoint){}
222 boost::asio::ip::tcp::endpoint l7vs::tcp_data::get_endpoint(){
223 return endpoint_info;
226 l7vs::tcp_socket::tcp_socket(boost::asio::io_service& io) : my_socket( io ){}
227 l7vs::tcp_socket::~tcp_socket(){}
228 boost::asio::ip::tcp::socket& l7vs::tcp_socket::get_socket(){
231 bool l7vs::tcp_socket::connect(const boost::asio::ip::tcp::endpoint connect_endpoint,boost::system::error_code& ec){
234 bool l7vs::tcp_socket::close(boost::system::error_code& ec){
237 bool l7vs::tcp_socket::set_non_blocking_mode(boost::system::error_code& ec){
240 std::size_t l7vs::tcp_socket::write_some(boost::asio::mutable_buffers_1 buffers, boost::system::error_code& ec){
244 std::size_t l7vs::tcp_socket::read_some(boost::asio::mutable_buffers_1 buffers, boost::system::error_code& ec){
252 l7vs::tcp_session::tcp_session(l7vs::virtualservice_tcp& vs, boost::asio::io_service& session_io) : io( session_io ),
253 parent_service( vs ),
254 client_socket( io ) {
256 session_pause_flag = false;
257 std::cout << "SESSION:CREATE" << std::endl;
259 l7vs::tcp_session::~tcp_session(void){
260 std::cout << "SESSION:DESTROY" << std::endl;
262 l7vs::session_result_message l7vs::tcp_session::initialize(void){
263 l7vs::session_result_message result;
267 boost::asio::ip::tcp::socket& l7vs::tcp_session::get_client_socket(void){
268 return client_socket.get_socket();
271 bool l7vs::tcp_session::is_thread_wait(void){
275 void l7vs::tcp_session::set_virtual_service_message(const TCP_VIRTUAL_SERVICE_MESSAGE_TAG message){
277 case SORRY_STATE_ENABLE:
279 boost::mutex::scoped_lock( exit_flag_update_mutex );
283 case SORRY_STATE_DISABLE:
285 boost::mutex::scoped_lock( exit_flag_update_mutex );
291 boost::mutex::scoped_lock( exit_flag_update_mutex );
292 boost::mutex::scoped_lock( module_function_sorry_disable_mutex );
294 session_pause_flag = true;
297 case SESSION_PAUSE_ON:
299 boost::mutex::scoped_lock( module_function_sorry_disable_mutex );
300 session_pause_flag = true;
303 case SESSION_PAUSE_OFF:
305 boost::mutex::scoped_lock( module_function_sorry_disable_mutex );
306 session_pause_flag = false;
312 void l7vs::tcp_session::up_thread_run(void){
314 std::cout << "UP:RUN" << std::endl;
315 for( i = 0; i < (INT_MAX/12); ++i ){
317 boost::mutex::scoped_lock( exit_flag_update_mutex );
318 if( exit_flag )break;
321 std::cout << "UP:STOP(" << i << ")" << std::endl;
324 void l7vs::tcp_session::down_thread_run(void){
326 std::cout << "DOWN:RUN" << std::endl;
327 for( i = 0; i < (INT_MAX/12); ++i ){
329 boost::mutex::scoped_lock( module_function_sorry_disable_mutex );
330 if( session_pause_flag )break;
333 std::cout << "DOWN:STOP(" << i << ")" << std::endl;
336 void l7vs::tcp_session::thread_state_update(const std::bitset<TCP_SESSION_THREAD_STATE_BIT> thread_flag,const bool regist){}
337 void l7vs::tcp_session::up_thread_client_accept_event(const TCP_PROCESS_TYPE_TAG process_type){}
338 void l7vs::tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_type){}
339 void l7vs::tcp_session::up_thread_client_respond(const TCP_PROCESS_TYPE_TAG process_type){}
340 void l7vs::tcp_session::up_thread_client_respond_event(const TCP_PROCESS_TYPE_TAG process_type){}
341 void l7vs::tcp_session::up_thread_client_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
342 void l7vs::tcp_session::up_thread_client_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type){}
343 void l7vs::tcp_session::up_thread_realserver_send(const TCP_PROCESS_TYPE_TAG process_type){}
344 void l7vs::tcp_session::up_thread_realserver_get_destination_event(const TCP_PROCESS_TYPE_TAG process_type){}
345 void l7vs::tcp_session::up_thread_realserver_connect(const TCP_PROCESS_TYPE_TAG process_type){}
346 void l7vs::tcp_session::up_thread_realserver_connect_event(const TCP_PROCESS_TYPE_TAG process_type){}
347 void l7vs::tcp_session::up_thread_realserver_connection_fail_event(const TCP_PROCESS_TYPE_TAG process_type){}
348 void l7vs::tcp_session::up_thread_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
349 void l7vs::tcp_session::up_thread_realserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type){}
350 void l7vs::tcp_session::up_thread_all_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
351 void l7vs::tcp_session::up_thread_sorryserver_send(const TCP_PROCESS_TYPE_TAG process_type){}
352 void l7vs::tcp_session::up_thread_sorryserver_get_destination_event(const TCP_PROCESS_TYPE_TAG process_type){}
353 void l7vs::tcp_session::up_thread_sorryserver_connect(const TCP_PROCESS_TYPE_TAG process_type){}
354 void l7vs::tcp_session::up_thread_sorryserver_connect_event(const TCP_PROCESS_TYPE_TAG process_type){}
355 void l7vs::tcp_session::up_thread_sorryserver_connection_fail_event(const TCP_PROCESS_TYPE_TAG process_type){}
356 void l7vs::tcp_session::up_thread_sorryserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
357 void l7vs::tcp_session::up_thread_sorryserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type){}
358 void l7vs::tcp_session::up_thread_sorry_enable_event(const TCP_PROCESS_TYPE_TAG process_type){}
359 void l7vs::tcp_session::up_thread_sorry_disable_event(const TCP_PROCESS_TYPE_TAG process_type){}
360 void l7vs::tcp_session::up_thread_sorryserver_mod_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
361 void l7vs::tcp_session::up_thread_exit(const TCP_PROCESS_TYPE_TAG process_type){}
362 void l7vs::tcp_session::up_thread_all_socket_close(void){}
364 void l7vs::tcp_session::down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG process_type){}
365 void l7vs::tcp_session::down_thread_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
366 void l7vs::tcp_session::down_thread_realserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type){}
367 void l7vs::tcp_session::down_thread_all_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
368 void l7vs::tcp_session::down_thread_client_connection_chk_event(const TCP_PROCESS_TYPE_TAG process_type){}
369 void l7vs::tcp_session::down_thread_client_respond_event(const TCP_PROCESS_TYPE_TAG process_type){}
370 void l7vs::tcp_session::down_thread_client_send(const TCP_PROCESS_TYPE_TAG process_type){}
371 void l7vs::tcp_session::down_thread_client_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
372 void l7vs::tcp_session::down_thread_client_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type){}
373 void l7vs::tcp_session::down_thread_sorryserver_receive(const TCP_PROCESS_TYPE_TAG process_type){}
374 void l7vs::tcp_session::down_thread_sorryserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
375 void l7vs::tcp_session::down_thread_sorryserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type){}
376 void l7vs::tcp_session::down_thread_sorry_enable_event(const TCP_PROCESS_TYPE_TAG process_type){}
377 void l7vs::tcp_session::down_thread_sorryserver_mod_disconnect(const TCP_PROCESS_TYPE_TAG process_type){}
378 void l7vs::tcp_session::down_thread_sorry_disable_event(const TCP_PROCESS_TYPE_TAG process_type){}
379 void l7vs::tcp_session::down_thread_exit(const TCP_PROCESS_TYPE_TAG process_type){}
380 void l7vs::tcp_session::down_thread_all_socket_close(){}
383 l7vs::udp_session::udp_session(virtualservice_udp& vs, boost::asio::io_service& session_io) : io( session_io ),
384 parent_service( vs ),
385 client_side_socket( io ) {}
386 l7vs::udp_session::~udp_session(){}
387 l7vs::session_result_message l7vs::udp_session::initialize(const udp_endpoint listen_end){
388 l7vs::session_result_message result;
392 void l7vs::udp_session::set_virtual_service_message(const UDP_VIRTUAL_SERVICE_MESSAGE_TAG message){}
393 void l7vs::udp_session::run(void){}
394 bool l7vs::udp_session::client_send(const udp_endpoint client_endpoint, const udp_session_buff& data_buff,const std::size_t data_size,boost::system::error_code& ec){
397 void l7vs::udp_session::release_request(const boost::thread::id release_thread_id){}
399 void l7vs::udp_session::make_request_thread(const int max_count){}
400 void l7vs::udp_session::active_request_thread(const udp_endpoint client_endpoint , const udp_session_buff receive_data, const std::size_t receive_size){}
401 void l7vs::udp_session::all_active_request_stop(void){}