At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
------------------------------------------------------------
revno: 403
revision-id:mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Wed 2008-01-02 18:04:44 -0600
message:
Made a stab at getting async transactions to work.
added:
csharp/examples/asyncexample/ asyncexample-20080102230453-twj4rhaq4m4dqimf-1
csharp/examples/asyncexample/AssemblyInfo.cs
assemblyinfo.cs-20080102230453-twj4rhaq4m4dqimf-2
csharp/examples/asyncexample/asyncexample.mdp
asyncexample.mdp-20080102230453-twj4rhaq4m4dqimf-3
csharp/ndbapi/BaseCallback.cs basecallback.cs-20080103000439-c0xuyit3u16x06r3-1
renamed:
csharp/examples/testasync.cs => csharp/examples/asyncexample/testasync.cs
testasync.cs-20071231170428-eqdg2d7b4syqjhgt-2
modified:
csharp/Makefile.am makefile.in-20070228073157-gkwqutuh9f3nq7s2-1
csharp/csharp.mds csharp.mds-20071231171226-bgekh6don5s6evnk-1
csharp/examples/examples.mdp test.mdp-20071231171204-0aihyf88clt213sl-1
csharp/ndbapi.i
svn-v2:10@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-csharp%2fndb.i
csharp/ndbapi/AssemblyInfo.cs assemblyinfo.cs-20071231171137-ybu6s56tjq6zugaj-1
csharp/ndbapi/ndbapi.mdp ndbapi.mdp-20071231171154-cc3a94g06bm81lq9-1
csharp/examples/asyncexample/testasync.cs testasync.cs-20071231170428-eqdg2d7b4syqjhgt-2
=== added directory 'csharp/examples/asyncexample'
=== added file 'csharp/examples/asyncexample/AssemblyInfo.cs'
--- a/csharp/examples/asyncexample/AssemblyInfo.cs 1970-01-01 00:00:00 +0000
+++ b/csharp/examples/asyncexample/AssemblyInfo.cs 2008-01-03 00:04:44 +0000
@@ -0,0 +1,30 @@
+// AssemblyInfo.cs created with MonoDevelop
+// User: mtaylor at 5:04 PM 1/2/2008
+//
+// To change standard headers go to Edit->Preferences->Coding->Standard Headers
+//
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("asyncexample")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// If the build and revision are set to '*' they will be updated automatically.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
=== added file 'csharp/examples/asyncexample/asyncexample.mdp'
--- a/csharp/examples/asyncexample/asyncexample.mdp 1970-01-01 00:00:00 +0000
+++ b/csharp/examples/asyncexample/asyncexample.mdp 2008-01-03 00:04:44 +0000
@@ -0,0 +1,25 @@
+<Project name="asyncexample" fileversion="2.0" language="C#" clr-version="Net_2_0"
ctype="DotNetProject">
+ <Configurations active="Debug">
+ <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+ <Output directory="bin/Debug" assembly="asyncexample" />
+ <Build debugmode="True" target="Exe" />
+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet"
clr-version="Net_2_0" />
+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True"
unsafecodeallowed="False" generateoverflowchecks="True" mainclass=""
generatexmldocumentation="False" win32Icon="." ctype="CSharpCompilerParameters" />
+ </Configuration>
+ <Configuration name="Release" ctype="DotNetProjectConfiguration">
+ <Output directory="bin/Release" assembly="asyncexample" />
+ <Build debugmode="False" target="Exe" />
+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet"
clr-version="Net_2_0" />
+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True"
unsafecodeallowed="False" generateoverflowchecks="True" mainclass=""
generatexmldocumentation="False" win32Icon="." ctype="CSharpCompilerParameters" />
+ </Configuration>
+ </Configurations>
+ <Contents>
+ <File name="AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
+ <File name="testasync.cs" subtype="Code" buildaction="Compile" />
+ </Contents>
+ <References>
+ <ProjectReference type="Project" localcopy="True" refto="ndbapi" />
+ <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <ProjectReference type="Assembly" localcopy="True" refto="../../MySql.Data.dll"
/>
+ </References>
+</Project>
\ No newline at end of file
=== added file 'csharp/ndbapi/BaseCallback.cs'
--- a/csharp/ndbapi/BaseCallback.cs 1970-01-01 00:00:00 +0000
+++ b/csharp/ndbapi/BaseCallback.cs 2008-01-03 00:04:44 +0000
@@ -0,0 +1,75 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace MySql.Cluster.NdbApi {
+
+ public delegate void AsynchCallbackDelegate(int result, IntPtr theTrans);
+
+ public abstract class BaseCallback {
+
+ public long currentTime {
+ get {
+ return ndbapiPINVOKE.getMicroTime();
+ }
+ }
+
+ public long elapsedTime {
+ get {
+ return this.currentTime - this.create_time;
+ }
+ }
+
+ public long executeTime {
+ get {
+ return this.end_time - this.create_time;
+ }
+ }
+
+ public long callbackTime {
+ get {
+ return this.end_time - this.start_time;
+ }
+ }
+ protected long create_time;
+ protected long start_time;
+ protected long end_time;
+ protected NdbTransaction theTrans = null;
+
+ internal AsynchCallbackDelegate theCallback = null;
+
+ public BaseCallback() {
+ create_time = 0;
+ start_time = 0;
+ end_time = 0;
+ theCallback = new AsynchCallbackDelegate(cli_call_callback);
+ }
+
+ internal AsynchCallbackDelegate registerTransactionHook(NdbTransaction trans) {
+ theTrans=trans;
+ return theCallback;
+ }
+
+ protected void cli_call_callback(int result, IntPtr transPtr) {
+
+ this.start_time = this.currentTime;
+ if (NdbTransaction.getCPtr(theTrans).Equals(transPtr)) {
+ this.callback(result);
+ } else {
+ // Something is horrible wrong! The transaction we were passed is not the same as
the
+ // transaction we are storing. TODO: How do we deal with this?
+ this.callback(result);
+ }
+ this.end_time = this.currentTime;
+ }
+
+ public abstract void callback(int result);
+
+ public NdbError ndbError {
+ get {
+ return theTrans.getNdbError();
+ }
+ }
+
+ }
+
+}
=== renamed file 'csharp/examples/testasync.cs' =>
'csharp/examples/asyncexample/testasync.cs'
--- a/csharp/examples/testasync.cs 2007-12-31 17:04:42 +0000
+++ b/csharp/examples/asyncexample/testasync.cs 2008-01-03 00:04:44 +0000
@@ -25,17 +25,16 @@
//public delegate void AsynchDelegate(int retval, NdbTransaction trans, object
anyObject);
-class CSCallback : BaseCallback {
+class CSCallback : BaseCallback {
NdbRecAttr results;
-
- public CSCallback(NdbRecAttr results) {
+
+ public CSCallback(NdbRecAttr results, NdbTransaction trans) {
this.results = results ;
}
- public override void callback(int ret, NdbTransaction trans) {
-
- uint foo=this.results.u_32_value();
+ public override void callback(int ret) {
+ uint foo=this.results.getUint32();
Console.WriteLine("In callback from C#! {0}",foo);
}
}
@@ -91,12 +90,12 @@
NdbClusterConnection connection = NdbFactory.createNdbClusterConnection();
- if (connection.connect(5,3,1) != 0) {
+ if (connection.connect(5,3,true) != 0) {
Console.WriteLine("Connect to cluster management server failed.");
return -1;
}
- if (connection.wait_until_ready(30,30) != 0) {
+ if (connection.waitUntilReady(30,30) != 0) {
Console.WriteLine("Cluster was not ready within 30 secs.");
return -1;
}
@@ -128,8 +127,8 @@
ulong auto_id = myNdb.getAutoIncrementValue("mytablename",(uint)BATCH_SIZE);
//auto_id=(t*BATCH_SIZE)+i
- myOperation.equal("ATTR1",auto_id);
- myOperation.setValue("ATTR2", i);
+ myOperation.equalUlong("ATTR1",auto_id);
+ myOperation.setInt("ATTR2", i);
}
@@ -154,9 +153,7 @@
NdbScanOperation myScanOperation =
myTransaction.getNdbScanOperation("mytablename");
- if (myScanOperation.readTuples(NdbOperation.LockMode.LM_CommittedRead) == -1) {
- Console.WriteLine(myScanOperation.getNdbError().getMessage());
- }
+ myScanOperation.readTuples(NdbOperation.LockMode.LM_CommittedRead);
NdbRecAttr myRecAttr=myScanOperation.getValue("ATTR1");
@@ -166,7 +163,7 @@
while(true) {
if (myScanOperation.nextResult(true) != 0)
break;
- ulong random_id = myRecAttr.u_32_value();
+ ulong random_id = myRecAttr.getUint32();
ids.Add(random_id);
}
@@ -194,11 +191,11 @@
ulong id_num = ids[rand.Next(0,ids.Count)];
- myOper.equal("ATTR1",id_num);
+ myOper.equalUlong("ATTR1",id_num);
NdbRecAttr myRecAttr= myOper.getValue("ATTR2");
- CSCallback cb = new CSCallback(myRecAttr);
+ CSCallback cb = new CSCallback(myRecAttr,myTransaction);
myTransaction.executeAsynchPrepare( ExecType.Commit , cb, AbortOption.AO_IgnoreError );
=== modified file 'csharp/Makefile.am'
--- a/csharp/Makefile.am 2007-12-31 17:12:36 +0000
+++ b/csharp/Makefile.am 2008-01-03 00:04:44 +0000
@@ -1,3 +1,4 @@
+NDBAPI_SOURCE = $(shell ls ndbapi/*cs)
NDBAPI_BUILT_SRC=AbortOption.cs NdbScanOperation.cs ExecType.cs
NdbTransaction.cs Ndb_cluster_connection.cs SWIGTYPE*cs ndb.cs
Ndb.cs NdbOperation.cs ndbPINVOKE.cs
NdbRecAttr.cs NdbError.cs NdbFactory.cs
MYSQL_DLL = MySql.Data.dll
CLEANFILES = ndbapi.dll *exe test/*exe ndbapi.cpp MySql.Cluster.NdbApi.dll
ndbapi/generated/* mgmapi/generated/* mgmapi.cpp MySql.Cluster.MgmApi.dll
@@ -22,12 +23,12 @@
SUFFIXES = .exe .cs .i .cpp
.cs.exe: MySql.Cluster.NdbApi.dll ndbapi.cpp
- $(MCS) -keyfile:connectors.snk -r:MySql.Cluster.NdbApi.dll -r:$(MYSQL_DLL) $<
+ $(MCS) -r:MySql.Cluster.NdbApi.dll -r:$(MYSQL_DLL) $<
MySql.Cluster.MgmApi.dll:
- $(MCS) -keyfile:connectors.snk -target:library -out:$@ mgmapi/*.cs mgmapi/generated/*.cs
-MySql.Cluster.NdbApi.dll:
- $(MCS) -keyfile:connectors.snk -target:library -out:$@ ndbapi/*.cs ndbapi/generated/*.cs
+ $(MCS) -target:library -out:$@ mgmapi/*.cs mgmapi/generated/*.cs
+MySql.Cluster.NdbApi.dll: $(NDBAPI_SOURCE)
+ $(MCS) -target:library -out:$@ ndbapi/*.cs ndbapi/generated/*.cs
#$(CSHARP_SOURCES)
#.PRECIOUS: %.cpp %.so %.dll
=== modified file 'csharp/csharp.mds'
--- a/csharp/csharp.mds 2007-12-31 22:48:46 +0000
+++ b/csharp/csharp.mds 2008-01-03 00:04:44 +0000
@@ -6,6 +6,8 @@
<Entry build="True" name="Packages" configuration="" />
<Entry build="True" name="test" configuration="Debug" />
<Entry build="True" name="test" configuration="Debug" />
+ <Entry build="True" name="testasync" configuration="Debug" />
+ <Entry build="True" name="asyncexample" configuration="Debug" />
</Configuration>
<Configuration name="Release" ctype="CombineConfiguration">
<Entry build="True" name="ndbapi" configuration="Release" />
@@ -13,6 +15,8 @@
<Entry build="True" name="Packages" configuration="" />
<Entry build="True" name="test" configuration="Release" />
<Entry build="True" name="test" configuration="Release" />
+ <Entry build="True" name="testasync" configuration="Release" />
+ <Entry build="True" name="asyncexample" configuration="Release" />
</Configuration>
</Configurations>
<StartMode startupentry="ndbapi" single="True">
@@ -21,6 +25,8 @@
<Execute type="None" entry="Packages" />
<Execute type="None" entry="test" />
<Execute type="None" entry="test" />
+ <Execute type="None" entry="testasync" />
+ <Execute type="None" entry="asyncexample" />
</StartMode>
<Entries>
<Entry filename="ndbapi/ndbapi.mdp" />
@@ -28,5 +34,7 @@
<Entry filename="Packages.mdse" />
<Entry filename="examples/examples.mdp" />
<Entry filename="test/test.mdp" />
+ <Entry filename="test/testasync/testasync.mdp" />
+ <Entry filename="examples/asyncexample/asyncexample.mdp" />
</Entries>
</Combine>
\ No newline at end of file
=== modified file 'csharp/examples/examples.mdp'
--- a/csharp/examples/examples.mdp 2007-12-31 22:48:46 +0000
+++ b/csharp/examples/examples.mdp 2008-01-03 00:04:44 +0000
@@ -17,7 +17,6 @@
<File name="AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
<File name="test.cs" subtype="Code" buildaction="Compile" />
<File name="test2.cs" subtype="Code" buildaction="Compile" />
- <File name="testasync.cs" subtype="Code" buildaction="Compile" />
<File name="bin/Debug/mgmapi.dll.mdb" subtype="Code" buildaction="Exclude" />
<File name="bin/Debug/ndbapi.dll.mdb" subtype="Code" buildaction="Exclude" />
</Contents>
=== modified file 'csharp/ndbapi.i'
--- a/csharp/ndbapi.i 2007-11-25 23:22:57 +0000
+++ b/csharp/ndbapi.i 2008-01-03 00:04:44 +0000
@@ -28,6 +28,7 @@
internal void addReference(Ndb ndbref) {
ndbReference = ndbref;
}
+
%}
%typemap(csout, excode=SWIGEXCODE) NdbTransaction* Ndb::startTransaction {
@@ -137,21 +138,16 @@
%}
-/*%typemap(ctype) (asynch_callback_t *) "AsynchCallback_t"
-%typemap(cstype) asynch_callback_t * "Object"
-//%typemap(imtype) asynch_callback_t * "BaseCallback"
-%typemap(imtype) asynch_callback_t * "System.Runtime.InteropServices.HandleRef"
-%typemap(csin) asynch_callback_t * "(Object)$csinput"
-*/
+
+%typemap(ctype) (asynch_callback_t *) "AsynchCallback_t"
+%typemap(cstype) asynch_callback_t * "BaseCallback"
+%typemap(imtype) asynch_callback_t * "AsynchCallbackDelegate"
+ //%typemap(imtype) asynch_callback_t * "System.Runtime.InteropServices.HandleRef"
+%typemap(csin) asynch_callback_t * "$csinput.registerTransactionHook(this)"
+
%pragma(csharp) imclasscode=%{
- class AsynchHelper {
-
- public delegate void AsynchCallbackDelegate(int result, NdbTransaction theTrans);
-
- }
-
class CustomExceptionHelper {
// C# delegate for the C/C++ customExceptionCallback
public delegate void CustomExceptionDelegate(int excp, string message);
=== modified file 'csharp/ndbapi/AssemblyInfo.cs'
--- a/csharp/ndbapi/AssemblyInfo.cs 2007-12-31 17:12:36 +0000
+++ b/csharp/ndbapi/AssemblyInfo.cs 2008-01-03 00:04:44 +0000
@@ -34,4 +34,4 @@
// .NET Framework documentation for more information about signing.
// This is not required, if you don't want signing let these attributes like they're.
[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyFile("connectors.snk")]
=== modified file 'csharp/ndbapi/ndbapi.mdp'
--- a/csharp/ndbapi/ndbapi.mdp 2007-12-31 22:48:46 +0000
+++ b/csharp/ndbapi/ndbapi.mdp 2008-01-03 00:04:44 +0000
@@ -42,13 +42,7 @@
<File name="generated/NdbScanOperation.cs" subtype="Code" buildaction="Compile"
/>
<File name="generated/NdbTable.cs" subtype="Code" buildaction="Compile" />
<File name="generated/NdbTransaction.cs" subtype="Code" buildaction="Compile"
/>
- <File name="generated/SWIGTYPE_p_asynch_callback_t.cs" subtype="Code"
buildaction="Compile" />
- <File name="generated/SWIGTYPE_p_BYTES.cs" subtype="Code" buildaction="Compile"
/>
- <File name="generated/SWIGTYPE_p_MYSQL_TIME.cs" subtype="Code"
buildaction="Compile" />
- <File name="generated/SWIGTYPE_p_p_char.cs" subtype="Code" buildaction="Compile"
/>
- <File name="generated/SWIGTYPE_p_voidint.cs" subtype="Code" buildaction="Compile"
/>
<File name="BaseCallback.cs" subtype="Code" buildaction="Compile" />
- <File name="bin/Debug/ndbapi.dll.mdb" subtype="Code" buildaction="Exclude" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />
| Thread |
|---|
| • Rev 403: Made a stab at getting async transactions to work. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel | Monty Taylor | 3 Jan |