Abstract
This section describes the NdbEventOperation
class, which is used to monitor changes (events) in a database. It
provides the core functionality used to implement MySQL Cluster
Replication.
Parent class. None
Child classes. None
Description.
NdbEventOperation
represents a database event.
Creating an Instance of NdbEventOperation
.
This class has no public constructor or destructor. Instead,
instances of NdbEventOperation
are created as
the result of method calls on Ndb
and
NdbDictionary
objects:
There must exist an event which was created using
Dictionary::createEvent()
. This method
returns an instance of the
NdbDictionary::Event
class. See
Section 2.3.3.1.12, “Dictionary::createEvent()
”.
An NdbEventOperation
object is
instantiated using
Ndb::createEventOperation()
, which acts
on instance of NdbDictionary::Event
. See
Section 2.3.8.1.11, “Ndb::createEventOperation
”.
See also Section 2.3.4, “The Event
Class”.
An instance of this class is removed by invoking
Ndb::dropEventOperation
. See
Section 2.3.8.1.12, “Ndb::dropEventOperation()
”, for more information.
A detailed example demonstrating creation and removal of event operations is provided in Section 2.4.7, “NDB API Event Handling Example”.
Known Issues. The following issues may be encountered when working with event operations in the NDB API:
The maximum number of active
NdbEventOperation
objects is currently
fixed at compile time at 2 *
MaxNoOfTables
. This may become a separately
configurable parameter in a future release.
Currently, all INSERT
,
DELETE
, and UPDATE
events — as well as all attribute changes — are
sent to the API, even if only some attributes have been
specified. However, these are hidden from the user and only
relevant data is shown after calling
Ndb::nextEvent()
.
Note that false exits from
Ndb::pollEvents()
may occur, and thus the
following nextEvent()
call returns zero,
since there was no available data. In such cases, simply
call pollEvents()
again.
See Section 2.3.8.1.13, “Ndb::pollEvents()
”, and
Section 2.3.8.1.14, “Ndb::nextEvent()
”.
Event code does not check the table schema version. When a table is dropped, make sure that you drop any associated events.
We intend to remedy this issue in a future release of MySQL Cluster and the NDB API.
If you have received a complete epoch, events from this epoch are not re-sent, even in the event of a node failure. However, if a node failure has occurred, subsequent epochs may contain duplicate events, which can be identified by duplicated primary keys.
In the MySQL Cluster replication code, duplicate primary
keys on INSERT
operations are normally
handled by treating such inserts as
REPLACE
operations.
To view the contents of the system table containing created events, you can use the ndb_select_all utility as shown here:
ndb_select_all -d sys 'NDB$EVENTS_0'
Methods. The following table lists the public methods of this class and the purpose or use of each method:
Method | Purpose / Use |
---|---|
getState() |
Gets the current state of the event operation |
getEventType() |
Gets the event type |
getValue() |
Retrieves an attribute value |
getPreValue() |
Retrieves an attribute's previous value |
getBlobHandle() |
Gets a handle for reading blob attributes |
getPreBlobHandle() |
Gets a handle for reading the previous blob attribute |
getGCI() |
Retrieves the GCI of the most recently retrieved event |
getLatestGCI() |
Retrieves the most recent GCI (whether or not the corresponding event has been retrieved) |
getNdbError() |
Gets the most recent error |
isConsistent() |
Detects event loss caused by node failure |
tableNameChanged() |
Checks to see whether the name of a table has changed |
tableFrmChanged() |
Checks to see whether a table .FRM file has changed |
tableFragmentationChanged() |
Checks to see whether the fragmentation for a table has changed |
tableRangeListChanged() |
Checks to see whether a table range partition list name has changed |
mergeEvents() |
Allows for events to be merged |
execute() |
Activates the NdbEventOperation
|
For detailed descriptions, signatures, and examples of use for each
of these methods, see
Section 2.3.11.2, “NdbEventOperation
Methods”.
Types.
NdbEventOperation
defines one enumerated type.
See Section 2.3.11.1, “The NdbEventOperation::State
Type”, for details.
Class diagram.
This diagram shows all the available methods and enumerated types
of the NdbEventOperation
class: