2 * @file ip_replication_data_processor.h
3 * @brief ip replication data processor header file.
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6 * Copyright (C) 2009 NTT COMWARE Corporation.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 **********************************************************************/
25 #ifndef IP_REPLICATION_DATA_PROCESSOR_H
26 #define IP_REPLICATION_DATA_PROCESSOR_H
28 #include <boost/asio.hpp>
29 #include <boost/thread/condition.hpp>
30 #include "logger_enum.h"
32 #define IP_MAXLENGTH (40)
33 #define IP_SERVICE_NUMBER (128)
34 #define IP_REPLICATION_MAXLENGTH (256)
35 #define MAX_IP_SESSION_TEMPLIST_SIZE (20000)
40 struct ip_replication_data_header {
41 char virtualserver_ip[IP_MAXLENGTH];
42 unsigned short virtualserver_port;
47 struct ip_replication_data {
48 char realserver_ip[IP_MAXLENGTH];
49 unsigned short realserver_port;
54 struct ip_replication_temp_data {
58 boost::asio::ip::tcp::endpoint rs_endpoint;
61 class ip_replication_data_processor
64 //! loglevel get function object type
65 typedef boost::function< LOG_LEVEL_TAG(void) >
66 getloglevel_func_type;
67 //! log output function object type
68 typedef boost::function< void (const unsigned int, const std::string &, const char *, int) >
72 ip_replication_data_processor(char *ip_replication_area_begin,
73 int ip_replication_area_size,
74 const boost::asio::ip::tcp::endpoint &virtual_service_endpoint,
75 getloglevel_func_type ingetloglevel,
76 logger_func_type inputLogFatal,
77 logger_func_type inputLogError,
78 logger_func_type inputLogWarn,
79 logger_func_type inputLogInfo,
80 logger_func_type inputLogDebug);
82 virtual ~ip_replication_data_processor();
84 void put_into_temp_list(const ip_replication_temp_data &data);
86 void write_replication_area();
88 ip_replication_data *get_replication_area();
90 void register_replication_area_lock(boost::function<void(void)> intable_lock);
92 void register_replication_area_unlock(boost::function<void(void)> intable_unlock);
95 int get_from_temp_list(ip_replication_temp_data &data);
98 std::deque<ip_replication_temp_data> temp_list;
99 boost::mutex temp_list_mutex;
100 boost::condition temp_list_condition;
101 ip_replication_data *replication_area;
102 boost::function<void(void)> replication_area_lock;
103 boost::function<void(void)> replication_area_unlock;
104 boost::asio::ip::tcp::endpoint virtual_service_endpoint;
105 getloglevel_func_type getloglevel; //! get loglevel function object
106 logger_func_type putLogFatal; //! fatal log output function object
107 logger_func_type putLogError; //! error log output function object
108 logger_func_type putLogWarn; //! warn log output function object
109 logger_func_type putLogInfo; //! info log output function object
110 logger_func_type putLogDebug; //! debug log output function object
115 #endif // IP_REPLICATION_DATA_PROCESSOR_H