本文整理匯總了Java中com.cloudera.sqoop.config.ConfigurationConstants類的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationConstants類的具體用法?Java ConfigurationConstants怎麽用?Java ConfigurationConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConfigurationConstants類屬於com.cloudera.sqoop.config包,在下文中一共展示了ConfigurationConstants類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writePasswordFile
import com.cloudera.sqoop.config.ConfigurationConstants; //導入依賴的package包/類
/**
* Writes the user's password to a tmp file with 0600 permissions.
* @return the filename used.
*/
public static String writePasswordFile(Configuration conf)
throws IOException {
// Create the temp file to hold the user's password.
String tmpDir = conf.get(
ConfigurationConstants.PROP_JOB_LOCAL_DIRECTORY, "/tmp/");
File tempFile = File.createTempFile("mysql-cnf", ".cnf", new File(tmpDir));
// Make the password file only private readable.
DirectImportUtils.setFilePermissions(tempFile, "0600");
// If we're here, the password file is believed to be ours alone. The
// inability to set chmod 0600 inside Java is troublesome. We have to
// trust that the external 'chmod' program in the path does the right
// 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 = DBConfiguration.getPassword((JobConf) conf);
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(tempFile)));
w.write("[client]\n");
w.write("password=" + password + "\n");
w.close();
return tempFile.toString();
}
示例2: getLocalWorkPath
import com.cloudera.sqoop.config.ConfigurationConstants; //導入依賴的package包/類
/**
* Return the local filesystem dir where the current task attempt can
* perform work.
* @return a File describing a directory where local temp data for the
* task attempt can be stored.
*/
public static File getLocalWorkPath(Configuration conf) throws IOException {
String tmpDir = conf.get(
ConfigurationConstants.PROP_JOB_LOCAL_DIRECTORY,
"/tmp/");
// Create a local subdir specific to this task attempt.
String taskAttemptStr = TaskId.get(conf, "task_attempt");
File taskAttemptDir = new File(tmpDir, taskAttemptStr);
if (!taskAttemptDir.exists()) {
boolean createdDir = taskAttemptDir.mkdirs();
if (!createdDir) {
throw new IOException("Could not create missing task attempt dir: "
+ taskAttemptDir.toString());
}
}
return taskAttemptDir;
}
示例3: writePasswordFile
import com.cloudera.sqoop.config.ConfigurationConstants; //導入依賴的package包/類
/**
* Writes the user's password to a tmp file with 0600 permissions.
* @return the filename used.
*/
public static String writePasswordFile(Configuration conf)
throws IOException {
// Create the temp file to hold the user's password.
String tmpDir = conf.get(
ConfigurationConstants.PROP_JOB_LOCAL_DIRECTORY, "/tmp/");
File tempFile = File.createTempFile("mysql-cnf", ".cnf", new File(tmpDir));
// Make the password file only private readable.
DirectImportUtils.setFilePermissions(tempFile, "0600");
// If we're here, the password file is believed to be ours alone. The
// inability to set chmod 0600 inside Java is troublesome. We have to
// trust that the external 'chmod' program in the path does the right
// 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);
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(tempFile)));
w.write("[client]\n");
w.write("password=" + password + "\n");
w.close();
return tempFile.toString();
}