corosync  2.3.2
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 
60 #define VOTEQUORUM_NODESTATE_MEMBER 1
61 #define VOTEQUORUM_NODESTATE_DEAD 2
62 #define VOTEQUORUM_NODESTATE_LEAVING 3
63 
67  unsigned int node_id;
68  unsigned int node_state;
69  unsigned int node_votes;
70  unsigned int node_expected_votes;
71  unsigned int highest_expected;
72  unsigned int total_votes;
73  unsigned int quorum;
74  unsigned int flags;
75  unsigned int qdevice_votes;
77 };
78 
79 typedef struct {
80  uint32_t nodeid;
81  uint32_t state;
83 
85  votequorum_handle_t handle,
86  uint64_t context,
87  uint32_t quorate,
88  uint32_t node_list_entries,
89  votequorum_node_t node_list[]);
90 
92  votequorum_handle_t handle,
93  uint64_t context,
94  uint32_t expected_votes);
95 
96 typedef struct {
100 
101 
106  votequorum_handle_t *handle,
107  votequorum_callbacks_t *callbacks);
108 
113  votequorum_handle_t handle);
114 
115 
120  votequorum_handle_t handle,
121  cs_dispatch_flags_t dispatch_types);
122 
130  votequorum_handle_t handle,
131  int *fd);
132 
137  votequorum_handle_t handle,
138  unsigned int nodeid,
139  struct votequorum_info *info);
140 
145  votequorum_handle_t handle,
146  unsigned int expected_votes);
147 
152  votequorum_handle_t handle,
153  unsigned int nodeid,
154  unsigned int votes);
155 
160  votequorum_handle_t handle,
161  uint64_t context,
162  unsigned int flags );
163 
165  votequorum_handle_t handle);
166 
171  votequorum_handle_t handle,
172  void **context);
173 
175  votequorum_handle_t handle,
176  void *context);
177 
184  votequorum_handle_t handle,
185  const char *name);
186 
191  votequorum_handle_t handle,
192  const char *name);
193 
198  votequorum_handle_t handle,
199  const char *oldname,
200  const char *newname);
201 
206  votequorum_handle_t handle,
207  const char *name,
208  unsigned int cast_vote);
209 
214  votequorum_handle_t handle,
215  const char *name,
216  unsigned int allow);
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 #endif /* COROSYNC_VOTEQUORUM_H_DEFINED */
cs_error_t votequorum_trackstart(votequorum_handle_t handle, uint64_t context, unsigned int flags)
Track node and quorum changes.
uint32_t votes
char oldname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
cs_error_t votequorum_setvotes(votequorum_handle_t handle, unsigned int nodeid, unsigned int votes)
set votes for a node
cs_error_t votequorum_initialize(votequorum_handle_t *handle, votequorum_callbacks_t *callbacks)
Create a new quorum connection.
cs_error_t votequorum_context_set(votequorum_handle_t handle, void *context)
#define VOTEQUORUM_QDEVICE_MAX_NAME_LEN
uint64_t votequorum_handle_t
void(* votequorum_notification_fn_t)(votequorum_handle_t handle, uint64_t context, uint32_t quorate, uint32_t node_list_entries, votequorum_node_t node_list[])
cs_error_t votequorum_dispatch(votequorum_handle_t handle, cs_dispatch_flags_t dispatch_types)
Dispatch messages and configuration changes.
cs_error_t votequorum_qdevice_poll(votequorum_handle_t handle, const char *name, unsigned int cast_vote)
Poll a quorum device.
cs_error_t votequorum_qdevice_update(votequorum_handle_t handle, const char *oldname, const char *newname)
Update registered name of a quorum device.
cs_error_t votequorum_finalize(votequorum_handle_t handle)
Close the quorum handle.
uint32_t expected_votes
cs_error_t votequorum_setexpected(votequorum_handle_t handle, unsigned int expected_votes)
set expected_votes
cs_error_t votequorum_fd_get(votequorum_handle_t handle, int *fd)
Get a file descriptor on which to poll.
void(* votequorum_expectedvotes_notification_fn_t)(votequorum_handle_t handle, uint64_t context, uint32_t expected_votes)
uint32_t flags
cs_error_t votequorum_qdevice_register(votequorum_handle_t handle, const char *name)
Register a quorum device.
cs_error_t
Definition: corotypes.h:78
cs_error_t votequorum_context_get(votequorum_handle_t handle, void **context)
Save and retrieve private data/context.
cs_dispatch_flags_t
Definition: corotypes.h:67
votequorum_expectedvotes_notification_fn_t votequorum_expectedvotes_notify_fn
uint32_t quorate
Definition: sam.c:133
votequorum_notification_fn_t votequorum_notify_fn
char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
char newname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
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.
cs_error_t votequorum_trackstop(votequorum_handle_t handle)
cs_error_t votequorum_qdevice_unregister(votequorum_handle_t handle, const char *name)
Unregister a quorum device.
unsigned int nodeid
Definition: coroapi.h:65
cs_error_t votequorum_getinfo(votequorum_handle_t handle, unsigned int nodeid, struct votequorum_info *info)
Get quorum information.