ctdb-mutex: Drop dependency on ctdb_set_helper
[amitay/samba.git] / ctdb / server / ipalloc_private.h
1 /*
2    CTDB IP takeover code
3
4    Copyright (C) Ronnie Sahlberg  2007
5    Copyright (C) Andrew Tridgell  2007
6    Copyright (C) Martin Schwenke  2015
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (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
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef __CTDB_IPALLOC_PRIVATE_H__
23 #define __CTDB_IPALLOC_PRIVATE_H__
24
25 #include "protocol/protocol.h"
26
27 #include "server/ipalloc.h"
28
29 struct ipalloc_state {
30         uint32_t num;
31
32         /* Arrays with data for each node */
33         struct ctdb_public_ip_list *available_public_ips;
34         struct ctdb_public_ip_list *known_public_ips;
35
36         struct public_ip_list *all_ips;
37         enum ipalloc_algorithm algorithm;
38         bool no_ip_failback;
39         bool no_ip_takeover;
40         uint32_t *force_rebalance_nodes;
41 };
42
43 bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
44                           int32_t pnn,
45                           struct public_ip_list *ip);
46 int node_ip_coverage(uint32_t pnn, struct public_ip_list *ips);
47 int find_takeover_node(struct ipalloc_state *ipalloc_state,
48                        struct public_ip_list *ip);
49
50 void unassign_unsuitable_ips(struct ipalloc_state *ipalloc_state);
51 void basic_allocate_unassigned(struct ipalloc_state *ipalloc_state);
52
53 bool ipalloc_nondeterministic(struct ipalloc_state *ipalloc_state);
54 bool ipalloc_deterministic(struct ipalloc_state *ipalloc_state);
55 bool ipalloc_lcp2(struct ipalloc_state *ipalloc_state);
56
57 #endif /* __CTDB_IPALLOC_PRIVATE_H__ */