2 * @file l7vs_replication.h
3 * @bref The Replication of data between ACT and STB.
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6 * Copyright (C) 2005 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 **********************************************************************/
24 #ifndef L7VS_REPLICATION_H
25 #define L7VS_REPLICATION_H
28 //! Max Number of Components
31 //! Max Size of Components
32 #define CMP_BLOCK_MAX (100000)
34 //! Key's length of Component ID
35 #define ID_LENGTH (17)
37 //! REPLICATION_SLAVE of Component SIZE
38 #define CMP_SIZE_LENGTH (17)
40 //! Maximum size of input/output raw data
41 #define DATA_SIZE (480)
43 //! Maximum size of input/output raw data
44 #define SEND_DATA_SIZE (512)
47 #define MIN_INTERVAL (10)
50 #define MAX_INTERVAL (10000)
52 //! Min Compulsorily Interval
53 #define MIN_COMPULSORILRY_INTERVAL (4)
55 //! Max Compulsorily Interval
56 #define MAX_COMPULSORILRY_INTERVAL (400)
59 #define NIC_LENGTH (128)
61 //! Dump log data's width
62 #define LOG_DATA_WIDTH (16)
64 //! Replication data ID
65 #define REPLICATION_ID (37)
71 enum REPLICATION_MODE_TAG{
72 REPLICATION_OUT, //!< Initial
73 REPLICATION_SINGLE, //!< Single
74 REPLICATION_MASTER, //!< Master isActive
75 REPLICATION_SLAVE, //!< Slave isActive
76 REPLICATION_MASTER_STOP, //!< Master isStop
77 REPLICATION_SLAVE_STOP //!< Slave isStop
80 //! Transfer data between active server and standby server.
81 struct l7vs_replication_data{
82 unsigned short id; //!< ID of Replication Function
84 unsigned long long serial; //!< Serial Number
85 unsigned int block_num; //!< Block Number in Replication memory
87 uint64_t size; //!< Data size for checking packet loss
88 char data[DATA_SIZE];//!< Raw data
91 //! Component information set to SG file.
92 struct l7vs_replication_component{
93 char id[ID_LENGTH]; //!< ID distinguishes Component
94 unsigned int block_head; //!< The first Block Number of Component's memory
95 unsigned int block_size; //!< Number of Block allocated in component memory
98 //! State Infomation struct to execute Replication.
99 struct l7vs_replication_state{
100 enum REPLICATION_MODE_TAG service_status; //!< States Type of Replication Function
101 unsigned long long send_time; //!< Completion last time to send data
102 unsigned int last_send_block; //!< Completion last Block Number to send data
103 unsigned int last_recv_block; //!< Completion last Block Number to receive data
104 unsigned int total_block; //!< The maximum Block Number of Components memory
105 void * replication_memory; //!< Top address in Replication memory
106 void * component_memory; //!< Top address in Component memory
107 uint64_t sarface_block_no; //!< Serial number for respect switch
108 uint64_t * sarface_block_array_ptr;//!< Serial number in received respect at every block
111 //! Essential information set to SG file.
112 struct l7vs_replication_info{
113 char ip_addr[NI_MAXHOST]; //!< Destination IP address (IPv4 or IPv6)
114 char service_name[NI_MAXSERV]; //!< Destination service name or port number
115 char nic[NIC_LENGTH]; //!< Network device (ex. eth0, bond0, hme0, etc.)
116 unsigned short interval; //!< Interval when data of one block is sent
117 int component_num; //!< Number of components read setting
118 struct l7vs_replication_component component_info[CMP_MAX]; //!< Information on individual component
124 // Initialize of Replication Function
125 extern int l7vs_replication_init();
127 // Finalize of Replication Function
128 extern void l7vs_replication_fini();
130 // Switches Slave to Master ( VirtualService is added )
131 extern void l7vs_replication_switch_to_master();
133 // Switches Master to Slave ( VirtualService is deleted )
134 extern void l7vs_replication_switch_to_slave();
136 // Allocate the memory of the component.
137 extern void *l7vs_replication_pay_memory( char* component_id, unsigned int* size );
139 // Replication Callback
140 extern int l7vs_replication_send_callback( struct l7vs_iomux *iom );
142 // Replication Callback
143 extern int l7vs_replication_recv_callback( struct l7vs_iomux *iom );
145 // Dump Replication info to the Log.
146 extern void l7vs_replication_dump_memory();
148 // Starting the Replication
149 extern void l7vs_replication_start();
151 // Stopping the Replication
152 extern void l7vs_replication_stop();
154 // Compulsorily executes the replication.
155 extern void l7vs_replication_compulsorily();
157 // Re-Sets the Interval
158 extern void l7vs_replication_reset();
160 // Acquires the state
161 extern enum REPLICATION_MODE_TAG l7vs_replication_get_status();
163 // Check the interval time
164 extern int l7vs_replication_checkinterval();