20 #include <ndbapi/NdbApi.hpp>
31 fprintf(stderr, "code: %d msg: %s\n", \
32 ndb_mgm_get_latest_error(h), \
33 ndb_mgm_get_latest_error_msg(h)); \
37 #define LOGEVENTERROR(h) \
39 fprintf(stderr, "code: %d msg: %s\n", \
40 ndb_logevent_get_latest_error(h), \
41 ndb_logevent_get_latest_error_msg(h)); \
45 int main(
int argc,
char** argv)
59 printf(
"Arguments are <connect_string cluster 1> <connect_string cluster 2> [<iterations>].\n");
62 const char *connectstring1 = argv[1];
63 const char *connectstring2 = argv[2];
66 iterations = atoi(argv[3]);
71 if ( h1 == 0 || h2 == 0 )
73 printf(
"Unable to create handle\n");
79 printf(
"Unable to set connectstring\n");
88 while (iterations-- != 0)
93 printf(
"No event within %d milliseconds\n", timeout);
98 switch (event1.type) {
100 printf(
"Node %d: BackupStarted\n", event1.source_nodeid);
101 printf(
" Starting node ID: %d\n", event1.BackupStarted.starting_node);
102 printf(
" Backup ID: %d\n", event1.BackupStarted.backup_id);
105 printf(
"Node %d: BackupCompleted\n", event1.source_nodeid);
106 printf(
" Backup ID: %d\n", event1.BackupStarted.backup_id);
109 printf(
"Node %d: BackupAborted\n", event1.source_nodeid);
112 printf(
"Node %d: BackupFailedToStart\n", event1.source_nodeid);
116 printf(
"Node %d: NodeFailCompleted\n", event1.source_nodeid);
119 printf(
"Node %d: ArbitResult\n", event1.source_nodeid);
120 printf(
" code %d, arbit_node %d\n",
121 event1.ArbitResult.code & 0xffff,
122 event1.ArbitResult.arbit_node);
125 printf(
"Node %d: DeadDueToHeartbeat\n", event1.source_nodeid);
126 printf(
" node %d\n", event1.DeadDueToHeartbeat.node);
130 printf(
"Node %d: Connected\n", event1.source_nodeid);
131 printf(
" node %d\n", event1.Connected.node);
134 printf(
"Node %d: Disconnected\n", event1.source_nodeid);
135 printf(
" node %d\n", event1.Disconnected.node);
138 printf(
"Node %d: StartCompleted\n", event1.source_nodeid);
139 printf(
" version %d.%d.%d\n",
140 event1.NDBStartCompleted.version >> 16 & 0xff,
141 event1.NDBStartCompleted.version >> 8 & 0xff,
142 event1.NDBStartCompleted.version >> 0 & 0xff);
145 printf(
"Node %d: ArbitState\n", event1.source_nodeid);
146 printf(
" code %d, arbit_node %d\n",
147 event1.ArbitState.code & 0xffff,
148 event1.ArbitResult.arbit_node);
158 printf(
"No event within %d milliseconds\n", timeout);
163 switch (event2.type) {
165 printf(
"Node %d: BackupStarted\n", event2.source_nodeid);
166 printf(
" Starting node ID: %d\n", event2.BackupStarted.starting_node);
167 printf(
" Backup ID: %d\n", event2.BackupStarted.backup_id);
170 printf(
"Node %d: BackupCompleted\n", event2.source_nodeid);
171 printf(
" Backup ID: %d\n", event2.BackupStarted.backup_id);
174 printf(
"Node %d: BackupAborted\n", event2.source_nodeid);
177 printf(
"Node %d: BackupFailedToStart\n", event2.source_nodeid);
181 printf(
"Node %d: NodeFailCompleted\n", event2.source_nodeid);
184 printf(
"Node %d: ArbitResult\n", event2.source_nodeid);
185 printf(
" code %d, arbit_node %d\n",
186 event2.ArbitResult.code & 0xffff,
187 event2.ArbitResult.arbit_node);
190 printf(
"Node %d: DeadDueToHeartbeat\n", event2.source_nodeid);
191 printf(
" node %d\n", event2.DeadDueToHeartbeat.node);
195 printf(
"Node %d: Connected\n", event2.source_nodeid);
196 printf(
" node %d\n", event2.Connected.node);
199 printf(
"Node %d: Disconnected\n", event2.source_nodeid);
200 printf(
" node %d\n", event2.Disconnected.node);
203 printf(
"Node %d: StartCompleted\n", event2.source_nodeid);
204 printf(
" version %d.%d.%d\n",
205 event2.NDBStartCompleted.version >> 16 & 0xff,
206 event2.NDBStartCompleted.version >> 8 & 0xff,
207 event2.NDBStartCompleted.version >> 0 & 0xff);
210 printf(
"Node %d: ArbitState\n", event2.source_nodeid);
211 printf(
" code %d, arbit_node %d\n",
212 event2.ArbitState.code & 0xffff,
213 event2.ArbitResult.arbit_node);
222 ndb_mgm_destroy_logevent_handle(&le1);
223 ndb_mgm_destroy_logevent_handle(&le2);