The following steps are involved:
Create an NdbLogEventHandle using
ndb_mgm_create_logevent_handle().
Wait for and store log events using
ndb_logevent_get_next().
The log event data is available in the structure
ndb_logevent. The data which is specific
to a particular event is stored in a union between
structures; use ndb_logevent::type to
decide which structure is valid.
The following sample code demonstrates listening to events related to backups:
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
NdbLogEventHandle le_handle= ndb_mgm_create_logevent_handle(handle, filter);
struct ndb_logevent le;
int r= ndb_logevent_get_next(le_handle, &le, 0);
if(r < 0)
/* error */
else if(r == 0)
/* no event */
switch(le.type)
{
case NDB_LE_BackupStarted:
... le.BackupStarted.starting_node;
... le.BackupStarted.backup_id;
break;
case NDB_LE_BackupFailedToStart:
... le.BackupFailedToStart.error;
break;
case NDB_LE_BackupCompleted:
... le.BackupCompleted.stop_gci;
break;
case NDB_LE_BackupAborted:
... le.BackupStarted.backup_id;
break;
default:
break;
}
For more information, see Section 3.2.1, “Log Event Functions”.
Available log event types are listed in
Section 3.3.4, “The Ndb_logevent_type Type”, as well as in the
file
/storage/ndb/include/mgmapi/ndb_logevent.h
in the MySQL 5.1 sources.
