corosync  2.4.1
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 #include <corosync/corotypes.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
48 typedef uint64_t votequorum_handle_t;
49 
50 #define VOTEQUORUM_INFO_TWONODE 1
51 #define VOTEQUORUM_INFO_QUORATE 2
52 #define VOTEQUORUM_INFO_WAIT_FOR_ALL 4
53 #define VOTEQUORUM_INFO_LAST_MAN_STANDING 8
54 #define VOTEQUORUM_INFO_AUTO_TIE_BREAKER 16
55 #define VOTEQUORUM_INFO_ALLOW_DOWNSCALE 32
56 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64
57 #define VOTEQUORUM_INFO_QDEVICE_ALIVE 128
58 #define VOTEQUORUM_INFO_QDEVICE_CAST_VOTE 256
59 #define VOTEQUORUM_INFO_QDEVICE_MASTER_WINS 512
60 
61 #define VOTEQUORUM_QDEVICE_NODEID 0
62 #define VOTEQUORUM_QDEVICE_MAX_NAME_LEN 255
63 #define VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT 10000
64 #define VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT 30000
65 
66 #define VOTEQUORUM_NODESTATE_MEMBER 1
67 #define VOTEQUORUM_NODESTATE_DEAD 2
68 #define VOTEQUORUM_NODESTATE_LEAVING 3
69 
76  unsigned int node_id;
77  unsigned int node_state;
78  unsigned int node_votes;
79  unsigned int node_expected_votes;
80  unsigned int highest_expected;
81  unsigned int total_votes;
82  unsigned int quorum;
83  unsigned int flags;
84  unsigned int qdevice_votes;
86 };
87 
91 typedef struct {
92  uint32_t nodeid;
93  uint32_t state;
95 
99 typedef struct {
100  uint32_t nodeid;
101  uint64_t seq;
103 
108  votequorum_handle_t handle,
109  uint64_t context,
110  uint32_t quorate,
111  uint32_t node_list_entries,
112  votequorum_node_t node_list[]);
113 
115  votequorum_handle_t handle,
116  uint64_t context,
118  uint32_t node_list_entries,
119  uint32_t node_list[]);
120 
125  votequorum_handle_t handle,
126  uint64_t context,
127  uint32_t expected_votes);
128 
132 typedef struct {
137 
145  votequorum_handle_t *handle,
146  votequorum_callbacks_t *callbacks);
147 
154  votequorum_handle_t handle);
155 
163  votequorum_handle_t handle,
164  cs_dispatch_flags_t dispatch_types);
165 
176  votequorum_handle_t handle,
177  int *fd);
178 
187  votequorum_handle_t handle,
188  unsigned int nodeid,
189  struct votequorum_info *info);
190 
198  votequorum_handle_t handle,
199  unsigned int expected_votes);
200 
209  votequorum_handle_t handle,
210  unsigned int nodeid,
211  unsigned int votes);
212 
221  votequorum_handle_t handle,
222  uint64_t context,
223  unsigned int flags);
224 
231  votequorum_handle_t handle);
232 
240  votequorum_handle_t handle,
241  void **context);
242 
250  votequorum_handle_t handle,
251  void *context);
252 
263  votequorum_handle_t handle,
264  const char *name);
265 
273  votequorum_handle_t handle,
274  const char *name);
275 
284  votequorum_handle_t handle,
285  const char *oldname,
286  const char *newname);
287 
297  votequorum_handle_t handle,
298  const char *name,
299  unsigned int cast_vote,
300  votequorum_ring_id_t ring_id);
301 
310  votequorum_handle_t handle,
311  const char *name,
312  unsigned int allow);
313 
314 #ifdef __cplusplus
315 }
316 #endif
317 #endif /* COROSYNC_VOTEQUORUM_H_DEFINED */
uint32_t votes
The votequorum_callbacks_t struct.
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
votequorum_handle_t
void(* votequorum_quorum_notification_fn_t)(votequorum_handle_t handle, uint64_t context, uint32_t quorate, uint32_t node_list_entries, votequorum_node_t node_list[])
The votequorum_quorum_notification_fn_t callback.
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
The votequorum_node_t struct.
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.
uint32_t expected_votes
cs_error_t votequorum_trackstop(votequorum_handle_t handle)
votequorum_trackstop
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.
void(* votequorum_expectedvotes_notification_fn_t)(votequorum_handle_t handle, uint64_t context, uint32_t expected_votes)
The votequorum_expectedvotes_notification_fn_t callback.
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)
votequorum_context_set
votequorum_nodelist_notification_fn_t votequorum_nodelist_notify_fn
cs_error_t
The cs_error_t enum.
Definition: corotypes.h:94
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
Definition: corotypes.h:80
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
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]
The votequorum_info struct.
void(* votequorum_nodelist_notification_fn_t)(votequorum_handle_t handle, uint64_t context, votequorum_ring_id_t ring_id, uint32_t node_list_entries, uint32_t node_list[])
votequorum_quorum_notification_fn_t votequorum_quorum_notify_fn
The votequorum_ring_id_t struct.
unsigned int nodeid
Definition: coroapi.h:75
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.