Updated Branches: refs/heads/trunk ef093399b -> 00d09b7b2
SQOOP-979: MySQL direct connector is not working correct after moving password to credential cache (Jarek Jarcec Cecho via Kate Ting) Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/00d09b7b Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/00d09b7b Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/00d09b7b Branch: refs/heads/trunk Commit: 00d09b7b252ff889069883960e007513422c24d4 Parents: ef09339 Author: Kate Ting <[email protected]> Authored: Sat Apr 6 17:29:02 2013 -0400 Committer: Kate Ting <[email protected]> Committed: Sat Apr 6 17:29:02 2013 -0400 ---------------------------------------------------------------------- .../com/cloudera/sqoop/manager/MySQLUtils.java | 2 -- src/java/org/apache/sqoop/manager/MySQLUtils.java | 6 +++--- .../apache/sqoop/mapreduce/MySQLDumpMapper.java | 4 +++- .../apache/sqoop/mapreduce/MySQLExportMapper.java | 3 ++- .../apache/sqoop/mapreduce/db/DBConfiguration.java | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/00d09b7b/src/java/com/cloudera/sqoop/manager/MySQLUtils.java ---------------------------------------------------------------------- diff --git a/src/java/com/cloudera/sqoop/manager/MySQLUtils.java b/src/java/com/cloudera/sqoop/manager/MySQLUtils.java index 6611f8e..3410324 100644 --- a/src/java/com/cloudera/sqoop/manager/MySQLUtils.java +++ b/src/java/com/cloudera/sqoop/manager/MySQLUtils.java @@ -49,8 +49,6 @@ public final class MySQLUtils { org.apache.sqoop.manager.MySQLUtils.CONNECT_STRING_KEY; public static final String USERNAME_KEY = org.apache.sqoop.manager.MySQLUtils.USERNAME_KEY; - public static final String PASSWORD_KEY = - org.apache.sqoop.manager.MySQLUtils.PASSWORD_KEY; public static final String WHERE_CLAUSE_KEY = org.apache.sqoop.manager.MySQLUtils.WHERE_CLAUSE_KEY; public static final String EXTRA_ARGS_KEY = http://git-wip-us.apache.org/repos/asf/sqoop/blob/00d09b7b/src/java/org/apache/sqoop/manager/MySQLUtils.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/sqoop/manager/MySQLUtils.java b/src/java/org/apache/sqoop/manager/MySQLUtils.java index c86cf1a..ee22f17 100644 --- a/src/java/org/apache/sqoop/manager/MySQLUtils.java +++ b/src/java/org/apache/sqoop/manager/MySQLUtils.java @@ -29,11 +29,13 @@ import java.io.OutputStreamWriter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.mapred.JobConf; import com.cloudera.sqoop.config.ConfigurationConstants; import com.cloudera.sqoop.config.ConfigurationHelper; import com.cloudera.sqoop.util.DirectImportUtils; import org.apache.sqoop.lib.DelimiterSet; +import org.apache.sqoop.mapreduce.db.DBConfiguration; /** * Helper methods and constants for MySQL imports/exports. @@ -65,8 +67,6 @@ public final class MySQLUtils { ConfigurationHelper.getDbUrlProperty(); public static final String USERNAME_KEY = ConfigurationHelper.getDbUsernameProperty(); - public static final String PASSWORD_KEY = - ConfigurationHelper.getDbPasswordProperty(); public static final String WHERE_CLAUSE_KEY = ConfigurationHelper.getDbInputConditionsProperty(); @@ -110,7 +110,7 @@ public final class MySQLUtils { // thing, and returns the correct exit status. But given our inability to // re-read the permissions associated with a file, we'll have to make do // with this. - String password = conf.get(PASSWORD_KEY); + String password = DBConfiguration.getPassword((JobConf) conf); BufferedWriter w = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(tempFile))); w.write("[client]\n"); http://git-wip-us.apache.org/repos/asf/sqoop/blob/00d09b7b/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java b/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java index 4daaaeb..aeeb137 100644 --- a/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java +++ b/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java @@ -30,9 +30,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.NullWritable; +import org.apache.hadoop.mapred.JobConf; import org.apache.sqoop.util.AsyncSink; import org.apache.sqoop.util.JdbcUrl; import org.apache.sqoop.util.PerfCounters; +import org.apache.sqoop.mapreduce.db.DBConfiguration; import com.cloudera.sqoop.lib.DelimiterSet; import com.cloudera.sqoop.lib.FieldFormatter; import com.cloudera.sqoop.lib.RecordParser; @@ -345,7 +347,7 @@ public class MySQLDumpMapper args.add(MySQLUtils.MYSQL_DUMP_CMD); // requires that this is on the path. - String password = conf.get(MySQLUtils.PASSWORD_KEY); + String password = DBConfiguration.getPassword((JobConf) conf); String passwordFile = null; Process p = null; http://git-wip-us.apache.org/repos/asf/sqoop/blob/00d09b7b/src/java/org/apache/sqoop/mapreduce/MySQLExportMapper.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/sqoop/mapreduce/MySQLExportMapper.java b/src/java/org/apache/sqoop/mapreduce/MySQLExportMapper.java index dc1c126..5a695ca 100644 --- a/src/java/org/apache/sqoop/mapreduce/MySQLExportMapper.java +++ b/src/java/org/apache/sqoop/mapreduce/MySQLExportMapper.java @@ -28,6 +28,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.NullWritable; +import org.apache.hadoop.mapred.JobConf; import org.apache.sqoop.util.AsyncSink; import org.apache.sqoop.util.JdbcUrl; import org.apache.sqoop.util.LoggingAsyncSink; @@ -138,7 +139,7 @@ public class MySQLExportMapper<KEYIN, VALIN> } args.add(MySQLUtils.MYSQL_IMPORT_CMD); // needs to be on the path. - String password = conf.get(MySQLUtils.PASSWORD_KEY); + String password = DBConfiguration.getPassword((JobConf) conf); if (null != password && password.length() > 0) { passwordFile = new File(MySQLUtils.writePasswordFile(conf)); http://git-wip-us.apache.org/repos/asf/sqoop/blob/00d09b7b/src/java/org/apache/sqoop/mapreduce/db/DBConfiguration.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/sqoop/mapreduce/db/DBConfiguration.java b/src/java/org/apache/sqoop/mapreduce/db/DBConfiguration.java index 4bd066d..be942ce 100644 --- a/src/java/org/apache/sqoop/mapreduce/db/DBConfiguration.java +++ b/src/java/org/apache/sqoop/mapreduce/db/DBConfiguration.java @@ -299,7 +299,7 @@ public class DBConfiguration { } // retrieve the password from the credentials object - private static String getPassword(JobConf configuration) { + public static String getPassword(JobConf configuration) { LOG.debug("Fetching password from job credentials store"); byte[] secret = configuration.getCredentials().getSecretKey( PASSWORD_SECRET_KEY);
