At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge
------------------------------------------------------------
revno: 194
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Tue 2007-10-23 16:47:41 -0700
message:
Fixed async transactions. New form of createNdb() now, that instead of a boolean takes
the parameter to send to init(). In the process, noticed that getAutoIncrementValue() is
now broken. (if it isn't one thing, it's another)
removed:
java/testsuite/ndbj/ClusterConfiguratorBase.java
clusterconfiguratorb-20070517181935-98huwjarzuh25b30-46
modified:
java/com/mysql/cluster/ndbj/Ndb.java ndb.java-20070517181935-98huwjarzuh25b30-2
java/com/mysql/cluster/ndbj/NdbClusterConnection.java
ndbclusterconnection-20070517181935-98huwjarzuh25b30-9
java/com/mysql/cluster/ndbj/examples/CRUDandScan.java
crudandscan.java-20070517181935-98huwjarzuh25b30-32
java/com/mysql/cluster/ndbj/examples/DeleteUsingPrimaryKey.java
deleteusingprimaryke-20070517181935-98huwjarzuh25b30-33
java/com/mysql/cluster/ndbj/examples/ExamplesConfigurator.java
examplesconfigurator-20070517181935-98huwjarzuh25b30-34
java/com/mysql/cluster/ndbj/examples/InsertUsingPrimaryKey.java
insertusingprimaryke-20070517181935-98huwjarzuh25b30-36
java/com/mysql/cluster/ndbj/examples/JoinUsingScanAndIndexScan.java
joinusingscanandinde-20070517181935-98huwjarzuh25b30-37
java/com/mysql/cluster/ndbj/examples/PrimaryKeyBatchOps.java
primarykeybatchops.j-20070517181935-98huwjarzuh25b30-38
java/com/mysql/cluster/ndbj/examples/PrimaryKeyOpBlob.java
primarykeyopblob.jav-20070517181935-98huwjarzuh25b30-39
java/com/mysql/cluster/ndbj/examples/ReadRowsUsingTableScan.java
readrowsusingtablesc-20070517181935-98huwjarzuh25b30-40
java/com/mysql/cluster/ndbj/examples/ReadUsingOrderedIndexOnPK.java
readusingorderedinde-20070517181935-98huwjarzuh25b30-41
java/com/mysql/cluster/ndbj/examples/ReadUsingPrimaryKey.java
readusingprimarykey.-20070517181935-98huwjarzuh25b30-42
java/com/mysql/cluster/ndbj/examples/RetryTransaction.java
retrytransaction.jav-20070517181935-98huwjarzuh25b30-43
java/com/mysql/cluster/ndbj/examples/TestAsync.java
testasync.java-20070703002120-jsnz1ul38pp1h3w3-1
java/com/mysql/cluster/ndbj/examples/UpdateUsingPrimaryKey.java
updateusingprimaryke-20070517181935-98huwjarzuh25b30-44
java/testsuite/BaseNdbjTestCase.java basejdbc.java-20070517181935-98huwjarzuh25b30-45
java/testsuite/ndbj/NdbOperationIDTest.java
ndboperationidtest.j-20070517181935-98huwjarzuh25b30-53
swig/Ndb.i ndb.i-20070228021421-qkr4cbpxymyqdrf3-1
swig/NdbClusterConnection.i ndb_cluster_connecti-20070228021421-qkr4cbpxymyqdrf3-6
=== removed file 'java/testsuite/ndbj/ClusterConfiguratorBase.java'
--- a/java/testsuite/ndbj/ClusterConfiguratorBase.java 2007-09-14 07:54:14 +0000
+++ b/java/testsuite/ndbj/ClusterConfiguratorBase.java 1970-01-01 00:00:00 +0000
@@ -1,273 +0,0 @@
-package testsuite.ndbj;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import com.mysql.cluster.ndbj.Ndb;
-import com.mysql.cluster.ndbj.NdbApiException;
-import com.mysql.cluster.ndbj.NdbClusterConnection;
-import com.mysql.cluster.ndbj.NdbFactory;
-import com.mysql.cluster.ndbj.NdbTransaction;
-
-public class ClusterConfiguratorBase
-{
- protected static String CONFIG_FILENAME="ndbj.props";
- protected static String MYSQLD_HOST="localhost:26099";
- protected static String NDB_MGMD_CONNECTSTRING="";
- protected static String DB_NAME="test";
- protected static String TABLE_NAME="";
- protected static String LIB_PATH = "/usr/local/mysql/lib/mysql";;
- protected static String USERNAME = "root";
- protected static String PASSWORD = "";
- protected static String CLUSTER_LOG="";
- protected static final int MAX_NUM_TRANSACTIONS=4;
- protected static Connection MYSQL_CONN=null;
-
- protected NdbClusterConnection conn=null;
- protected Ndb ndb=null;
- protected NdbTransaction trans=null;
-
- protected static void createTable(String tableName, String schemaDefinition)
- throws NdbApiException {
- TABLE_NAME=tableName;
-
-
- /**
- * Connect to mysql server
- */
- String dBaseName = "jdbc:mysql://"+MYSQLD_HOST+"/" +DB_NAME;
-
-
- try {
- Class.forName("org.gjt.mm.mysql.Driver").newInstance();
- }
- catch (Exception e) {
- System.err.println("Error loading driver: " + e.toString());
- System.exit(-1);
- }
-
- try {
- MYSQL_CONN = DriverManager.getConnection(dBaseName, USERNAME, PASSWORD);
- Statement stmt = MYSQL_CONN.createStatement();
- String dropTable = "DROP TABLE IF EXISTS " + TABLE_NAME;
- String schemaDefinitionStr ="CREATE TABLE IF NOT EXISTS `"
- + TABLE_NAME + "` " + schemaDefinition;
- System.out.println(schemaDefinitionStr );
- stmt.execute(dropTable);
- stmt.execute(schemaDefinitionStr);
- stmt.close();
- } catch (SQLException e) {
- System.err.println(e.toString());
- System.exit(-1);
- }
- catch (Exception e) {
- System.err.println("Couldn't connect to mysql server with DB_NAME="+dBaseName+",
uname="+USERNAME+", pwd="+PASSWORD);
- System.exit(-1);
- }
- finally {
- try {
- if (MYSQL_CONN != null)
- MYSQL_CONN.close();
- }
- catch (SQLException e) {
- System.err.println(e.toString());
- System.exit(-1);
- }
- }
-
-
-
- }
- protected ClusterConfiguratorBase(String configFileName) {
-
- CONFIG_FILENAME=configFileName;
-
- /**
- * Set environment variables
- */
-
- File f =null;
- try {
- InputStream in=null;
- f = new File(CONFIG_FILENAME);
- if (f.exists()){
- if (f.canRead()){
- in = new FileInputStream(f);
- }
- else {
- System.err.println("Could not open " + CONFIG_FILENAME);
- System.exit(-1);
- }
- }
- else {
- System.err.println("Could not find " + CONFIG_FILENAME);
- System.exit(-1);
- }
-
- Properties p = new Properties(System.getProperties());
- p.load(in);
-
- // set the system properties
- System.setProperties(p);
-
- ClusterConfiguratorBase.MYSQLD_HOST = System.getProperty("ndbj.mysqld");
- if (ClusterConfiguratorBase.MYSQLD_HOST == null) {
- System.out.println("ndbj.mysql not defined in configuration file: + " +
CONFIG_FILENAME);
-
- }
-
- ClusterConfiguratorBase.NDB_MGMD_CONNECTSTRING=
System.getProperty("ndbj.connectstring");
- if (ClusterConfiguratorBase.NDB_MGMD_CONNECTSTRING == null) {
- System.out.println("ndbj.connectstring not defined in configuration file: + " +
CONFIG_FILENAME);
- }
-
- ClusterConfiguratorBase.DB_NAME= System.getProperty("ndbj.testDatabase");
- if (ClusterConfiguratorBase.DB_NAME == null) {
- System.out.println("ndbj.testDatabase was empty. Setting it to 'test' db.");
- }
-
- ClusterConfiguratorBase.LIB_PATH= System.getProperty("ndbj.libpath");
- if (ClusterConfiguratorBase.LIB_PATH == null) {
- System.out.println("ndbj.libpath not defined in configuration file. It contains the
directory with the ndbj libraries. Config file : + " + CONFIG_FILENAME);
-
- }
-
- ClusterConfiguratorBase.USERNAME = System.getProperty("ndbj.username");
- if (ClusterConfiguratorBase.USERNAME == null) {
- System.out.println("ndbj.username was empty. Setting it to 'root'.");
- }
-
- ClusterConfiguratorBase.PASSWORD = System.getProperty("ndbj.password");
- if (ClusterConfiguratorBase.PASSWORD == null) {
- System.out.println("ndbj.password was empty. Setting it to empty string ''");
- }
-
- ClusterConfiguratorBase.CLUSTER_LOG= System.getProperty("ndbj.clusterLog");
- if (ClusterConfiguratorBase.CLUSTER_LOG== null) {
- System.out.println("ndbj.clusterLog was empty. Setting it to empty string ''");
- }
- }
- catch (java.io.FileNotFoundException e) {
- System.err.println(e.getMessage());
-
- }
- catch (java.io.IOException e) {
- System.err.println(e.getMessage());
-
- }
- catch (NullPointerException e) {
- System.err.println(e.getMessage());
-
- }
- catch (IllegalArgumentException e) {
- System.err.println(e.getMessage());
-
- }
- catch (SecurityException e) {
- System.err.println(e.getMessage());
-
- }
-
-
-
- Class clazz = ClassLoader.class;
- Field field;
- boolean accessible;
- try {
- // Reset the "sys_paths" field of the ClassLoader to null.
- field = clazz.getDeclaredField("sys_paths");
- accessible = field.isAccessible();
- if (!accessible)
- field.setAccessible(true);
- // Reset it to null so that whenever "System.loadLibrary" is called, it will be
reconstructed with the changed value.
- field.set(clazz, null);
- System.setProperty("java.library.path", LIB_PATH);
- }
- catch (java.lang.UnsatisfiedLinkError e) {
- System.err.println(e.getMessage());
- }
- catch (NoSuchFieldException e) {
- System.err.println(e.getMessage());
- }
- catch (IllegalAccessException e) {
- System.err.println(e.getMessage());
- }
-
-
-
- }
-
- public void setUp() throws Exception {
- /**
- * Connect to cluster, done once for each Application
- */
-
- try {
-
- conn = NdbFactory.createNdbClusterConnection(NDB_MGMD_CONNECTSTRING);
- conn.connect(5,3,true);
- conn.waitUntilReady(30,0);
- /**
- * Get a connection to NDB (once / thread)
- */
- ndb = conn.createNdb(ClusterConfiguratorBase.DB_NAME,true);
- }
- catch (NdbApiException e) {
- System.err.println("failed initialisation");
- System.exit(-1);
- }
- }
-
- public void close() throws Exception {
-
- String dBaseName = "jdbc:mysql://"+MYSQLD_HOST+"/" +DB_NAME;
-
- try {
- Class.forName("org.gjt.mm.mysql.Driver").newInstance();
- }
- catch (Exception e) {
- System.err.println("Error loading driver: " + e.toString());
- System.exit(-1);
- }
-
- try {
- MYSQL_CONN = DriverManager.getConnection(dBaseName, USERNAME, PASSWORD);
- Statement stmt = MYSQL_CONN.createStatement();
- String dropTable = "DROP TABLE IF EXISTS " + TABLE_NAME;
- stmt.execute(dropTable);
- stmt.close();
- } catch (SQLException e) {
- System.err.println(e.toString());
- System.exit(-1);
- }
- catch (Exception e) {
- System.err.println("Couldn't connect to mysql server with
DB_NAME="+dBaseName+", uname="+USERNAME+", pwd="+PASSWORD);
- System.exit(-1);
- }
- finally {
- try {
- if (MYSQL_CONN != null)
- MYSQL_CONN.close();
- }
- catch (SQLException e) {
- System.err.println(e.toString());
- System.exit(-1);
- }
- }
-
- if (ndb != null)
- ndb.close();
- if (conn != null)
- conn.close();
-
-
- }
-
-}
=== modified file 'java/com/mysql/cluster/ndbj/Ndb.java'
--- a/java/com/mysql/cluster/ndbj/Ndb.java 2007-10-10 20:43:37 +0000
+++ b/java/com/mysql/cluster/ndbj/Ndb.java 2007-10-23 23:47:41 +0000
@@ -109,7 +109,7 @@
*/
public abstract void close();
- public BigInteger getAutoIncrementValue(String aTableName, long cacheSize) throws
NdbApiException;
+ public long getAutoIncrementValue(String aTableName, long cacheSize) throws
NdbApiException;
public abstract int sendPollNdb(int aMillisecondNumber) throws NdbApiException;
@@ -122,4 +122,6 @@
public NdbEventOperation createEventOperation(String eventName) throws NdbApiException;
public NdbTransaction startTransaction(NdbTable table, int keyData) throws
NdbApiException;
+
+ public long getAutoIncrementValue(NdbTable myTable, long cacheSize) throws
NdbApiException;
}
\ No newline at end of file
=== modified file 'java/com/mysql/cluster/ndbj/NdbClusterConnection.java'
--- a/java/com/mysql/cluster/ndbj/NdbClusterConnection.java 2007-09-30 02:06:41 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbClusterConnection.java 2007-10-23 23:47:41 +0000
@@ -4,7 +4,7 @@
/**
* This class represents a connection to a cluster of data nodes.
* A NdbClusterConnectionImpl object is used to bind to
- * a cluster. It is needed to create NdbRef objects, that in turn can be used to
+ * a cluster. It is needed to create Ndb objects, that in turn can be used to
* create a NdbTransactionRef and operation objects.
* <p>
* The close() method must be called on a NdbClusterConnectionImpl object
@@ -45,13 +45,13 @@
*
*<p>
* There is no restriction against instantiating multiple NdbClusterConnectionImpl
objects representing connections to different management servers
- * in a single application, nor against using these for creating multiple instances of
the NdbRef class.
- * Such NdbClusterConnectionImpl objects (and the NdbRef instances based on them) are not
required even to connect to the same cluster.
+ * in a single application, nor against using these for creating multiple instances of
the Ndb class.
+ * Such NdbClusterConnectionImpl objects (and the Ndb instances based on them) are not
required even to connect to the same cluster.
* <p>
* For example, it is entirely possible to perform application-level partitioning of
data in such a manner that data
- * meeting one set of criteria are "handed off" to one cluster via an NdbRef object that
makes use of an NdbClusterConnectionImpl
+ * meeting one set of criteria are "handed off" to one cluster via an Ndb object that
makes use of an NdbClusterConnectionImpl
* object representing a connection to that cluster, while data not meeting those
criteria
- * (or perhaps a different set of criteria) can be sent to a different cluster through a
different instance of NdbRef
+ * (or perhaps a different set of criteria) can be sent to a different cluster through a
different instance of Ndb
* that makes use of an NdbClusterConnectionImpl "pointing" to the second cluster.
* <p>
* It is possible to extend this scenario to develop a single application that accesses
an arbitrary number of clusters.
@@ -60,21 +60,21 @@
* <li>A cluster management server (ndb_mgmd) can connect to one and only one
cluster without being restarted and reconfigured, as it must read the data telling it
which data nodes make up the cluster from a configuration file (config.ini).
* <li>An NdbClusterConnectionImpl object "belongs" to a single management server
whose hostname or IP address is used in instantiating this object (passed as the
connectstring argument to its constructor); once the object is created,
* it cannot be used to initiate a connection to a different management server.
- * <li>An NdbRef object making use of this connection (NdbClusterConnectionImpl)
cannot be re-used to connect to a different cluster management server
- * (and thus to a different collection of data nodes making up a cluster). Any given
instance of NdbRef is bound to a
+ * <li>An Ndb object making use of this connection (NdbClusterConnectionImpl)
cannot be re-used to connect to a different cluster management server
+ * (and thus to a different collection of data nodes making up a cluster). Any given
instance of Ndb is bound to a
* specific NdbClusterConnectionImpl when created, and that NdbClusterConnectionImpl is
in turn bound to a single and unique management server
* when it is instantiated.
- * <li>The bindings described above persist for the lifetimes of the NdbRef and
NdbClusterConnectionImpl objects in question.
+ * <li>The bindings described above persist for the lifetimes of the Ndb and
NdbClusterConnectionImpl objects in question.
* </ul>
* <p>
* Therefore, it is imperative in designing and implementing any application that
accesses multiple clusters in a single session,
- * that a separate set of NdbClusterConnectionImpl and NdbRef objects be instantiated
for connecting to each cluster management server,
+ * that a separate set of NdbClusterConnectionImpl and Ndb objects be instantiated for
connecting to each cluster management server,
* and that no confusion arises as to which of these is used to access which MySQL
Cluster.
* <p>
* It is also important to keep in mind that no direct "sharing" of data or data nodes
between different clusters is possible. A data node can belong to
* one and only one cluster, and any movement of data between clusters must be
accomplished on the application level.
*
- * @see NdbRef
+ * @see Ndb
* @see NdbTransactions
* @author jdowling
*/
@@ -114,43 +114,43 @@
/**
- * Factory method used to create a NdbRef object using the NdbClusterConnectionImpl
object.
- * Set the delayInit parameter to false to fully initialise the NdbRef object. If
- * you set delayInit to 'true', you need to call the init() method to fully initialise
the NdbRef object.
- * @param dirName is an optional parameter providing a namespace for the tables and
indexes created in any connection from the NdbRef object. The default value for this
parameter is an empty string.
+ * Factory method used to create a Ndb object using the NdbClusterConnectionImpl
object.
+ * Set the delayInit parameter to false to fully initialise the Ndb object. If
+ * you set delayInit to 'true', you need to call the init() method to fully initialise
the Ndb object.
+ * @param dirName is an optional parameter providing a namespace for the tables and
indexes created in any connection from the Ndb object. The default value for this
parameter is an empty string.
* @param schemaName The optional schemaName provides an additional namespace for the
tables and indexes created in a given catalog. The default value for this parameter is
the string “def”.
- * @param noDelayInit set to 'true' if you call the init() method for the NdbRef object
explicitly.
- * @return NdbRef object
- * @throws NdbApiException if a NdbRef object cannot be created.
+ * @param initThreads set to number of threads to pass to the init() method for the Ndb
object
+ * @return Ndb object
+ * @throws NdbApiException if a Ndb object cannot be created.
*/
- public abstract Ndb createNdb(String dirName, String schemaName, boolean noDelayInit)
+ public abstract Ndb createNdb(String dirName, String schemaName, int initThreads)
throws NdbApiException;
/**
- * Factory method used to create a NdbRef object using the NdbClusterConnectionImpl
object.
- * Set the delayInit parameter to false to fully initialise the NdbRef object. If
- * you set delayInit to 'true', you need to call the init() method to fully initialise
the NdbRef object.
- * @param dbName the name of the database for which we will use the NdbRef object.
- * @param noDelayInit set to 'true' if you call the init() method for the NdbRef object
explicitly.
- * @return NdbRef object
- * @throws NdbApiException if a NdbRef object cannot be created.
+ * Factory method used to create a Ndb object using the NdbClusterConnection object.
+ * Set the delayInit parameter to false to fully initialise the Ndb object. If
+ * you set delayInit to 'true', you need to call the init() method to fully initialise
the Ndb object.
+ * @param dbName the name of the database for which we will use the Ndb object.
+ * @param initThreads set to number of threads to pass to the init() method for the Ndb
object
+ * @return Ndb object
+ * @throws NdbApiException if a Ndb object cannot be created.
*/
- public abstract Ndb createNdb(String dbName, boolean noDelayInit) throws
NdbApiException;
+ public abstract Ndb createNdb(String dbName, int initThreads) throws NdbApiException;
/**
- * Factory method used to create a NdbRef object using the NdbClusterConnectionImpl
object.
- * @param dbName the name of the database for which we will use the NdbRef object.
- * @return NdbRef object
- * @throws NdbApiException if a NdbRef object cannot be created.
+ * Factory method used to create a Ndb object using the NdbClusterConnectionImpl
object.
+ * @param dbName the name of the database for which we will use the Ndb object.
+ * @return Ndb object
+ * @throws NdbApiException if a Ndb object cannot be created.
*/
public abstract Ndb createNdb(String dbName) throws NdbApiException;
/**
- * The close method must be called on a NdbClusterConnectionImpl object when it
+ * The close method must be called on a NdbClusterConnection object when it
* is no longer needed in order to free up its resources.
- * @return true if NdbRef object closed successfully, false if NdbRef object
+ * @return true if Ndb object closed successfully, false if Ndb object
* has already been closed
*/
public abstract boolean close();
=== modified file 'java/com/mysql/cluster/ndbj/examples/CRUDandScan.java'
--- a/java/com/mysql/cluster/ndbj/examples/CRUDandScan.java 2007-09-30 02:39:45 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/CRUDandScan.java 2007-10-23 23:47:41 +0000
@@ -126,15 +126,10 @@
/**
* Get a connection to a NDB object that is used to create transactions.
* We're going to initialise the ndb object with more than the default
- * number of transactions, so we pass noDelayInit as false.
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,false);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
- /**
- * Initialise the ndb object with maximum number of transaction equal to 12
- */
- ndb.init(12);
-
timeStamp = new Timestamp(System.currentTimeMillis());
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/DeleteUsingPrimaryKey.java'
--- a/java/com/mysql/cluster/ndbj/examples/DeleteUsingPrimaryKey.java 2007-09-14 10:08:14
+0000
+++ b/java/com/mysql/cluster/ndbj/examples/DeleteUsingPrimaryKey.java 2007-10-23 23:47:41
+0000
@@ -108,10 +108,13 @@
*/
conn.waitUntilReady(30,0);
+
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/ExamplesConfigurator.java'
--- a/java/com/mysql/cluster/ndbj/examples/ExamplesConfigurator.java 2007-09-14 07:54:14
+0000
+++ b/java/com/mysql/cluster/ndbj/examples/ExamplesConfigurator.java 2007-10-23 23:47:41
+0000
@@ -206,10 +206,12 @@
conn = NdbFactory.createNdbClusterConnection(CONNECTSTRING);
conn.connect(5,3,true);
conn.waitUntilReady(30,0);
- /**
- * Get a connection to NDB (once / thread)
- */
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ /**
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
+ */
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
catch (NdbApiException e) {
=== modified file 'java/com/mysql/cluster/ndbj/examples/InsertUsingPrimaryKey.java'
--- a/java/com/mysql/cluster/ndbj/examples/InsertUsingPrimaryKey.java 2007-09-14 10:08:14
+0000
+++ b/java/com/mysql/cluster/ndbj/examples/InsertUsingPrimaryKey.java 2007-10-23 23:47:41
+0000
@@ -105,11 +105,13 @@
* Wait 30 seconds for the cluster to be available, throw exception if it is not ready.
*/
conn.waitUntilReady(30,0);
-
+
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/JoinUsingScanAndIndexScan.java'
--- a/java/com/mysql/cluster/ndbj/examples/JoinUsingScanAndIndexScan.java 2007-10-01
19:23:10 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/JoinUsingScanAndIndexScan.java 2007-10-23
23:47:41 +0000
@@ -115,9 +115,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/PrimaryKeyBatchOps.java'
--- a/java/com/mysql/cluster/ndbj/examples/PrimaryKeyBatchOps.java 2007-10-01 06:12:42
+0000
+++ b/java/com/mysql/cluster/ndbj/examples/PrimaryKeyBatchOps.java 2007-10-23 23:47:41
+0000
@@ -117,9 +117,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
timeStamp = new Timestamp(System.currentTimeMillis());
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/PrimaryKeyOpBlob.java'
--- a/java/com/mysql/cluster/ndbj/examples/PrimaryKeyOpBlob.java 2007-10-02 22:56:43 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/PrimaryKeyOpBlob.java 2007-10-23 23:47:41 +0000
@@ -110,9 +110,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/ReadRowsUsingTableScan.java'
--- a/java/com/mysql/cluster/ndbj/examples/ReadRowsUsingTableScan.java 2007-10-01 06:12:42
+0000
+++ b/java/com/mysql/cluster/ndbj/examples/ReadRowsUsingTableScan.java 2007-10-23 23:47:41
+0000
@@ -99,9 +99,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/ReadUsingOrderedIndexOnPK.java'
--- a/java/com/mysql/cluster/ndbj/examples/ReadUsingOrderedIndexOnPK.java 2007-10-01
06:12:42 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/ReadUsingOrderedIndexOnPK.java 2007-10-23
23:47:41 +0000
@@ -102,9 +102,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/ReadUsingPrimaryKey.java'
--- a/java/com/mysql/cluster/ndbj/examples/ReadUsingPrimaryKey.java 2007-10-01 06:12:42
+0000
+++ b/java/com/mysql/cluster/ndbj/examples/ReadUsingPrimaryKey.java 2007-10-23 23:47:41
+0000
@@ -98,9 +98,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/RetryTransaction.java'
--- a/java/com/mysql/cluster/ndbj/examples/RetryTransaction.java 2007-09-14 10:08:14 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/RetryTransaction.java 2007-10-23 23:47:41 +0000
@@ -95,9 +95,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/TestAsync.java'
--- a/java/com/mysql/cluster/ndbj/examples/TestAsync.java 2007-09-30 02:06:41 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/TestAsync.java 2007-10-23 23:47:41 +0000
@@ -32,7 +32,6 @@
INSERT_NUM = Integer.parseInt(argv[1]);
int BATCH_SIZE=100;
- //com.mysql.cluster.ndbapi.ndbapi.ndb_init();
/**************************************************************
* Connect to mysql server and create table *
@@ -53,17 +52,19 @@
try {
- s.executeUpdate("DROP TABLE if exists " + table_name);
+ s.executeUpdate("DROP TABLE " + table_name);
} catch (SQLException e) {
+ System.out.println("Couldn't drop table: " + table_name);
}
try {
- s.executeUpdate("CREATE TABLE if not exists " +
+ s.executeUpdate("CREATE TABLE " +
table_name +
" (ATTR1 INT UNSIGNED," +
" ATTR2 INT UNSIGNED NOT NULL," +
" PRIMARY KEY (ATTR1) )" +
" ENGINE=NDBCLUSTER");
} catch (SQLException e) {
+ System.out.println("Couldn't create table: " + table_name);
}
@@ -95,10 +96,9 @@
System.exit(-1);
}
- Ndb myNdb = connection.createNdb( "test" ) ;
-
- myNdb.init(4);
-
+ Ndb myNdb = connection.createNdb( "test" , 1024) ;
+ NdbDictionary myDict = myNdb.getDictionary();
+ NdbTable myTable = myDict.getTable(table_name);
System.out.println("running tests:");
/**************************************************************************
@@ -120,12 +120,13 @@
for(int i=0;i<BATCH_SIZE-offset;i++) {
- NdbOperation myOperation = myTransaction.getNdbOperation(table_name);
+
+ long auto_id = myNdb.getAutoIncrementValue(myTable,BATCH_SIZE);
+ NdbOperation myOperation = myTransaction.getNdbOperation(myTable);
myOperation.insertTuple();
- java.math.BigInteger auto_id = myNdb.getAutoIncrementValue(table_name,BATCH_SIZE);
- myOperation.equal("ATTR1",auto_id);
+ myOperation.equal("ATTR1",((t-1)*BATCH_SIZE)+i);
myOperation.setLong("ATTR2", t*BATCH_SIZE+i);
}
=== modified file 'java/com/mysql/cluster/ndbj/examples/UpdateUsingPrimaryKey.java'
--- a/java/com/mysql/cluster/ndbj/examples/UpdateUsingPrimaryKey.java 2007-09-30 02:06:41
+0000
+++ b/java/com/mysql/cluster/ndbj/examples/UpdateUsingPrimaryKey.java 2007-10-23 23:47:41
+0000
@@ -110,9 +110,11 @@
conn.waitUntilReady(30,0);
/**
- * Get a connection to a NDB object that is used to create transactions
+ * Get a connection to a NDB object that is used to create transactions.
+ * We're going to initialise the ndb object with more than the default
+ * number of transactions, 12.
*/
- ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,true);
+ ndb = conn.createNdb(ExamplesConfigurator.DB_NAME,12);
}
=== modified file 'java/testsuite/BaseNdbjTestCase.java'
--- a/java/testsuite/BaseNdbjTestCase.java 2007-09-14 07:54:14 +0000
+++ b/java/testsuite/BaseNdbjTestCase.java 2007-10-23 23:47:41 +0000
@@ -165,8 +165,7 @@
/**
* Get a connection to NDB (once / thread)
*/
- ndb = conn.createNdb("test",false);
- ndb.init(1000);
+ ndb = conn.createNdb("test",1024);
System.out.println("connected");
} catch (NdbApiException e) {
=== modified file 'java/testsuite/ndbj/NdbOperationIDTest.java'
--- a/java/testsuite/ndbj/NdbOperationIDTest.java 2007-09-30 21:21:46 +0000
+++ b/java/testsuite/ndbj/NdbOperationIDTest.java 2007-10-23 23:47:41 +0000
@@ -5,11 +5,9 @@
import testsuite.BaseNdbjTestCase;
import com.mysql.cluster.ndbj.NdbApiException;
-import com.mysql.cluster.ndbj.NdbError;
import com.mysql.cluster.ndbj.NdbOperation;
import com.mysql.cluster.ndbj.NdbOperation.LockMode;
import com.mysql.cluster.ndbj.NdbResultSet;
-import com.mysql.cluster.ndbj.NdbTransaction;
import com.mysql.cluster.ndbj.AbortOption;
=== modified file 'swig/Ndb.i'
--- a/swig/Ndb.i 2007-10-10 20:43:37 +0000
+++ b/swig/Ndb.i 2007-10-23 23:47:41 +0000
@@ -82,7 +82,7 @@
}
int init(int maxNoOfTransactions = 4);
- %ndbexception("NdbApiException") getAutoIncrementValue {
+/* %ndbexception("NdbApiException") getAutoIncrementValue {
$action
if (result == 0) {
NdbError err = arg1->getNdbError();
@@ -95,7 +95,7 @@
Uint64 & OUTPUT, Uint32 cacheSize);
int getAutoIncrementValue(const NdbDictTable * aTable,
Uint64 & OUTPUT, Uint32 cacheSize);
-
+*/
@@ -103,7 +103,7 @@
%extend Ndb {
public:
- Uint64 getAutoIncrementValue(const char* aTableName,
+ Int64 getAutoIncrementValue(const char* aTableName,
Uint32 cacheSize) {
Uint64 id = 0;
@@ -111,7 +111,17 @@
if (ret == -1) {
return 0;
}
- return id;
+ return (Int64)id;
+ };
+ Int64 getAutoIncrementValue(NdbDictTable * myTable,
+ Uint32 cacheSize) {
+
+ Uint64 id = 0;
+ int ret = self->getAutoIncrementValue(myTable,id,cacheSize);
+ if (ret == -1) {
+ return 0;
+ }
+ return (Int64)id;
};
%ndbexception("NdbApiException") {
$action
=== modified file 'swig/NdbClusterConnection.i'
--- a/swig/NdbClusterConnection.i 2007-09-30 02:39:45 +0000
+++ b/swig/NdbClusterConnection.i 2007-10-23 23:47:41 +0000
@@ -87,10 +87,10 @@
NDB_exception(NdbApiException,"Couldn't allocate an Ndb object");
}
}
- Ndb* createNdb(const char* aCatalogName="", const char* aSchemaName="def", bool
noDelayInit = false) {
+ Ndb* createNdb(const char* aCatalogName="", const char* aSchemaName="def", int
initThreads = 0) {
Ndb * theNdb = new Ndb(self,aCatalogName,aSchemaName);
- if ((theNdb!=NULL) && noDelayInit) {
- int ret = theNdb->init();
+ if ((theNdb!=NULL) && (initThreads >0)) {
+ int ret = theNdb->init(initThreads);
if ( ret ) {
delete theNdb;
return NULL;
@@ -98,10 +98,10 @@
}
return theNdb;
}
- Ndb* createNdb(const char* aCatalogName, bool noDelayInit) {
+ Ndb* createNdb(const char* aCatalogName, int initThreads = 0) {
Ndb * theNdb = new Ndb(self,aCatalogName);
- if ((theNdb!=NULL) && noDelayInit) {
- int ret = theNdb->init();
+ if ((theNdb!=NULL) && (initThreads > 0)) {
+ int ret = theNdb->init(initThreads);
if ( ret ) {
delete theNdb;
return NULL;
| Thread |
|---|
| • Rev 194: Fixed async transactions. New form of createNdb() now, that instead of a boolean takes the parameter to send to init(). In the process, notic... | Monty Taylor | 24 Oct |