OSDN Git Service

Update INSTALL.ja.utf-8 for new release.
[ultramonkey-l7/ultramonkey-l7-v2.git] / include / l7vs_replication.h
1 /*
2  * @file        l7vs_replication.h
3  * @bref        The Replication of data between ACT and STB.
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2005  NTT COMWARE Corporation.
7  *
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.
12  *
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.
17  *
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
21  * 02110-1301 USA
22  *
23  **********************************************************************/
24 #ifndef L7VS_REPLICATION_H
25 #define L7VS_REPLICATION_H
26
27
28 //! Max Number of Components
29 #define CMP_MAX (100)
30
31 //! Max Size of Components
32 #define CMP_BLOCK_MAX (100000)
33
34 //! Key's length of Component ID
35 #define ID_LENGTH (17)
36
37 //! REPLICATION_SLAVE of Component SIZE
38 #define CMP_SIZE_LENGTH (17)
39
40 //! Maximum size of input/output raw data
41 #define DATA_SIZE (480)
42
43 //! Maximum size of input/output raw data
44 #define SEND_DATA_SIZE (512)
45
46 //! Min Interval
47 #define MIN_INTERVAL (10)
48
49 //! Max Interval
50 #define MAX_INTERVAL (10000)
51
52 //! Min Compulsorily Interval
53 #define MIN_COMPULSORILRY_INTERVAL (4)
54
55 //! Max Compulsorily Interval
56 #define MAX_COMPULSORILRY_INTERVAL (400)
57
58 //! Set nic length
59 #define NIC_LENGTH (128)
60
61 //! Dump log data's width
62 #define LOG_DATA_WIDTH (16)
63
64 //! Replication data ID
65 #define REPLICATION_ID (37)
66
67 #include <netdb.h>
68 #include <stdint.h>
69
70 //! Mode Type
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
78 };
79
80 //! Transfer data between active server and standby server.
81 struct l7vs_replication_data{
82         unsigned short          id;             //!< ID of Replication Function
83         char                    pad1[6];
84         unsigned long long      serial;         //!< Serial Number
85         unsigned int            block_num;      //!< Block Number in Replication memory
86         char                    pad2[4];
87         uint64_t                size;           //!< Data size for checking packet loss
88         char                    data[DATA_SIZE];//!< Raw data
89 };
90
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
96 };
97
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
109 };
110
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
119 };
120
121
122 // External function
123
124 // Initialize of Replication Function
125 extern int l7vs_replication_init();
126
127 // Finalize of Replication Function
128 extern void l7vs_replication_fini();
129
130 // Switches Slave to Master ( VirtualService is added )
131 extern void l7vs_replication_switch_to_master();
132
133 // Switches Master to Slave ( VirtualService is deleted )
134 extern void l7vs_replication_switch_to_slave();
135
136 // Allocate the memory of the component.
137 extern void *l7vs_replication_pay_memory( char* component_id, unsigned int* size );
138
139 // Replication Callback
140 extern int l7vs_replication_send_callback( struct l7vs_iomux *iom );
141
142 // Replication Callback
143 extern int l7vs_replication_recv_callback( struct l7vs_iomux *iom );
144
145 // Dump Replication info to the Log.
146 extern void l7vs_replication_dump_memory();
147
148 // Starting the Replication
149 extern void l7vs_replication_start();
150
151 // Stopping the Replication
152 extern void l7vs_replication_stop();
153
154 // Compulsorily executes the replication.
155 extern void l7vs_replication_compulsorily();
156
157 // Re-Sets the Interval
158 extern void l7vs_replication_reset();
159
160 // Acquires the state
161 extern enum REPLICATION_MODE_TAG l7vs_replication_get_status();
162
163 // Check the interval time
164 extern int l7vs_replication_checkinterval();
165
166
167 #endif