2 * @file schedule_module_wrr.h
3 * @brief shared object schedule module class
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 **********************************************************************/
24 #ifndef SCHEDULE_MODULE_WRR_H
25 #define SCHEDULE_MODULE_WRR_H
27 #include "schedule_module_base.h"
32 class schedule_module_weighted_round_robin : public schedule_module_base
35 boost::asio::ip::tcp::endpoint tcp_endpoint ;
36 boost::asio::ip::udp::endpoint udp_endpoint ;
39 int currentWeight; /*! Current Weight */
40 int maxWeight; /*! Max of Weight */
41 int gcd; /*! G.C.D. of RealServer list */
42 wrr_weights() : currentWeight(0), maxWeight(0), gcd(0) {}
46 schedule_module_weighted_round_robin();
48 ~schedule_module_weighted_round_robin();
50 //! initialize function
53 //! tcp protocol support check
54 //! @return tcp support is true
55 //! @return tcp not-support is false
57 //! udp protocol support check
58 //! @return udp support is true
59 //! @return udp not-support is false
62 //! handle schedule called then schedule function for TCP/IP endpoint
63 //! @param[in] thread id
64 //! @param[in] list iterator first function object
65 //! @param[in] list iterator last function object
66 //! @param[in] list iterator next function object
67 //! @param[out] scheduled TCP/IP endpoint
69 boost::thread::id thread_id,
70 rslist_iterator_begin_func_type inlist_begin,
71 rslist_iterator_end_func_type inlist_end,
72 rslist_iterator_next_func_type inlist_next,
73 boost::asio::ip::tcp::endpoint &outendpoint);
75 //! handle schedule calls then schedule function for UDP endpoint
76 //! @param[in] thread id
77 //! @param[in] list iterator first function object
78 //! @param[in] list iterator last function object
79 //! @param[in] list iterator next function object
80 //! @param[out] scheduled UDP endpoint
82 boost::thread::id thread_id,
83 rslist_iterator_begin_func_type inlist_begin,
84 rslist_iterator_end_func_type inlist_end,
85 rslist_iterator_next_func_type inlist_next,
86 boost::asio::ip::udp::endpoint &outendpoint);
88 //! replication interval interrupt
89 //! timer thread call this function. from virtualservice.
90 void replication_interrupt();
93 int sched_wrr_service_init(
94 rslist_iterator_begin_func_type inlist_begin,
95 rslist_iterator_end_func_type inlist_end,
96 rslist_iterator_next_func_type inlist_next);
97 int sched_wrr_getMaxWeight(
98 rslist_iterator_begin_func_type inlist_begin,
99 rslist_iterator_end_func_type inlist_end,
100 rslist_iterator_next_func_type inlist_next);
101 int sched_wrr_gcd(int a, int b);
102 int sched_wrr_getGCD(
103 rslist_iterator_begin_func_type inlist_begin,
104 rslist_iterator_end_func_type inlist_end,
105 rslist_iterator_next_func_type inlist_next);
110 #endif //SCHEDULE_MODULE_WRR_H