hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r812092 - in /hadoop/mapreduce/trunk: CHANGES.txt src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/DefaultManagerFactory.java src/contrib/sqoop/src/test/org/apache/hadoop/sqoop/testutil/HsqldbTestServer.java
Date Mon, 07 Sep 2009 11:36:31 GMT
Author: tomwhite
Date: Mon Sep  7 11:36:30 2009
New Revision: 812092

URL: http://svn.apache.org/viewvc?rev=812092&view=rev
Log:
MAPREDUCE-918. Test hsqldb server should be memory-only. Contributed by Aaron Kimball.

Modified:
    hadoop/mapreduce/trunk/CHANGES.txt
    hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/DefaultManagerFactory.java
    hadoop/mapreduce/trunk/src/contrib/sqoop/src/test/org/apache/hadoop/sqoop/testutil/HsqldbTestServer.java

Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=812092&r1=812091&r2=812092&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Mon Sep  7 11:36:30 2009
@@ -295,6 +295,9 @@
     MAPREDUCE-876. Sqoop import of large tables can time out.
     (Aaron Kimball via tomwhite)
 
+    MAPREDUCE-918. Test hsqldb server should be memory-only.
+    (Aaron Kimball via tomwhite)
+
   BUG FIXES
 
     MAPREDUCE-878. Rename fair scheduler design doc to 

Modified: hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/DefaultManagerFactory.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/DefaultManagerFactory.java?rev=812092&r1=812091&r2=812092&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/DefaultManagerFactory.java
(original)
+++ hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/DefaultManagerFactory.java
Mon Sep  7 11:36:30 2009
@@ -41,12 +41,27 @@
 
     String connectStr = options.getConnectString();
 
+    // java.net.URL follows RFC-2396 literally, which does not allow a ':'
+    // character in the scheme component (section 3.1). JDBC connect strings,
+    // however, commonly have a multi-scheme addressing system. e.g.,
+    // jdbc:mysql://...; so we cannot parse the scheme component via URL
+    // objects. Instead, attempt to pull out the scheme as best as we can.
+
+    // First, see if this is of the form [scheme://hostname-and-etc..]
     int schemeStopIdx = connectStr.indexOf("//");
     if (-1 == schemeStopIdx) {
-      // no scheme component?
-      LOG.warn("Could not parse connect string: [" + connectStr
-          + "]; this may be malformed.");
-      return null;
+      // If no hostname start marker ("//"), then look for the right-most ':'
+      // character.
+      schemeStopIdx = connectStr.lastIndexOf(':');
+      if (-1 == schemeStopIdx) {
+        // Warn that this is nonstandard. But we should be as permissive
+        // as possible here and let the ConnectionManagers themselves throw
+        // out the connect string if it doesn't make sense to them.
+        LOG.warn("Could not determine scheme component of connect string");
+
+        // Use the whole string.
+        schemeStopIdx = connectStr.length();
+      }
     }
 
     String scheme = connectStr.substring(0, schemeStopIdx);
@@ -58,6 +73,8 @@
       return null;
     }
 
+    LOG.debug("Trying with scheme: " + scheme);
+
     if (scheme.equals("jdbc:mysql:")) {
       if (options.isDirect()) {
         return new LocalMySQLManager(options);

Modified: hadoop/mapreduce/trunk/src/contrib/sqoop/src/test/org/apache/hadoop/sqoop/testutil/HsqldbTestServer.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/contrib/sqoop/src/test/org/apache/hadoop/sqoop/testutil/HsqldbTestServer.java?rev=812092&r1=812091&r2=812092&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/contrib/sqoop/src/test/org/apache/hadoop/sqoop/testutil/HsqldbTestServer.java
(original)
+++ hadoop/mapreduce/trunk/src/contrib/sqoop/src/test/org/apache/hadoop/sqoop/testutil/HsqldbTestServer.java
Mon Sep  7 11:36:30 2009
@@ -45,9 +45,6 @@
   // singleton server instance.
   private static Server server;
 
-  // When we create databases in HSqlDb, where do we put the files?
-  private static final String DATABASE_DATA_DIR = "./hsqldb-data";
-
   private static final String DATABASE_NAME = "db1";
 
   // hsqldb always capitalizes table and column names
@@ -56,7 +53,7 @@
 
   private static final String EMPLOYEE_TABLE_NAME = "EMPLOYEES";
 
-  private static final String DB_URL = "jdbc:hsqldb:hsql://localhost/" + DATABASE_NAME;
+  private static final String DB_URL = "jdbc:hsqldb:mem:" + DATABASE_NAME;
   private static final String DRIVER_CLASS = "org.hsqldb.jdbcDriver";
 
   // all user-created HSQLDB tables are in the "PUBLIC" schema when connected to a database.
@@ -87,11 +84,10 @@
    */
   public void start() {
     if (null == server) {
-      LOG.info("Starting new hsqldb server; database=" + DATABASE_NAME + "; dir="
-          + DATABASE_DATA_DIR);
+      LOG.info("Starting new hsqldb server; database=" + DATABASE_NAME);
       server = new Server();
-      server.setDatabasePath(0, DATABASE_DATA_DIR);
-      server.setDatabaseName(0, DATABASE_NAME);
+      server.putPropertiesFromString("database.0=mem:" + DATABASE_NAME
+          + ";no_system_exit=true");
       server.start();
     }
   }



Mime
View raw message