Java Code Examples for org.apache.hadoop.mapreduce.security.token.JobTokenSecretManager#createSecretKey()

The following examples show how to use org.apache.hadoop.mapreduce.security.token.JobTokenSecretManager#createSecretKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFetcher.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings("unchecked") // mocked generics
public void setup() {
  LOG.info(">>>> " + name.getMethodName());
  job = new JobConf();
  job.setBoolean(MRJobConfig.SHUFFLE_FETCH_RETRY_ENABLED, false);
  jobWithRetry = new JobConf();
  jobWithRetry.setBoolean(MRJobConfig.SHUFFLE_FETCH_RETRY_ENABLED, true);
  id = TaskAttemptID.forName("attempt_0_1_r_1_1");
  ss = mock(ShuffleSchedulerImpl.class);
  mm = mock(MergeManagerImpl.class);
  r = mock(Reporter.class);
  metrics = mock(ShuffleClientMetrics.class);
  except = mock(ExceptionReporter.class);
  key = JobTokenSecretManager.createSecretKey(new byte[]{0,0,0,0});
  connection = mock(HttpURLConnection.class);

  allErrs = mock(Counters.Counter.class);
  when(r.getCounter(anyString(), anyString())).thenReturn(allErrs);

  ArrayList<TaskAttemptID> maps = new ArrayList<TaskAttemptID>(1);
  maps.add(map1ID);
  maps.add(map2ID);
  when(ss.getMapsForHost(host)).thenReturn(maps);
}
 
Example 2
Source File: TestFetcher.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings("unchecked") // mocked generics
public void setup() {
  LOG.info(">>>> " + name.getMethodName());
  job = new JobConf();
  job.setBoolean(MRJobConfig.SHUFFLE_FETCH_RETRY_ENABLED, false);
  jobWithRetry = new JobConf();
  jobWithRetry.setBoolean(MRJobConfig.SHUFFLE_FETCH_RETRY_ENABLED, true);
  id = TaskAttemptID.forName("attempt_0_1_r_1_1");
  ss = mock(ShuffleSchedulerImpl.class);
  mm = mock(MergeManagerImpl.class);
  r = mock(Reporter.class);
  metrics = mock(ShuffleClientMetrics.class);
  except = mock(ExceptionReporter.class);
  key = JobTokenSecretManager.createSecretKey(new byte[]{0,0,0,0});
  connection = mock(HttpURLConnection.class);

  allErrs = mock(Counters.Counter.class);
  when(r.getCounter(anyString(), anyString())).thenReturn(allErrs);

  ArrayList<TaskAttemptID> maps = new ArrayList<TaskAttemptID>(1);
  maps.add(map1ID);
  maps.add(map2ID);
  when(ss.getMapsForHost(host)).thenReturn(maps);
}
 
Example 3
Source File: MRTask.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
private void configureMRTask()
    throws IOException, InterruptedException {

  Credentials credentials = UserGroupInformation.getCurrentUser()
      .getCredentials();
  jobConf.setCredentials(credentials);
  // TODO Can this be avoided all together. Have the MRTezOutputCommitter use
  // the Tez parameter.
  // TODO This could be fetched from the env if YARN is setting it for all
  // Containers.
  // Set it in conf, so as to be able to be used the the OutputCommitter.

  // Not needed. This is probably being set via the source/consumer meta
  Token<JobTokenIdentifier> jobToken = TokenCache.getSessionToken(credentials);
  if (jobToken != null) {
    // Will MR ever run without a job token.
    SecretKey sk = JobTokenSecretManager.createSecretKey(jobToken
        .getPassword());
    this.jobTokenSecret = sk;
  } else {
    LOG.warn("No job token set");
  }

  configureLocalDirs();

  // Set up the DistributedCache related configs
  setupDistributedCacheConfig(jobConf);
}
 
Example 4
Source File: MRTask.java    From tez with Apache License 2.0 5 votes vote down vote up
private void configureMRTask()
    throws IOException, InterruptedException {

  Credentials credentials = UserGroupInformation.getCurrentUser()
      .getCredentials();
  jobConf.setCredentials(credentials);
  // TODO Can this be avoided all together. Have the MRTezOutputCommitter use
  // the Tez parameter.
  // TODO This could be fetched from the env if YARN is setting it for all
  // Containers.
  // Set it in conf, so as to be able to be used the the OutputCommitter.

  // Not needed. This is probably being set via the source/consumer meta
  Token<JobTokenIdentifier> jobToken = TokenCache.getSessionToken(credentials);
  if (jobToken != null) {
    // Will MR ever run without a job token.
    SecretKey sk = JobTokenSecretManager.createSecretKey(jobToken
        .getPassword());
    this.jobTokenSecret = sk;
  } else {
    LOG.warn("No job token set");
  }

  configureLocalDirs();

  // Set up the DistributedCache related configs
  setupDistributedCacheConfig(jobConf);
}
 
Example 5
Source File: Application.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static String createDigest(byte[] password, String data)
    throws IOException {
  SecretKey key = JobTokenSecretManager.createSecretKey(password);
  return SecureShuffleUtils.hashFromString(data, key);
}
 
Example 6
Source File: Application.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static String createDigest(byte[] password, String data)
    throws IOException {
  SecretKey key = JobTokenSecretManager.createSecretKey(password);
  return SecureShuffleUtils.hashFromString(data, key);
}
 
Example 7
Source File: CommonStub.java    From hadoop with Apache License 2.0 2 votes vote down vote up
protected String createDigest(byte[] password, String data) throws IOException {
  SecretKey key = JobTokenSecretManager.createSecretKey(password);

  return SecureShuffleUtils.hashFromString(data, key);

}
 
Example 8
Source File: CommonStub.java    From big-c with Apache License 2.0 2 votes vote down vote up
protected String createDigest(byte[] password, String data) throws IOException {
  SecretKey key = JobTokenSecretManager.createSecretKey(password);

  return SecureShuffleUtils.hashFromString(data, key);

}