]>
Commit | Line | Data |
---|---|---|
031c02f5 FDN |
1 | #include <config.h> |
2 | ||
5bb7ca5d CC |
3 | #include <sys/types.h> |
4 | #include <stdio.h> | |
5731af27 | 5 | #include <inttypes.h> |
5bb7ca5d CC |
6 | #include <stdint.h> |
7 | #include <stdlib.h> | |
8 | #include <unistd.h> | |
56eaee95 | 9 | #include <corosync/corotypes.h> |
301a730d | 10 | #include <corosync/quorum.h> |
5bb7ca5d | 11 | |
7d457e12 | 12 | static quorum_handle_t g_handle; |
5bb7ca5d CC |
13 | |
14 | static void quorum_notification_fn( | |
15 | quorum_handle_t handle, | |
16 | uint32_t quorate, | |
17 | uint64_t ring_id, | |
18 | uint32_t view_list_entries, | |
19 | uint32_t *view_list) | |
20 | { | |
21 | int i; | |
22 | ||
23 | printf("quorum notification called \n"); | |
06fbaac7 | 24 | printf(" quorate = %lu\n", (long unsigned int) quorate); |
5731af27 | 25 | printf(" ring id = " CS_PRI_RING_ID_SEQ "\n", ring_id); |
06fbaac7 | 26 | printf(" num nodes = %lu ", (long unsigned int) view_list_entries); |
5bb7ca5d CC |
27 | |
28 | for (i=0; i<view_list_entries; i++) { | |
5731af27 | 29 | printf(" " CS_PRI_NODE_ID, view_list[i]); |
5bb7ca5d CC |
30 | } |
31 | printf("\n"); | |
32 | } | |
33 | ||
34 | ||
35 | int main(int argc, char *argv[]) | |
36 | { | |
37 | int quorate; | |
38 | quorum_callbacks_t callbacks; | |
e34d509d | 39 | uint32_t quorum_type; |
5bb7ca5d CC |
40 | int err; |
41 | ||
42 | callbacks.quorum_notify_fn = quorum_notification_fn; | |
e34d509d | 43 | if ( (err=quorum_initialize(&g_handle, &callbacks, &quorum_type)) != CS_OK) |
5bb7ca5d CC |
44 | fprintf(stderr, "quorum_initialize FAILED: %d\n", err); |
45 | ||
7d457e12 | 46 | if ( (err=quorum_trackstart(g_handle, CS_TRACK_CHANGES)) != CS_OK) |
5bb7ca5d CC |
47 | fprintf(stderr, "quorum_trackstart FAILED: %d\n", err); |
48 | ||
7d457e12 | 49 | if ( (err=quorum_getquorate(g_handle, &quorate)) != CS_OK) |
5bb7ca5d CC |
50 | fprintf(stderr, "quorum_getquorate FAILED: %d\n", err); |
51 | else { | |
52 | printf("quorate %d\n", quorate); | |
53 | } | |
54 | ||
55 | printf("Waiting for quorum events, press ^C to finish\n"); | |
56 | printf("-------------------\n"); | |
57 | ||
58 | while (1) | |
dfb3cd69 FDN |
59 | if (quorum_dispatch(g_handle, CS_DISPATCH_ALL) != CS_OK) { |
60 | fprintf(stderr, "Error from quorum_dispatch\n"); | |
61 | return -1; | |
62 | } | |
5bb7ca5d CC |
63 | |
64 | return 0; | |
65 | } |