corosync
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
42extern "C" {
43#endif
44
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#define VOTEQUORUM_INFO_QDEVICE_HAS_EXTRA_INFO 1024
61
62#define VOTEQUORUM_QDEVICE_NODEID 0
63#define VOTEQUORUM_QDEVICE_MAX_NAME_LEN 255
64#define VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT 10000
65#define VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT 30000
66
67#define VOTEQUORUM_NODESTATE_MEMBER 1
68#define VOTEQUORUM_NODESTATE_DEAD 2
69#define VOTEQUORUM_NODESTATE_LEAVING 3
70
71#define VOTEQUORUM_QDEVICE_EXTRA_NODEINFO_MAXSIZE 4096
72
79 unsigned int node_id;
80 unsigned int node_state;
81 unsigned int node_votes;
82 unsigned int node_expected_votes;
83 unsigned int highest_expected;
84 unsigned int total_votes;
85 unsigned int quorum;
86 unsigned int flags;
87 unsigned int qdevice_votes;
89};
90
98
106
111 votequorum_handle_t handle,
112 uint64_t context,
116
118 votequorum_handle_t handle,
119 uint64_t context,
123
128 votequorum_handle_t handle,
129 uint64_t context,
131
140 votequorum_handle_t handle,
141 uint64_t context,
144 void *extra_info);
145
154
158
166
174 votequorum_handle_t *handle,
175 const votequorum_model_v1_data_t *model);
176
184 votequorum_handle_t *handle,
185 votequorum_callbacks_t *callbacks);
186
193 votequorum_handle_t handle);
194
202 votequorum_handle_t handle,
204
215 votequorum_handle_t handle,
216 int *fd);
217
226 votequorum_handle_t handle,
227 unsigned int nodeid,
228 struct votequorum_info *info);
229
237 votequorum_handle_t handle,
238 unsigned int expected_votes);
239
248 votequorum_handle_t handle,
249 unsigned int nodeid,
250 unsigned int votes);
251
260 votequorum_handle_t handle,
261 uint64_t context,
262 unsigned int flags);
263
270 votequorum_handle_t handle);
271
279 votequorum_handle_t handle,
280 void **context);
281
289 votequorum_handle_t handle,
290 void *context);
291
302 votequorum_handle_t handle,
303 const char *name);
304
312 votequorum_handle_t handle,
313 const char *name);
314
323 votequorum_handle_t handle,
324 const char *oldname,
325 const char *newname);
326
336 votequorum_handle_t handle,
337 const char *name,
338 unsigned int cast_vote,
340
349 votequorum_handle_t handle,
350 const char *name,
351 unsigned int allow);
352
361 votequorum_handle_t handle,
362 unsigned int nodeid,
364 void *extra_info);
365
373 votequorum_handle_t handle,
375 const void *extra_info);
376
377#ifdef __cplusplus
378}
379#endif
380#endif /* COROSYNC_VOTEQUORUM_H_DEFINED */
unsigned int nodeid
the ID of the node whose info needs updating
Definition coroapi.h:0
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
Definition corotypes.h:84
cs_error_t
The cs_error_t enum.
Definition corotypes.h:98
char oldname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
uint32_t flags
char extra_info[]
char newname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
uint32_t votes
uint32_t expected_votes
uint32_t ei_size
length of the extra info
cs_error_t votequorum_qdevice_register(votequorum_handle_t handle, const char *name)
Register a quorum device.
cs_error_t votequorum_setvotes(votequorum_handle_t handle, unsigned int nodeid, unsigned int votes)
set votes for a node
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[])
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.
uint64_t votequorum_handle_t
votequorum_handle_t
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.
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_context_get(votequorum_handle_t handle, void **context)
Save and retrieve private data/context.
cs_error_t votequorum_set_qdevice_extra_info(votequorum_handle_t handle, uint32_t ei_size, const void *extra_info)
set the current extra_info for this node, should only be used by the qdevice
cs_error_t votequorum_finalize(votequorum_handle_t handle)
Close the quorum handle.
cs_error_t votequorum_trackstop(votequorum_handle_t handle)
votequorum_trackstop
cs_error_t votequorum_qdevice_unregister(votequorum_handle_t handle, const char *name)
Unregister a quorum device.
cs_error_t votequorum_fd_get(votequorum_handle_t handle, int *fd)
Get a file descriptor on which to poll.
cs_error_t votequorum_model_initialize(votequorum_handle_t *handle, const votequorum_model_v1_data_t *model)
Create a new quorum connection.
cs_error_t votequorum_get_qdevice_extra_info(votequorum_handle_t handle, unsigned int nodeid, uint32_t *ei_size, void *extra_info)
request the current extra_info for a node
cs_error_t votequorum_context_set(votequorum_handle_t handle, void *context)
votequorum_context_set
#define VOTEQUORUM_QDEVICE_MAX_NAME_LEN
cs_error_t votequorum_trackstart(votequorum_handle_t handle, uint64_t context, unsigned int flags)
Track node and quorum changes.
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_dispatch(votequorum_handle_t handle, cs_dispatch_flags_t dispatch_types)
Dispatch messages and configuration changes.
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_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
void(* votequorum_qdevice_extra_info_fn_t)(votequorum_handle_t handle, uint64_t context, uint32_t nodeid, uint32_t ei_size, void *extra_info)
Callback to be notified of changes to a node's extra info.
cs_error_t votequorum_initialize(votequorum_handle_t *handle, votequorum_callbacks_t *callbacks)
Create a new quorum connection.
uint32_t quorate
Definition sam.c:134
The votequorum_callbacks_t struct.
votequorum_nodelist_notification_fn_t votequorum_nodelist_notify_fn
votequorum_expectedvotes_notification_fn_t votequorum_expectedvotes_notify_fn
votequorum_quorum_notification_fn_t votequorum_quorum_notify_fn
The votequorum_info struct.
char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]
votequorum_nodelist_notification_fn_t votequorum_nodelist_notify_fn
votequorum_qdevice_extra_info_fn_t votequorum_qdevice_extra_info_fn
votequorum_expectedvotes_notification_fn_t votequorum_expectedvotes_notify_fn
votequorum_quorum_notification_fn_t votequorum_quorum_notify_fn
The votequorum_node_t struct.
The votequorum_ring_id_t struct.
struct memb_ring_id ring_id
Definition totemsrp.c:4