List:Commits« Previous MessageNext Message »
From:Craig L Russell Date:December 18 2011 11:49am
Subject:bzr push into mysql-5.1-telco-7.1 branch (Craig.Russell:4388 to 4389)
View as plain text  
 4389 Craig L Russell	2011-12-18
      Improve clusterj error handling for loading system library.

    modified:
      storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java
      storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionServiceImpl.java
      storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/DbugImpl.java
 4388 Craig L Russell	2011-12-17
      Fix clusterj DBUG. 
        Test for ndbclient compiled without DBUG support
        Allocate a file /tmp/clusterj-test-dbug
        Verify that keywords are stored/retrieved LIFO

    renamed:
      storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/DbugTest.java.not_yet => storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/DbugTest.java
    modified:
      storage/ndb/clusterj/clusterj-test/Makefile.am
      storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/DbugImpl.java
      storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/DbugTest.java
=== modified file 'storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java	2011-03-08 00:44:56 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java	2011-12-18 11:47:59 +0000
@@ -45,13 +45,6 @@ public class ClusterConnectionImpl
     static final Logger logger = LoggerFactoryService.getFactory()
             .getInstance(com.mysql.clusterj.core.store.ClusterConnection.class);
 
-    /** Load the ndbjtie system library */
-    static {
-        loadSystemLibrary("ndbclient");
-        // initialize the charset map
-        Utility.getCharsetMap();
-    }
-
     /** Ndb_cluster_connection is wrapped by ClusterConnection */
     protected Ndb_cluster_connection clusterConnection;
 
@@ -77,40 +70,6 @@ public class ClusterConnectionImpl
         logger.info(local.message("INFO_Create_Cluster_Connection", connectString, nodeId));
     }
 
-    static protected void loadSystemLibrary(String name) {
-        String message;
-        String path;
-        try {
-            System.loadLibrary(name);
-        } catch (UnsatisfiedLinkError e) {
-            path = getLoadLibraryPath();
-            message = local.message("ERR_Failed_Loading_Library",
-                    name, path, "UnsatisfiedLinkError", e.getLocalizedMessage());
-            logger.fatal(message);
-            throw e;
-        } catch (SecurityException e) {
-            path = getLoadLibraryPath();
-            message = local.message("ERR_Failed_Loading_Library",
-                    name, path, "SecurityException", e.getLocalizedMessage());
-            logger.fatal(message);
-            throw e;
-        }
-    }
-
-    /**
-     * @return the load library path or the Exception string
-     */
-    private static String getLoadLibraryPath() {
-        String path;
-        try {
-            path = System.getProperty("java.library.path");
-        } catch (Exception ex) {
-            path = "<Exception: " + ex.getMessage() + ">";
-        }
-        return path;
-    }
-
-
     public void connect(int connectRetries, int connectDelay, boolean verbose) {
         checkConnection();
         int returnCode = clusterConnection.connect(connectRetries, connectDelay, verbose?1:0);

=== modified file 'storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionServiceImpl.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionServiceImpl.java	2011-03-08 00:44:56 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionServiceImpl.java	2011-12-18 11:47:59 +0000
@@ -40,7 +40,30 @@ public class ClusterConnectionServiceImp
         LoggerFactoryService.getFactory().registerLogger("com.mysql.clusterj.tie");
     }
 
+    /** Load the ndbclient system library only once */
+    static boolean ndbclientLoaded = false;
+
+    static protected void loadSystemLibrary(String name) {
+        // this is not thread-protected so it might be executed multiple times but no matter
+        if (ndbclientLoaded) {
+            return;
+        }
+        try {
+            System.loadLibrary(name);
+            // initialize the charset map
+            Utility.getCharsetMap();
+            ndbclientLoaded = true;
+        } catch (Throwable e) {
+            String path = getLoadLibraryPath();
+            String message = local.message("ERR_Failed_Loading_Library",
+                    name, path, e.getClass(), e.getLocalizedMessage());
+            logger.fatal(message);
+            throw new ClusterJFatalUserException(message, e);
+        }
+    }
+
     public ClusterConnection create(String connectString, int nodeId) {
+        loadSystemLibrary("ndbclient");
         try {
             return new ClusterConnectionImpl(connectString, nodeId);
         } catch (ClusterJFatalUserException cjex) {
@@ -52,4 +75,17 @@ public class ClusterConnectionServiceImp
         }
     }
 
+    /**
+     * @return the load library path or the Exception string
+     */
+    private static String getLoadLibraryPath() {
+        String path;
+        try {
+            path = System.getProperty("java.library.path");
+        } catch (Exception ex) {
+            path = "<Exception: " + ex.getMessage() + ">";
+        }
+        return path;
+    }
+
 }

=== modified file 'storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/DbugImpl.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/DbugImpl.java	2011-12-18 07:56:51 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/DbugImpl.java	2011-12-18 11:47:59 +0000
@@ -42,15 +42,16 @@ public class DbugImpl implements Dbug {
 
     private static final int DBUG_SIZE = 256;
 
-    /* Load the native library so we can set up debugging before anything else */
-    static {
-        ClusterConnectionImpl.loadSystemLibrary("ndbclient");
-    }
     boolean propertyTrace = false;
     String fileName = "";
     Character fileStrategy = 'o';
     String debugList;
     
+    public DbugImpl() {
+        // Load the native library so we can set up debugging before anything else
+        ClusterConnectionServiceImpl.loadSystemLibrary("ndbclient");
+    }
+
     public String get() {
         ByteBuffer buffer = ByteBuffer.allocateDirect(DBUG_SIZE);
         String result = Utils.dbugExplain(buffer, DBUG_SIZE);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.1 branch (Craig.Russell:4388 to 4389) Craig L Russell19 Dec