Willy Tarreau | 5b4c2b5 | 2009-10-03 11:21:53 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/types/lb_fwrr.h |
| 3 | * Types for Fast Weighted Round Robin load balancing algorithm. |
| 4 | * |
| 5 | * Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TYPES_LB_FWRR_H |
| 23 | #define _TYPES_LB_FWRR_H |
| 24 | |
| 25 | #include <common/config.h> |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 26 | #include <ebtree.h> |
Willy Tarreau | 5b4c2b5 | 2009-10-03 11:21:53 +0200 | [diff] [blame] | 27 | |
| 28 | /* This structure is used to apply fast weighted round robin on a server group */ |
| 29 | struct fwrr_group { |
| 30 | struct eb_root curr; /* tree for servers in "current" time range */ |
| 31 | struct eb_root t0, t1; /* "init" and "next" servers */ |
| 32 | struct eb_root *init; /* servers waiting to be placed */ |
| 33 | struct eb_root *next; /* servers to be placed at next run */ |
| 34 | int curr_pos; /* current position in the tree */ |
| 35 | int curr_weight; /* total weight of the current time range */ |
| 36 | int next_weight; /* total weight of the next time range */ |
| 37 | }; |
| 38 | |
| 39 | struct lb_fwrr { |
| 40 | struct fwrr_group act; /* weighted round robin on the active servers */ |
| 41 | struct fwrr_group bck; /* weighted round robin on the backup servers */ |
| 42 | }; |
| 43 | |
| 44 | #endif /* _TYPES_LB_FWRR_H */ |
| 45 | |
| 46 | /* |
| 47 | * Local variables: |
| 48 | * c-indent-level: 8 |
| 49 | * c-basic-offset: 8 |
| 50 | * End: |
| 51 | */ |