hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r787807 - in /hadoop/mapreduce/trunk: CHANGES.txt src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/MySQLManager.java
Date Tue, 23 Jun 2009 19:57:15 GMT
Author: tomwhite
Date: Tue Jun 23 19:57:14 2009
New Revision: 787807

URL: http://svn.apache.org/viewvc?rev=787807&view=rev
Log:
HADOOP-5968. Sqoop should only print a warning about mysql import speed once. Contributed
by Aaron Kimball.

Modified:
    hadoop/mapreduce/trunk/CHANGES.txt
    hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/MySQLManager.java

Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=787807&r1=787806&r2=787807&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Tue Jun 23 19:57:14 2009
@@ -12,6 +12,9 @@
     HADOOP-5967. Sqoop should only use a single map task. (Aaron Kimball via
     tomwhite)
 
+    HADOOP-5968. Sqoop should only print a warning about mysql import speed
+    once. (Aaron Kimball via tomwhite)
+
   BUG FIXES
     HADOOP-4687. MapReduce is split from Hadoop Core. It is a subproject under 
     Hadoop (Owen O'Malley)

Modified: hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/MySQLManager.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/MySQLManager.java?rev=787807&r1=787806&r2=787807&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/MySQLManager.java
(original)
+++ hadoop/mapreduce/trunk/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/manager/MySQLManager.java
Tue Jun 23 19:57:14 2009
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.sqoop.manager;
 
+import java.io.IOException;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -25,12 +26,12 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.sqoop.ImportOptions;
+import org.apache.hadoop.sqoop.util.ImportError;
 
 /**
  * Manages connections to MySQL databases
- * 
- *
  */
 public class MySQLManager extends GenericJdbcManager {
 
@@ -39,16 +40,11 @@
   // driver class to ensure is loaded when making db connection.
   private static final String DRIVER_CLASS = "com.mysql.jdbc.Driver";
 
+  // set to true after we warn the user that we can use local fastpath.
+  private static boolean warningPrinted = false;
+
   public MySQLManager(final ImportOptions opts) {
     super(DRIVER_CLASS, opts);
-
-    String connectString = opts.getConnectString();
-    if (null != connectString && connectString.indexOf("//localhost") != -1) {
-      // if we're not doing a remote connection, they should have a LocalMySQLManager.
-      LOG.warn("It looks like you are importing from mysql on localhost.");
-      LOG.warn("This transfer can be faster! Use the --local option to exercise a");
-      LOG.warn("MySQL-specific fast path.");
-    }
   }
 
   protected MySQLManager(final ImportOptions opts, boolean ignored) {
@@ -78,4 +74,29 @@
       return null;
     }
   }
+
+  @Override
+  public void importTable(String tableName, String jarFile, Configuration conf)
+        throws IOException, ImportError {
+
+    // Check that we're not doing a MapReduce from localhost. If we are, point
+    // out that we could use mysqldump.
+    if (!MySQLManager.warningPrinted) {
+      String connectString = options.getConnectString();
+
+      if (null != connectString && connectString.indexOf("//localhost") != -1) {
+        // if we're not doing a remote connection, they should have a LocalMySQLManager.
+        LOG.warn("It looks like you are importing from mysql on");
+        LOG.warn("localhost. This transfer can be faster! Use the");
+        LOG.warn("--local option to exercise a MySQL-specific fast");
+        LOG.warn("path.");
+
+        MySQLManager.warningPrinted = true; // don't display this twice.
+      }
+    }
+
+    // Then run the normal importTable() method.
+    super.importTable(tableName, jarFile, conf);
+  }
 }
+



Mime
View raw message