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 #define make_uint64(a,b) (((Uint64)(a)) + (((Uint64)(b)) << 32))
47 int main(
int argc,
char** argv)
61 printf(
"Arguments are <connect_string cluster> [<iterations>].\n");
64 const char *connectstring = argv[1];
67 iterations = atoi(argv[2]);
73 printf(
"Unable to create handle\n");
78 printf(
"Unable to set connectstring\n");
84 if ( le == 0 ) MGMERROR(h);
86 while (iterations-- != 0)
91 printf(
"No event within %d milliseconds\n", timeout);
98 printf(
"Node %d: BackupStarted\n",
event.source_nodeid);
99 printf(
" Starting node ID: %d\n",
event.BackupStarted.starting_node);
100 printf(
" Backup ID: %d\n",
event.BackupStarted.backup_id);
103 printf(
"Node %d: BackupStatus\n",
event.source_nodeid);
104 printf(
" Starting node ID: %d\n",
event.BackupStarted.starting_node);
105 printf(
" Backup ID: %d\n",
event.BackupStarted.backup_id);
106 printf(
" Data written: %llu bytes (%llu records)\n",
107 make_uint64(
event.BackupStatus.n_bytes_lo,
108 event.BackupStatus.n_bytes_hi),
109 make_uint64(
event.BackupStatus.n_records_lo,
110 event.BackupStatus.n_records_hi));
111 printf(
" Log written: %llu bytes (%llu records)\n",
112 make_uint64(
event.BackupStatus.n_log_bytes_lo,
113 event.BackupStatus.n_log_bytes_hi),
114 make_uint64(
event.BackupStatus.n_log_records_lo,
115 event.BackupStatus.n_log_records_hi));
118 printf(
"Node %d: BackupCompleted\n",
event.source_nodeid);
119 printf(
" Backup ID: %d\n",
event.BackupStarted.backup_id);
120 printf(
" Data written: %llu bytes (%llu records)\n",
121 make_uint64(
event.BackupCompleted.n_bytes,
122 event.BackupCompleted.n_bytes_hi),
123 make_uint64(
event.BackupCompleted.n_records,
124 event.BackupCompleted.n_records_hi));
125 printf(
" Log written: %llu bytes (%llu records)\n",
126 make_uint64(
event.BackupCompleted.n_log_bytes,
127 event.BackupCompleted.n_log_bytes_hi),
128 make_uint64(
event.BackupCompleted.n_log_records,
129 event.BackupCompleted.n_log_records_hi));
132 printf(
"Node %d: BackupAborted\n",
event.source_nodeid);
135 printf(
"Node %d: BackupFailedToStart\n",
event.source_nodeid);
139 printf(
"Node %d: NodeFailCompleted\n",
event.source_nodeid);
142 printf(
"Node %d: ArbitResult\n",
event.source_nodeid);
143 printf(
" code %d, arbit_node %d\n",
144 event.ArbitResult.code & 0xffff,
145 event.ArbitResult.arbit_node);
148 printf(
"Node %d: DeadDueToHeartbeat\n",
event.source_nodeid);
149 printf(
" node %d\n",
event.DeadDueToHeartbeat.node);
153 printf(
"Node %d: Connected\n",
event.source_nodeid);
154 printf(
" node %d\n",
event.Connected.node);
157 printf(
"Node %d: Disconnected\n",
event.source_nodeid);
158 printf(
" node %d\n",
event.Disconnected.node);
161 printf(
"Node %d: StartCompleted\n",
event.source_nodeid);
162 printf(
" version %d.%d.%d\n",
163 event.NDBStartCompleted.version >> 16 & 0xff,
164 event.NDBStartCompleted.version >> 8 & 0xff,
165 event.NDBStartCompleted.version >> 0 & 0xff);
168 printf(
"Node %d: ArbitState\n",
event.source_nodeid);
169 printf(
" code %d, arbit_node %d\n",
170 event.ArbitState.code & 0xffff,
171 event.ArbitResult.arbit_node);
180 ndb_mgm_destroy_logevent_handle(&le);