corosync  2.3.5-dirty
include/corosync/votequorum.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2012 Red Hat, Inc.
3  *
4  * All rights reserved.
5  *
6  * Authors: Christine Caulfield (ccaulfie@redhat.com)
7  * Fabio M. Di Nitto (fdinitto@redhat.com)
8  *
9  * This software licensed under BSD license, the text of which follows:
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * - Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * - Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  * - Neither the name of the MontaVista Software, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33  * THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef COROSYNC_VOTEQUORUM_H_DEFINED
37 #define COROSYNC_VOTEQUORUM_H_DEFINED
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 typedef uint64_t votequorum_handle_t;
44 
45 #define VOTEQUORUM_INFO_TWONODE 1
46 #define VOTEQUORUM_INFO_QUORATE 2
47 #define VOTEQUORUM_INFO_WAIT_FOR_ALL 4
48 #define VOTEQUORUM_INFO_LAST_MAN_STANDING 8
49 #define VOTEQUORUM_INFO_AUTO_TIE_BREAKER 16
50 #define VOTEQUORUM_INFO_ALLOW_DOWNSCALE 32
51 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64
52 #define VOTEQUORUM_INFO_QDEVICE_ALIVE 128
53 #define VOTEQUORUM_INFO_QDEVICE_CAST_VOTE 256
54 #define VOTEQUORUM_INFO_QDEVICE_MASTER_WINS 512
55 
56 #define VOTEQUORUM_QDEVICE_NODEID 0
57 #define VOTEQUORUM_QDEVICE_MAX_NAME_LEN 255
58 #define VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT 10000
59 #define VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT 30000
60 
61 #define VOTEQUORUM_NODESTATE_MEMBER 1
62 #define VOTEQUORUM_NODESTATE_DEAD 2
63 #define VOTEQUORUM_NODESTATE_LEAVING 3
64 
68  unsigned int node_id;
69  unsigned int node_state;
70  unsigned int node_votes;
71  unsigned int node_expected_votes;
72  unsigned int highest_expected;
73  unsigned int total_votes;
74  unsigned int quorum;
75  unsigned int flags;
76  unsigned int qdevice_votes;
78 };
79 
80 typedef struct {
81  uint32_t nodeid;
82  uint32_t state;
84 
85 typedef struct {
86  uint32_t nodeid;
87  uint64_t seq;
89 
91  votequorum_handle_t handle,
92  uint64_t context,
93  uint32_t quorate,
95  uint32_t node_list_entries,
96  votequorum_node_t node_list[]);
97 
99  votequorum_handle_t handle,
100  uint64_t context,
101  uint32_t expected_votes);
102 
103 typedef struct {
107 
108 
113  votequorum_handle_t *handle,
114  votequorum_callbacks_t *callbacks);
115 
120  votequorum_handle_t handle);
121 
122 
127  votequorum_handle_t handle,
128  cs_dispatch_flags_t dispatch_types);
129 
137  votequorum_handle_t handle,
138  int *fd);
139 
144  votequorum_handle_t handle,
145  unsigned int nodeid,
146  struct votequorum_info *info);
147 
152  votequorum_handle_t handle,
153  unsigned int expected_votes);
154 
159  votequorum_handle_t handle,
160  unsigned int nodeid,
161  unsigned int votes);
162 
167  votequorum_handle_t handle,
168  uint64_t context,
169  unsigned int flags );
170 
172  votequorum_handle_t handle);
173 
178  votequorum_handle_t handle,
179  void **context);
180 
182  votequorum_handle_t handle,
183  void *context);
184 
191  votequorum_handle_t handle,
192  const char *name);
193 
198  votequorum_handle_t handle,
199  const char *name);
200 
205  votequorum_handle_t handle,
206  const char *oldname,
207  const char *newname);
208 
213  votequorum_handle_t handle,
214  const char *name,
215  unsigned int cast_vote,
216  votequorum_ring_id_t ring_id);
217 
222  votequorum_handle_t handle,
223  const char *name,
224  unsigned int allow);
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 #endif /* COROSYNC_VOTEQUORUM_H_DEFINED */
uint32_t votes
char oldname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
cs_error_t votequorum_qdevice_update(votequorum_handle_t handle, const char *oldname, const char *newname)
Update registered name of a quorum device.
#define VOTEQUORUM_QDEVICE_MAX_NAME_LEN
uint64_t votequorum_handle_t
cs_error_t votequorum_getinfo(votequorum_handle_t handle, unsigned int nodeid, struct votequorum_info *info)
Get quorum information.
cs_error_t votequorum_setexpected(votequorum_handle_t handle, unsigned int expected_votes)
set expected_votes
cs_error_t votequorum_trackstart(votequorum_handle_t handle, uint64_t context, unsigned int flags)
Track node and quorum changes.
cs_error_t votequorum_dispatch(votequorum_handle_t handle, cs_dispatch_flags_t dispatch_types)
Dispatch messages and configuration changes.
cs_error_t votequorum_setvotes(votequorum_handle_t handle, unsigned int nodeid, unsigned int votes)
set votes for a node
cs_error_t votequorum_qdevice_unregister(votequorum_handle_t handle, const char *name)
Unregister a quorum device.
cs_error_t votequorum_context_get(votequorum_handle_t handle, void **context)
Save and retrieve private data/context.
void(* votequorum_notification_fn_t)(votequorum_handle_t handle, uint64_t context, uint32_t quorate, votequorum_ring_id_t ring_id, uint32_t node_list_entries, votequorum_node_t node_list[])
uint32_t expected_votes
cs_error_t votequorum_trackstop(votequorum_handle_t handle)
cs_error_t votequorum_finalize(votequorum_handle_t handle)
Close the quorum handle.
cs_error_t votequorum_initialize(votequorum_handle_t *handle, votequorum_callbacks_t *callbacks)
Create a new quorum connection.
cs_error_t votequorum_fd_get(votequorum_handle_t handle, int *fd)
Get a file descriptor on which to poll.
uint32_t flags
cs_error_t votequorum_context_set(votequorum_handle_t handle, void *context)
cs_error_t
Definition: corotypes.h:78
cs_dispatch_flags_t
Definition: corotypes.h:67
votequorum_expectedvotes_notification_fn_t votequorum_expectedvotes_notify_fn
cs_error_t votequorum_qdevice_master_wins(votequorum_handle_t handle, const char *name, unsigned int allow)
Allow qdevice to tell votequorum if master_wins can be enabled or not.
uint32_t quorate
Definition: sam.c:133
votequorum_notification_fn_t votequorum_notify_fn
char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
cs_error_t votequorum_qdevice_register(votequorum_handle_t handle, const char *name)
Register a quorum device.
char newname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
void(* votequorum_expectedvotes_notification_fn_t)(votequorum_handle_t handle, uint64_t context, uint32_t expected_votes)
unsigned int nodeid
Definition: coroapi.h:65
struct memb_ring_id ring_id
Definition: totemsrp.c:64
cs_error_t votequorum_qdevice_poll(votequorum_handle_t handle, const char *name, unsigned int cast_vote, votequorum_ring_id_t ring_id)
Poll a quorum device.