------------------------------------------------------------
revno: 125
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Mon 2007-06-25 09:54:09 -0700
message:
Added preliminary underlying support for NdbEventOperation.
added:
swig/NdbEventOperation.i ndbeventoperation.i-20070625162920-mfe5hei0d2x85mrk-1
modified:
java/ndbapi.i ndbapi.i-20070130002924-gcvhapmvh0lu1pkd-3
ruby/test.rb test.rb-20070228212451-7arjxk90dkwcn5xr-4
swig/NdbDictionary.i ndbdictionary.i-20070323110251-l7mg72hiddtuzeh0-1
swig/ndbglobals.i globals.i-20070228021421-qkr4cbpxymyqdrf3-7
=== added file 'swig/NdbEventOperation.i'
--- a/swig/NdbEventOperation.i 1970-01-01 00:00:00 +0000
+++ b/swig/NdbEventOperation.i 2007-06-25 16:54:09 +0000
@@ -0,0 +1,121 @@
+// -*- mode: c++ -*-
+/* Copyright (C) 2003 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+class NdbEventOperation {
+public:
+ /**
+ * State of the NdbEventOperation object
+ */
+ enum State {
+ EO_CREATED, ///< Created but execute() not called
+ EO_EXECUTING, ///< execute() called
+ EO_DROPPED, ///< Waiting to be deleted, Object unusable.
+ EO_ERROR ///< An error has occurred. Object unusable.
+ };
+ /**
+ * Retrieve current state of the NdbEventOperation object
+ */
+ State getState();
+ /**
+ * See NdbDictionary::Event. Default is false.
+ */
+ void mergeEvents(bool flag);
+
+ /**
+ * Activates the NdbEventOperation to start receiving events. The
+ * changed attribute values may be retrieved after Ndb::nextEvent()
+ * has returned not NULL. The getValue() methods must be called
+ * prior to execute().
+ *
+ * @return 0 if successful otherwise -1.
+ */
+ int execute();
+
+
+ NdbRecAttr *getValue(const char *anAttrName, char *aValue = 0);
+ /**
+ * See getValue().
+ */
+ NdbRecAttr *getPreValue(const char *anAttrName, char *aValue = 0);
+ NdbBlob* getBlobHandle(const char *anAttrName);
+ NdbBlob* getPreBlobHandle(const char *anAttrName);
+
+ int isOverrun() const;
+ bool isConsistent() const;
+
+ /**
+ * Query for occured event type.
+ *
+ * @note Only valid after Ndb::nextEvent() has been called and
+ * returned a not NULL value
+ *
+ * @return type of event
+ */
+ NdbDictEvent::TableEvent getEventType() const;
+ /**
+ * Check if table name has changed, for event TE_ALTER
+ */
+ const bool tableNameChanged() const;
+
+ /**
+ * Check if table frm has changed, for event TE_ALTER
+ */
+ const bool tableFrmChanged() const;
+
+ /**
+ * Check if table fragmentation has changed, for event TE_ALTER
+ */
+ const bool tableFragmentationChanged() const;
+
+ /**
+ * Check if table range partition list name has changed, for event TE_ALTER
+ */
+ const bool tableRangeListChanged() const;
+ /**
+ * Retrieve the GCI of the latest retrieved event
+ *
+ * @return GCI number
+ */
+ Uint64 getGCI() const;
+
+ /**
+ * Retrieve the AnyValue of the latest retrieved event
+ *
+ * @return AnyValue
+ */
+ Uint32 getAnyValue() const;
+ /**
+ * Retrieve the complete GCI in the cluster (not necessarily
+ * associated with an event)
+ *
+ * @return GCI number
+ */
+ Uint64 getLatestGCI() const;
+
+ /**
+ * Get the latest error
+ *
+ * @return Error object.
+ */
+ const struct NdbError & getNdbError() const;
+
+private:
+ NdbEventOperation(Ndb *theNdb, const char* eventName);
+ ~NdbEventOperation();
+};
+
+typedef void (* NdbEventCallback)(NdbEventOperation*, Ndb*, void*);
+
=== modified file 'java/ndbapi.i'
--- a/java/ndbapi.i 2007-05-29 15:45:11 +0000
+++ b/java/ndbapi.i 2007-06-25 16:54:09 +0000
@@ -86,7 +86,7 @@
%typemap(jstype) asynch_callback_t * "INdbCallable"
%typemap(javain) asynch_callback_t * "(Object)$javainput"
-%typemap(javaimports) NdbFactory, Ndb, Ndb_cluster_connection, NdbTransaction,
NdbOperation, NdbIndexOperation, NdbScanOperation, NdbIndexScanOperation, NdbBlob,
NdbDictDictionary, NdbDictColumn, NdbDictIndex, NdbDictTable, NdbDictObject,
NdbScanFilter "import com.mysql.cluster.errors.*;"
+%typemap(javaimports) NdbFactory, Ndb, Ndb_cluster_connection, NdbTransaction,
NdbOperation, NdbIndexOperation, NdbScanOperation, NdbIndexScanOperation, NdbBlob,
NdbDictDictionary, NdbDictColumn, NdbDictIndex, NdbDictTable, NdbDictObject,
NdbScanFilter, NdbEvent, NdbEventOperation "import com.mysql.cluster.errors.*;"
%pragma(java) moduleimports="import com.mysql.cluster.errors.*;"
%pragma(java) jniclassimports="import com.mysql.cluster.errors.*;"
@@ -270,6 +270,7 @@
%include "NdbScanOperation.i"
%include "NdbIndexOperation.i"
%include "NdbIndexScanOperation.i"
+%include "NdbEventOperation.i"
%include "NdbRecAttr.i"
%include "NdbBlob.i"
%include "NdbError.i"
=== modified file 'ruby/test.rb'
--- a/ruby/test.rb 2007-05-29 15:45:11 +0000
+++ b/ruby/test.rb 2007-06-25 16:54:09 +0000
@@ -14,7 +14,7 @@
begin
connection.connect(1,1,1)
connection.wait_until_ready(30, 30)
-
+
rescue Ndbapi::NdbApiException => e
puts "ERROR:" + e
exit
=== modified file 'swig/NdbDictionary.i'
--- a/swig/NdbDictionary.i 2007-05-29 15:45:11 +0000
+++ b/swig/NdbDictionary.i 2007-06-25 16:54:09 +0000
@@ -128,7 +128,7 @@
bool getNullable() const;
bool getPrimaryKey() const;
int getColumnNo() const;
- bool equal(const NdbDictionary::Column& column) const;
+ bool equal(const NdbDictColumn& column) const;
Type getType() const;
int getPrecision() const;
int getScale() const;
@@ -392,3 +392,185 @@
~NdbDictDictionary();
};
+
+class NdbDictEvent : public NdbDictObject {
+
+public:
+ enum TableEvent {
+ TE_INSERT =1<<0, ///< Insert event on table
+ TE_DELETE =1<<1, ///< Delete event on table
+ TE_UPDATE =1<<2, ///< Update event on table
+ TE_DROP =1<<4, ///< Drop of table
+ TE_ALTER =1<<5, ///< Alter of table
+ TE_CREATE =1<<6, ///< Create of table
+ TE_GCP_COMPLETE=1<<7, ///< GCP is complete
+ TE_CLUSTER_FAILURE=1<<8, ///< Cluster is unavailable
+ TE_STOP =1<<9, ///< Stop of event operation
+ TE_NODE_FAILURE=1<<10, ///< Node failed
+ TE_SUBSCRIBE =1<<11, ///< Node subscribes
+ TE_UNSUBSCRIBE =1<<12, ///< Node unsubscribes
+ TE_ALL=0xFFFF ///< Any/all event on table (not relevant when
+ ///< events are received)
+ };
+
+ enum EventDurability {
+ ED_UNDEFINED = 0,
+ ED_PERMANENT = 3,
+ };
+
+ /**
+ * Specifies reporting options for table events
+ */
+ enum EventReport {
+ ER_UPDATED = 0,
+ ER_ALL = 1, // except not-updated blob inlines
+ ER_SUBSCRIBE = 2
+ };
+
+ /**
+ * Constructor
+ * @param name Name of event
+ */
+ NdbDictEvent(const char *name);
+ /**
+ * Constructor
+ * @param name Name of event
+ * @param table Reference retrieved from NdbDictionary
+ */
+ NdbDictEvent(const char *name, const NdbDictTable& table);
+ virtual ~Event();
+ /**
+ * Set unique identifier for the event
+ */
+ int setName(const char *name);
+ /**
+ * Get unique identifier for the event
+ */
+ const char *getName() const;
+ /**
+ * Get table that the event is defined on
+ *
+ * @return pointer to table or NULL if no table has been defined
+ */
+ const NdbDictTable * getTable() const;
+ /**
+ * Define table on which events should be detected
+ *
+ * @note calling this method will default to detection
+ * of events on all columns. Calling subsequent
+ * addEventColumn calls will override this.
+ *
+ * @param table reference retrieved from NdbDictionary
+ */
+ void setTable(const NdbDictTable& table);
+ /**
+ * Set table for which events should be detected
+ *
+ * @note preferred way is using setTable(const NdbDictionary::Table&)
+ * or constructor with table object parameter
+ */
+ int setTable(const char *tableName);
+ /**
+ * Get table name for events
+ *
+ * @return table name
+ */
+ const char* getTableName() const;
+ /**
+ * Add type of event that should be detected
+ */
+ void addTableEvent(const TableEvent te);
+ /**
+ * Check if a specific table event will be detected
+ */
+ bool getTableEvent(const TableEvent te) const;
+ /**
+ * Set durability of the event
+ */
+ void setDurability(EventDurability);
+ /**
+ * Get durability of the event
+ */
+ EventDurability getDurability() const;
+ /**
+ * Set report option of the event
+ */
+ void setReport(EventReport);
+ /**
+ * Get report option of the event
+ */
+ EventReport getReport() const;
+
+ /**
+ * Add a column on which events should be detected
+ *
+ * @param attrId Column id
+ *
+ * @note errors will mot be detected until createEvent() is called
+ */
+ void addEventColumn(unsigned attrId);
+ /**
+ * Add a column on which events should be detected
+ *
+ * @param columnName Column name
+ *
+ * @note errors will not be detected until createEvent() is called
+ */
+ void addEventColumn(const char * columnName);
+ /**
+ * Add several columns on which events should be detected
+ *
+ * @param n Number of columns
+ * @param columnNames Column names
+ *
+ * @note errors will mot be detected until
+ * NdbDictionary::Dictionary::createEvent() is called
+ */
+ void addEventColumns(int n, const char ** columnNames);
+ /**
+ * Get no of columns defined in an Event
+ *
+ * @return Number of columns, -1 on error
+ */
+ int getNoOfEventColumns() const;
+
+ /**
+ * Get a specific column in the event
+ */
+ const NdbDictColumn * getEventColumn(unsigned no) const;
+
+ /**
+ * The merge events flag is false by default. Setting it true
+ * implies that events are merged in following ways:
+ *
+ * - for given NdbEventOperation associated with this event,
+ * events on same PK within same GCI are merged into single event
+ *
+ * - a blob table event is created for each blob attribute
+ * and blob events are handled as part of main table events
+ *
+ * - blob post/pre data from the blob part events can be read
+ * via NdbBlob methods as a single value
+ *
+ * NOTE: Currently this flag is not inherited by NdbEventOperation
+ * and must be set on NdbEventOperation explicitly.
+ */
+ void mergeEvents(bool flag);
+
+ /**
+ * Get object status
+ */
+ virtual NdbDictObject::Status getObjectStatus() const;
+
+ /**
+ * Get object version
+ */
+ virtual int getObjectVersion() const;
+
+ /**
+ * Get object id
+ */
+ virtual int getObjectId() const;
+ private:
+ Event(NdbEventImpl&);
+};
=== modified file 'swig/ndbglobals.i'
--- a/swig/ndbglobals.i 2007-05-29 15:45:11 +0000
+++ b/swig/ndbglobals.i 2007-06-25 16:54:09 +0000
@@ -50,17 +50,19 @@
typedef NdbDictionary::Column NdbDictColumn;
typedef NdbDictionary::Index NdbDictIndex;
typedef NdbDictionary::Dictionary NdbDictDictionary;
-
+typedef NdbDictionary::Event NdbDictEvent;
%}
-
+// TODO: This is a little stupid.
+// Why don't we just typedef these right in the first place
%rename(NdbObject) NdbDictObject;
%rename(NdbTable) NdbDictTable;
%rename(NdbColumn) NdbDictColumn;
%rename(NdbIndex) NdbDictIndex;
%rename(NdbDictionary) NdbDictDictionary;
+%rename(NdbEvent) NdbDictEvent;
enum AbortOption {
| Thread |
|---|
| • Rev 125: Added preliminary underlying support for NdbEventOperation. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge | Monty Taylor | 25 Jun |