本文整理汇总了Java中org.apache.hadoop.mapreduce.security.TokenCache.JOB_TOKEN_HDFS_FILE属性的典型用法代码示例。如果您正苦于以下问题:Java TokenCache.JOB_TOKEN_HDFS_FILE属性的具体用法?Java TokenCache.JOB_TOKEN_HDFS_FILE怎么用?Java TokenCache.JOB_TOKEN_HDFS_FILE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.mapreduce.security.TokenCache
的用法示例。
在下文中一共展示了TokenCache.JOB_TOKEN_HDFS_FILE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: localizeJobTokenFile
/**
* Download the job-token file from the FS and save on local fs.
* @param user
* @param jobId
* @return the local file system path of the downloaded file.
* @throws IOException
*/
private String localizeJobTokenFile(String user, JobID jobId)
throws IOException {
// check if the tokenJob file is there..
Path skPath = new Path(systemDirectory,
jobId.toString()+"/"+TokenCache.JOB_TOKEN_HDFS_FILE);
FileStatus status = null;
long jobTokenSize = -1;
status = systemFS.getFileStatus(skPath); //throws FileNotFoundException
jobTokenSize = status.getLen();
Path localJobTokenFile =
lDirAlloc.getLocalPathForWrite(getPrivateDirJobTokenFile(user,
jobId.toString()), jobTokenSize, fConf);
String localJobTokenFileStr = localJobTokenFile.toUri().getPath();
if(LOG.isDebugEnabled())
LOG.debug("localizingJobTokenFile from sd="+skPath.toUri().getPath() +
" to " + localJobTokenFileStr);
// Download job_token
systemFS.copyToLocalFile(skPath, localJobTokenFile);
return localJobTokenFileStr;
}
示例2: generateAndStoreTokens
/**
* generate job token and save it into the file
* @throws IOException
*/
private void generateAndStoreTokens() throws IOException {
Path jobDir = jobtracker.getSystemDirectoryForJob(jobId);
Path keysFile = new Path(jobDir, TokenCache.JOB_TOKEN_HDFS_FILE);
if (tokenStorage == null) {
tokenStorage = new Credentials();
}
//create JobToken file and write token to it
JobTokenIdentifier identifier = new JobTokenIdentifier(new Text(jobId
.toString()));
Token<JobTokenIdentifier> token = new Token<JobTokenIdentifier>(identifier,
jobtracker.getJobTokenSecretManager());
token.setService(identifier.getJobId());
TokenCache.setJobToken(token, tokenStorage);
// write TokenStorage out
tokenStorage.writeTokenStorageFile(keysFile, jobtracker.getConf());
LOG.info("jobToken generated and stored with users keys in "
+ keysFile.toUri().getPath());
}
示例3: generateAndStoreTokens
/**
* generate job token and save it into the file
* @throws IOException
*/
private void generateAndStoreTokens() throws IOException{
Path jobDir = jobtracker.getSystemDirectoryForJob(jobId);
Path keysFile = new Path(jobDir, TokenCache.JOB_TOKEN_HDFS_FILE);
if (tokenStorage == null) {
tokenStorage = new Credentials();
}
//create JobToken file and write token to it
JobTokenIdentifier identifier = new JobTokenIdentifier(new Text(jobId
.toString()));
Token<JobTokenIdentifier> token = new Token<JobTokenIdentifier>(identifier,
jobtracker.getJobTokenSecretManager());
token.setService(identifier.getJobId());
TokenCache.setJobToken(token, tokenStorage);
// write TokenStorage out
tokenStorage.writeTokenStorageFile(keysFile, jobtracker.getConf());
LOG.info("jobToken generated and stored with users keys in "
+ keysFile.toUri().getPath());
}
示例4: localizeJobTokenFile
/**
* Download the job-token file from the FS and save on local fs.
* @param user
* @param jobId
* @param jobConf
* @return the local file system path of the downloaded file.
* @throws IOException
*/
private String localizeJobTokenFile(String user, JobID jobId)
throws IOException {
// check if the tokenJob file is there..
Path skPath = new Path(systemDirectory,
jobId.toString()+"/"+TokenCache.JOB_TOKEN_HDFS_FILE);
FileStatus status = null;
long jobTokenSize = -1;
status = systemFS.getFileStatus(skPath); //throws FileNotFoundException
jobTokenSize = status.getLen();
Path localJobTokenFile =
lDirAlloc.getLocalPathForWrite(getLocalJobTokenFile(user,
jobId.toString()), jobTokenSize, fConf);
String localJobTokenFileStr = localJobTokenFile.toUri().getPath();
LOG.debug("localizingJobTokenFile from sd="+skPath.toUri().getPath() +
" to " + localJobTokenFileStr);
// Download job_token
systemFS.copyToLocalFile(skPath, localJobTokenFile);
return localJobTokenFileStr;
}
示例5: generateAndStoreTokens
/**
* generate job token and save it into the file
* @throws IOException
*/
private void generateAndStoreTokens() throws IOException {
Path jobDir = jobtracker.getSystemDirectoryForJob(jobId);
Path keysFile = new Path(jobDir, TokenCache.JOB_TOKEN_HDFS_FILE);
if (tokenStorage == null) {
tokenStorage = new Credentials();
}
//create JobToken file and write token to it
JobTokenIdentifier identifier = new JobTokenIdentifier(new Text(jobId
.toString()));
Token<JobTokenIdentifier> token = new Token<JobTokenIdentifier>(identifier,
jobtracker.getJobTokenSecretManager());
token.setService(identifier.getJobId());
TokenCache.setJobToken(token, tokenStorage);
// write TokenStorage out
FileSystem fs = keysFile.getFileSystem(jobtracker.getConf());
FSDataOutputStream os = null;
try {
os = fs.createNonRecursive(keysFile, true,
jobtracker.getConf().getInt("io.file.buffer.size", 4096),
fs.getDefaultReplication(keysFile),
fs.getDefaultBlockSize(keysFile), null);
tokenStorage.writeTokenStorageToStream(os);
} finally {
IOUtils.closeStream(os);
}
LOG.info("jobToken generated and stored with users keys in "
+ keysFile.toUri().getPath());
}