At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
------------------------------------------------------------
revno: 266
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Mon 2007-11-19 17:08:15 -0800
message:
Added python support for MGM API.
Fixed MGM API memory leak.
Added test program in Python for MGM API
added:
python/testmgm.py testmgm.py-20071120010244-xrr0eny7i350ornu-1
modified:
interface/mgmapi/NdbLogEventManager.i
ndbmgmlogeventhandle-20070906065939-pj4qrhof8kkzg3d1-1
interface/mgmapi/mgmglobals.i mgm.i-20070228021421-qkr4cbpxymyqdrf3-8
java/mgmj.i mgmapi.i-20070415064013-80k9rsqzumm2kjaf-1
python/mgmapi.i
svn-v2:10@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fmgm.i
=== added file 'python/testmgm.py'
--- a/python/testmgm.py 1970-01-01 00:00:00 +0000
+++ b/python/testmgm.py 2007-11-20 01:08:15 +0000
@@ -0,0 +1,21 @@
+from mysql.cluster import mgmapi
+
+mgm = mgmapi.NdbMgmFactory.createNdbMgm("localhost")
+mgm.setConnectTimeout(4000)
+mgm.connect(5,3,True)
+
+theList = mgmapi.NdbFilterList()
+theItem = mgmapi.NdbFilterItem(15,mgmapi.NDB_MGM_EVENT_CATEGORY_STATISTIC)
+theList.push_back(theItem)
+manager=mgm.createNdbLogEventManager(theList)
+
+while(True):
+ event = manager.getLogEvent(5000)
+ if event is not None:
+ if event.getEventType() == mgmapi.NDB_LE_TransReportCounters:
+ theEvent = mgmapi.TransReportCountersEvent(event)
+ print "Trans count: ",theEvent.transCount
+ print "Read count: ", theEvent.readCount
+ print "Scan count: ", theEvent.scanCount
+ print "Range count: ", theEvent.rangeScanCount
+ print "Got an Event from Node %s\t%s" %
(event.getSourceNodeId(),event.getEventType())
=== modified file 'interface/mgmapi/NdbLogEventManager.i'
--- a/interface/mgmapi/NdbLogEventManager.i 2007-11-19 23:55:29 +0000
+++ b/interface/mgmapi/NdbLogEventManager.i 2007-11-20 01:08:15 +0000
@@ -22,7 +22,6 @@
#include <vector>
#include <map>
#include <stdexcept>
-#include "mgmapi.h"
%}
%{
@@ -52,11 +51,14 @@
std::map<ndb_mgm_event_category,NdbLogEventCategoryListener *>
evtCategoryListeners;
public:
-
+
NdbLogEventManager(ndb_logevent_handle * theHandle) {
this->handle=theHandle;
}
-
+
+ ~NdbLogEventManager() {
+ ndb_mgm_destroy_logevent_handle(&handle);
+ }
const char * getMgmError() {
return ndb_logevent_get_latest_error_msg(this->handle);
}
@@ -192,15 +194,16 @@
virtual Ndb_logevent_type getEventType();
};
+%typemap(newfree) (BaseEventWrapper *) "free($1);";
%newobject NdbLogEventManager::getLogEvent;
class NdbLogEventManager {
NdbLogEventManager();
- ~NdbLogEventManager();
ndb_logevent_handle * handle;
NdbLogEventManager(ndb_logevent_handle * theHandle);
public:
// Returns -1 on error, 0 otherwise
+ ~NdbLogEventManager();
int registerListener(NdbLogEventTypeListener * listener);
bool unregisterListener(NdbLogEventTypeListener * listener);
int registerCategoryListener(NdbLogEventCategoryListener * listener);
=== modified file 'interface/mgmapi/mgmglobals.i'
--- a/interface/mgmapi/mgmglobals.i 2007-11-19 09:34:49 +0000
+++ b/interface/mgmapi/mgmglobals.i 2007-11-20 01:08:15 +0000
@@ -26,7 +26,7 @@
#include <vector>
#include "ndb_init.h"
-#include "mgmapi.h"
+#include "storage/ndb/mgmapi/mgmapi.h"
#include "mgmapi_debug.h"
%}
=== modified file 'java/mgmj.i'
--- a/java/mgmj.i 2007-11-19 23:55:29 +0000
+++ b/java/mgmj.i 2007-11-20 01:08:15 +0000
@@ -53,7 +53,6 @@
long cPtr = $jnicall;
return (cPtr == 0) ? null : new NdbLogEvent(cPtr,true);
}
-%typemap(newfree) (BaseEventWrapper *) "free($1);";
/*
%rename NdbMgmLogEventManager NdbMgmLogEventManagerRef;
%rename NdbMgmReply NdbMgmReplyRef;
=== modified file 'python/mgmapi.i'
--- a/python/mgmapi.i 2007-11-06 22:59:00 +0000
+++ b/python/mgmapi.i 2007-11-20 01:08:15 +0000
@@ -17,7 +17,13 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-%module mgmapi
+%module(directors="1") mgmapi
+
+%typemap(out) (BaseEventWrapper *) %{
+ //Monty
+ $result = SWIG_NewPointerObj(SWIG_as_voidptr(result->theEvent),
SWIGTYPE_p_ndb_logevent, SWIG_POINTER_OWN | 0 );
+ %}
+
%include "mgmapi/mgmglobals.i"
%include "mgmapi/NdbLogEvent.i"
@@ -119,3 +125,5 @@
%}
+
+
| Thread |
|---|
| • Rev 266: Added python support for MGM API. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel | Monty Taylor | 20 Nov |