mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 15:32:52 +08:00
SQOOP-979: MySQL direct connector is not working correct after moving password to credential cache
(Jarek Jarcec Cecho via Kate Ting)
This commit is contained in:
parent
ef093399bf
commit
00d09b7b25
@ -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 =
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user