// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
//
-#ifndef L7COMMAND_H
-#define L7COMMAND_H
+#ifndef L7VS_COMMAND_H
+#define L7VS_COMMAND_H
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include "logger_enum.h"
#include "parameter_enum.h"
#include "l7vs_replication.h"
-#include "l7vs_realserver_element.h"
-#include "l7vs_virtualservice_command_element.h"
+#include "virtualservice_element.h"
namespace l7vs{
//
};
enum REPLICATION_COMMAND_TAG{
REP_NONE = 0,
- REP_START // !< REPLICATION START COMMAND
+ REP_START, // !< REPLICATION START COMMAND
REP_STOP, // !< REPLICATION STOP COMMAND
REP_FORCE, // !< REPLICATION FORCE COMMAND
REP_DUMP // !< REPLICATION DUMP COMMAND
COMMAND_CODE_TAG command;
virtualservice_element vs_element;
- REPLICATION_CODE_TAG replication_command;
+ REPLICATION_COMMAND_TAG replication_command;
LOG_CATEGORY_TAG log_category;
LOG_LEVEL_TAG log_level;
PARAMETER_COMPONENT_TAG reload_param;
- PARAMETER_COMPONENT_TAG snmp_log_category;
+ LOG_CATEGORY_TAG snmp_log_category;
LOG_LEVEL_TAG snmp_log_level;
l7vsadm_request() : command( CMD_NONE ),
replication_command( REP_NONE ),
std::string message;
- std::list< l7vs_virtualservice_element >
+ std::list< virtualservice_element >
virtualservice_status_list;
REPLICATION_MODE_TAG replication_mode_status;
--- /dev/null
+/*
+ * @file l7vs_replication.h
+ * @bref The Replication of data between ACT and STB.
+ *
+ * L7VSD: Linux Virtual Server for Layer7 Load Balancing
+ * Copyright (C) 2005 NTT COMWARE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ **********************************************************************/
+#ifndef L7VS_REPLICATION_H
+#define L7VS_REPLICATION_H
+
+
+//! Max Number of Components
+#define CMP_MAX (100)
+
+//! Max Size of Components
+#define CMP_BLOCK_MAX (100000)
+
+//! Key's length of Component ID
+#define ID_LENGTH (17)
+
+//! REPLICATION_SLAVE of Component SIZE
+#define CMP_SIZE_LENGTH (17)
+
+//! Maximum size of input/output raw data
+#define DATA_SIZE (480)
+
+//! Maximum size of input/output raw data
+#define SEND_DATA_SIZE (512)
+
+//! Min Interval
+#define MIN_INTERVAL (10)
+
+//! Max Interval
+#define MAX_INTERVAL (10000)
+
+//! Min Compulsorily Interval
+#define MIN_COMPULSORILRY_INTERVAL (4)
+
+//! Max Compulsorily Interval
+#define MAX_COMPULSORILRY_INTERVAL (400)
+
+//! Set nic length
+#define NIC_LENGTH (128)
+
+//! Dump log data's width
+#define LOG_DATA_WIDTH (16)
+
+//! Replication data ID
+#define REPLICATION_ID (37)
+
+#include <netdb.h>
+#include <stdint.h>
+
+//! Mode Type
+enum REPLICATION_MODE_TAG{
+ REPLICATION_OUT, //!< Initial
+ REPLICATION_SINGLE, //!< Single
+ REPLICATION_MASTER, //!< Master isActive
+ REPLICATION_SLAVE, //!< Slave isActive
+ REPLICATION_MASTER_STOP, //!< Master isStop
+ REPLICATION_SLAVE_STOP //!< Slave isStop
+};
+
+//! Transfer data between active server and standby server.
+struct l7vs_replication_data{
+ unsigned short id; //!< ID of Replication Function
+ char pad1[6];
+ unsigned long long serial; //!< Serial Number
+ unsigned int block_num; //!< Block Number in Replication memory
+ char pad2[4];
+ uint64_t size; //!< Data size for checking packet loss
+ char data[DATA_SIZE];//!< Raw data
+};
+
+//! Component information set to SG file.
+struct l7vs_replication_component{
+ char id[ID_LENGTH]; //!< ID distinguishes Component
+ unsigned int block_head; //!< The first Block Number of Component's memory
+ unsigned int block_size; //!< Number of Block allocated in component memory
+};
+
+//! State Infomation struct to execute Replication.
+struct l7vs_replication_state{
+ enum REPLICATION_MODE_TAG service_status; //!< States Type of Replication Function
+ unsigned long long send_time; //!< Completion last time to send data
+ unsigned int last_send_block; //!< Completion last Block Number to send data
+ unsigned int last_recv_block; //!< Completion last Block Number to receive data
+ unsigned int total_block; //!< The maximum Block Number of Components memory
+ void * replication_memory; //!< Top address in Replication memory
+ void * component_memory; //!< Top address in Component memory
+ uint64_t sarface_block_no; //!< Serial number for respect switch
+ uint64_t * sarface_block_array_ptr;//!< Serial number in received respect at every block
+};
+
+//! Essential information set to SG file.
+struct l7vs_replication_info{
+ char ip_addr[NI_MAXHOST]; //!< Destination IP address (IPv4 or IPv6)
+ char service_name[NI_MAXSERV]; //!< Destination service name or port number
+ char nic[NIC_LENGTH]; //!< Network device (ex. eth0, bond0, hme0, etc.)
+ unsigned short interval; //!< Interval when data of one block is sent
+ int component_num; //!< Number of components read setting
+ struct l7vs_replication_component component_info[CMP_MAX]; //!< Information on individual component
+};
+
+
+// External function
+
+// Initialize of Replication Function
+extern int l7vs_replication_init();
+
+// Finalize of Replication Function
+extern void l7vs_replication_fini();
+
+// Switches Slave to Master ( VirtualService is added )
+extern void l7vs_replication_switch_to_master();
+
+// Switches Master to Slave ( VirtualService is deleted )
+extern void l7vs_replication_switch_to_slave();
+
+// Allocate the memory of the component.
+extern void *l7vs_replication_pay_memory( char* component_id, unsigned int* size );
+
+// Replication Callback
+extern int l7vs_replication_send_callback( struct l7vs_iomux *iom );
+
+// Replication Callback
+extern int l7vs_replication_recv_callback( struct l7vs_iomux *iom );
+
+// Dump Replication info to the Log.
+extern void l7vs_replication_dump_memory();
+
+// Starting the Replication
+extern void l7vs_replication_start();
+
+// Stopping the Replication
+extern void l7vs_replication_stop();
+
+// Compulsorily executes the replication.
+extern void l7vs_replication_compulsorily();
+
+// Re-Sets the Interval
+extern void l7vs_replication_reset();
+
+// Acquires the state
+extern enum REPLICATION_MODE_TAG l7vs_replication_get_status();
+
+// Check the interval time
+extern int l7vs_replication_checkinterval();
+
+
+#endif
--- /dev/null
+#include <boost/test/included/unit_test.hpp>
+#include <boost/asio.hpp>
+#include "../../include/l7vs_command.h"
+
+using namespace boost::unit_test;
+using namespace l7vs;
+
+//
+// using string to endpoint template function
+//
+template< typename InternetProtocol >
+boost::asio::ip::basic_endpoint< InternetProtocol > string_to_endpoint( std::string str ){
+ std::string::size_type pos = str.find( ":" );
+ std::string hostname = str.substr( 0, pos );
+ std::string portname = str.substr( pos+1, str.length() );
+ boost::asio::io_service io_service;
+ typename InternetProtocol::resolver resolver(io_service);
+ typename InternetProtocol::resolver::query query( hostname, portname );
+ typename InternetProtocol::resolver::iterator end;
+ typename InternetProtocol::resolver::iterator itr = resolver.resolve( query );
+ if( itr == end ) return typename InternetProtocol::endpoint();
+ return *itr;
+}
+
+
+// testcase 1.
+void realserver_element_test(){
+ realserver_element rs;
+ boost::asio::ip::tcp::endpoint tcp_default_endpoint;
+ boost::asio::ip::udp::endpoint udp_default_endpoint;
+ // unit_test[1] default constractor tcp endpoint test
+ BOOST_CHECK( rs.tcp_endpoint == tcp_default_endpoint );
+ // unit_test[2] default constractor udp endpoint test
+ BOOST_CHECK( rs.udp_endpoint == udp_default_endpoint );
+ // unit_test[3] default constrafctor weight test
+ BOOST_CHECK( rs.weight == -1 );
+ rs.tcp_endpoint = string_to_endpoint<boost::asio::ip::tcp>( "10.10.10.10:6555" );
+ rs.udp_endpoint = string_to_endpoint<boost::asio::ip::udp>( "20.20.20.20:4444" );
+ rs.weight = 255;
+
+ realserver_element rs2 = rs;
+ // unit_test[4] copy constractor tcp endpoint test
+ BOOST_CHECK( rs.tcp_endpoint == rs2.tcp_endpoint );
+ // unit_test[5] copy constractor udp endpoint test
+ BOOST_CHECK( rs.udp_endpoint == rs2.udp_endpoint );
+
+}
+
+
+test_suite* init_unit_test_suite( int argc, char* argv[] ){
+
+ // create unit test suite
+ test_suite* ts = BOOST_TEST_SUITE( "l7vs_command_ut" );
+ ts->add( BOOST_TEST_CASE( &realserver_element_test ) );
+
+ framework::master_test_suite().add( ts );
+
+ return 0;
+}
+