当前位置: 首页>>代码示例>>Java>>正文


Java TokenCache.setEncryptedSpillKey方法代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.security.TokenCache.setEncryptedSpillKey方法的典型用法代码示例。如果您正苦于以下问题:Java TokenCache.setEncryptedSpillKey方法的具体用法?Java TokenCache.setEncryptedSpillKey怎么用?Java TokenCache.setEncryptedSpillKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.mapreduce.security.TokenCache的用法示例。


在下文中一共展示了TokenCache.setEncryptedSpillKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setEncryptedSpillKeyIfRequired

import org.apache.hadoop.mapreduce.security.TokenCache; //导入方法依赖的package包/类
/**
 * Utility method to check if the Encrypted Spill Key needs to be set into the
 * user credentials of the user running the Map / Reduce Task
 * @param task The Map / Reduce task to set the Encrypted Spill information in
 * @throws Exception
 */
public static void setEncryptedSpillKeyIfRequired(Task task) throws
        Exception {
  if ((task != null) && (task.getEncryptedSpillKey() != null) && (task
          .getEncryptedSpillKey().length > 1)) {
    Credentials creds =
            UserGroupInformation.getCurrentUser().getCredentials();
    TokenCache.setEncryptedSpillKey(task.getEncryptedSpillKey(), creds);
    UserGroupInformation.getCurrentUser().addCredentials(creds);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:YarnChild.java

示例2: testEncryptedMerger

import org.apache.hadoop.mapreduce.security.TokenCache; //导入方法依赖的package包/类
@Test
public void testEncryptedMerger() throws Throwable {
  jobConf.setBoolean(MRJobConfig.MR_ENCRYPTED_INTERMEDIATE_DATA, true);
  conf.setBoolean(MRJobConfig.MR_ENCRYPTED_INTERMEDIATE_DATA, true);
  Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
  TokenCache.setEncryptedSpillKey(new byte[16], credentials);
  UserGroupInformation.getCurrentUser().addCredentials(credentials);
  testInMemoryAndOnDiskMerger();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestMerger.java

示例3: Job

import org.apache.hadoop.mapreduce.security.TokenCache; //导入方法依赖的package包/类
public Job(JobID jobid, String jobSubmitDir) throws IOException {
  this.systemJobDir = new Path(jobSubmitDir);
  this.systemJobFile = new Path(systemJobDir, "job.xml");
  this.id = jobid;
  JobConf conf = new JobConf(systemJobFile);
  this.localFs = FileSystem.getLocal(conf);
  String user = UserGroupInformation.getCurrentUser().getShortUserName();
  this.localJobDir = localFs.makeQualified(new Path(
      new Path(conf.getLocalPath(jobDir), user), jobid.toString()));
  this.localJobFile = new Path(this.localJobDir, id + ".xml");

  // Manage the distributed cache.  If there are files to be copied,
  // this will trigger localFile to be re-written again.
  localDistributedCacheManager = new LocalDistributedCacheManager();
  localDistributedCacheManager.setup(conf);
  
  // Write out configuration file.  Instead of copying it from
  // systemJobFile, we re-write it, since setup(), above, may have
  // updated it.
  OutputStream out = localFs.create(localJobFile);
  try {
    conf.writeXml(out);
  } finally {
    out.close();
  }
  this.job = new JobConf(localJobFile);

  // Job (the current object) is a Thread, so we wrap its class loader.
  if (localDistributedCacheManager.hasLocalClasspaths()) {
    setContextClassLoader(localDistributedCacheManager.makeClassLoader(
            getContextClassLoader()));
  }
  
  profile = new JobProfile(job.getUser(), id, systemJobFile.toString(), 
                           "http://localhost:8080/", job.getJobName());
  status = new JobStatus(id, 0.0f, 0.0f, JobStatus.RUNNING, 
      profile.getUser(), profile.getJobName(), profile.getJobFile(), 
      profile.getURL().toString());

  jobs.put(id, this);

  if (CryptoUtils.isEncryptedSpillEnabled(job)) {
    try {
      int keyLen = conf.getInt(
          MRJobConfig.MR_ENCRYPTED_INTERMEDIATE_DATA_KEY_SIZE_BITS,
          MRJobConfig
              .DEFAULT_MR_ENCRYPTED_INTERMEDIATE_DATA_KEY_SIZE_BITS);
      KeyGenerator keyGen =
          KeyGenerator.getInstance(INTERMEDIATE_DATA_ENCRYPTION_ALGO);
      keyGen.init(keyLen);
      Credentials creds =
          UserGroupInformation.getCurrentUser().getCredentials();
      TokenCache.setEncryptedSpillKey(keyGen.generateKey().getEncoded(),
          creds);
      UserGroupInformation.getCurrentUser().addCredentials(creds);
    } catch (NoSuchAlgorithmException e) {
      throw new IOException("Error generating encrypted spill key", e);
    }
  }

  this.start();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:63,代码来源:LocalJobRunner.java


注:本文中的org.apache.hadoop.mapreduce.security.TokenCache.setEncryptedSpillKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。