MCPcopy Create free account
hub / github.com/corosync/corosync / main

Function main

test/testvotequorum1.c:121–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119
120
121int main(int argc, char *argv[])
122{
123 struct votequorum_info info;
124 votequorum_callbacks_t callbacks;
125 int err;
126
127 if (argc > 1 && strcmp(argv[1], "-h")==0) {
128 fprintf(stderr, "usage: %s [new-expected] [new-votes]\n", argv[0]);
129 return 0;
130 }
131
132 callbacks.votequorum_quorum_notify_fn = votequorum_quorum_notification_fn;
133 callbacks.votequorum_nodelist_notify_fn = votequorum_nodelist_notification_fn;
134 callbacks.votequorum_expectedvotes_notify_fn = votequorum_expectedvotes_notification_fn;
135
136 if ( (err=votequorum_initialize(&g_handle, &callbacks)) != CS_OK)
137 fprintf(stderr, "votequorum_initialize FAILED: %d\n", err);
138
139 if ( (err = votequorum_trackstart(g_handle, g_handle, CS_TRACK_CHANGES)) != CS_OK)
140 fprintf(stderr, "votequorum_trackstart FAILED: %d\n", err);
141
142 if ( (err=votequorum_getinfo(g_handle, 0, &info)) != CS_OK)
143 fprintf(stderr, "votequorum_getinfo FAILED: %d\n", err);
144 else {
145 printf("node votes %d\n", info.node_votes);
146 printf("expected votes %d\n", info.node_expected_votes);
147 printf("highest expected %d\n", info.highest_expected);
148 printf("total votes %d\n", info.total_votes);
149 printf("quorum %d\n", info.quorum);
150 printf("flags ");
151 if (info.flags & VOTEQUORUM_INFO_TWONODE) printf("2Node ");
152 if (info.flags & VOTEQUORUM_INFO_QUORATE) printf("Quorate ");
153 if (info.flags & VOTEQUORUM_INFO_WAIT_FOR_ALL) printf("WaitForAll ");
154 if (info.flags & VOTEQUORUM_INFO_LAST_MAN_STANDING) printf("LastManStanding ");
155 if (info.flags & VOTEQUORUM_INFO_AUTO_TIE_BREAKER) printf("AutoTieBreaker ");
156 if (info.flags & VOTEQUORUM_INFO_ALLOW_DOWNSCALE) printf("AllowDownscale ");
157
158 printf("\n");
159 }
160
161 if (argc >= 2 && atoi(argv[1])) {
162 if ( (err=votequorum_setexpected(g_handle, atoi(argv[1]))) != CS_OK)
163 fprintf(stderr, "set expected votes FAILED: %d\n", err);
164 }
165 if (argc >= 3 && atoi(argv[2])) {
166 if ( (err=votequorum_setvotes(g_handle, 0, atoi(argv[2]))) != CS_OK)
167 fprintf(stderr, "set votes FAILED: %d\n", err);
168 }
169
170 if (argc >= 2) {
171 if ( (err=votequorum_getinfo(g_handle, 0, &info)) != CS_OK)
172 fprintf(stderr, "votequorum_getinfo2 FAILED: %d\n", err);
173 else {
174 printf("-------------------\n");
175 printf("node votes %d\n", info.node_votes);
176 printf("expected votes %d\n", info.node_expected_votes);
177 printf("highest expected %d\n", info.highest_expected);
178 printf("total votes %d\n", info.total_votes);

Callers

nothing calls this directly

Calls 6

votequorum_initializeFunction · 0.85
votequorum_trackstartFunction · 0.85
votequorum_getinfoFunction · 0.85
votequorum_setexpectedFunction · 0.85
votequorum_setvotesFunction · 0.85
votequorum_dispatchFunction · 0.85

Tested by

no test coverage detected