本文整理汇总了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();
}