diff --git a/src/java/com/cloudera/sqoop/manager/MySQLUtils.java b/src/java/com/cloudera/sqoop/manager/MySQLUtils.java index 6611f8ea..34103246 100644 --- a/src/java/com/cloudera/sqoop/manager/MySQLUtils.java +++ b/src/java/com/cloudera/sqoop/manager/MySQLUtils.java @@ -49,8 +49,6 @@ private 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 = diff --git a/src/java/org/apache/sqoop/manager/MySQLUtils.java b/src/java/org/apache/sqoop/manager/MySQLUtils.java index c86cf1a6..ee22f17f 100644 --- a/src/java/org/apache/sqoop/manager/MySQLUtils.java +++ b/src/java/org/apache/sqoop/manager/MySQLUtils.java @@ -29,11 +29,13 @@ 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 @@ private 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 static String writePasswordFile(Configuration conf) // 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"); diff --git a/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java b/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java index 4daaaeb5..aeeb1374 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.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 void map(String splitConditions, NullWritable val, Context context) 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; diff --git a/src/java/org/apache/sqoop/mapreduce/MySQLExportMapper.java b/src/java/org/apache/sqoop/mapreduce/MySQLExportMapper.java index dc1c1263..5a695ca8 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.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 @@ private void initMySQLImportProcess() throws IOException { } 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)); diff --git a/src/java/org/apache/sqoop/mapreduce/db/DBConfiguration.java b/src/java/org/apache/sqoop/mapreduce/db/DBConfiguration.java index 4bd066db..be942cee 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 Connection getConnection() } // 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);