org.apache.hadoop.mapred.Master Java Examples

The following examples show how to use org.apache.hadoop.mapred.Master. 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: TokenCache.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * get delegation token for a specific FS
 * @param fs
 * @param credentials
 * @param p
 * @param conf
 * @throws IOException
 */
static void obtainTokensForNamenodesInternal(FileSystem fs, 
    Credentials credentials, Configuration conf) throws IOException {
  String delegTokenRenewer = Master.getMasterPrincipal(conf);
  if (delegTokenRenewer == null || delegTokenRenewer.length() == 0) {
    throw new IOException(
        "Can't get Master Kerberos principal for use as renewer");
  }
  mergeBinaryTokens(credentials, conf);

  final Token<?> tokens[] = fs.addDelegationTokens(delegTokenRenewer,
                                                   credentials);
  if (tokens != null) {
    for (Token<?> token : tokens) {
      LOG.info("Got dt for " + fs.getUri() + "; "+token);
    }
  }
}
 
Example #2
Source File: TestTokenCache.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testSingleTokenFetch() throws Exception {
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/host@REALM");
  String renewer = Master.getMasterPrincipal(conf);
  Credentials credentials = new Credentials();
  
  final MockFileSystem fs = new MockFileSystem();
  final MockFileSystem mockFs = (MockFileSystem) fs.getRawFileSystem();
  when(mockFs.getCanonicalServiceName()).thenReturn("host:0");
  when(mockFs.getUri()).thenReturn(new URI("mockfs://host:0"));
  
  Path mockPath = mock(Path.class);
  when(mockPath.getFileSystem(conf)).thenReturn(mockFs);
  
  Path[] paths = new Path[]{ mockPath, mockPath };
  when(mockFs.addDelegationTokens("me", credentials)).thenReturn(null);
  TokenCache.obtainTokensForNamenodesInternal(credentials, paths, conf);
  verify(mockFs, times(1)).addDelegationTokens(renewer, credentials);
}
 
Example #3
Source File: TokenCache.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * get delegation token for a specific FS
 * @param fs
 * @param credentials
 * @param p
 * @param conf
 * @throws IOException
 */
static void obtainTokensForNamenodesInternal(FileSystem fs, 
    Credentials credentials, Configuration conf) throws IOException {
  String delegTokenRenewer = Master.getMasterPrincipal(conf);
  if (delegTokenRenewer == null || delegTokenRenewer.length() == 0) {
    throw new IOException(
        "Can't get Master Kerberos principal for use as renewer");
  }
  mergeBinaryTokens(credentials, conf);

  final Token<?> tokens[] = fs.addDelegationTokens(delegTokenRenewer,
                                                   credentials);
  if (tokens != null) {
    for (Token<?> token : tokens) {
      LOG.info("Got dt for " + fs.getUri() + "; "+token);
    }
  }
}
 
Example #4
Source File: TestTokenCache.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testSingleTokenFetch() throws Exception {
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/host@REALM");
  String renewer = Master.getMasterPrincipal(conf);
  Credentials credentials = new Credentials();
  
  final MockFileSystem fs = new MockFileSystem();
  final MockFileSystem mockFs = (MockFileSystem) fs.getRawFileSystem();
  when(mockFs.getCanonicalServiceName()).thenReturn("host:0");
  when(mockFs.getUri()).thenReturn(new URI("mockfs://host:0"));
  
  Path mockPath = mock(Path.class);
  when(mockPath.getFileSystem(conf)).thenReturn(mockFs);
  
  Path[] paths = new Path[]{ mockPath, mockPath };
  when(mockFs.addDelegationTokens("me", credentials)).thenReturn(null);
  TokenCache.obtainTokensForNamenodesInternal(credentials, paths, conf);
  verify(mockFs, times(1)).addDelegationTokens(renewer, credentials);
}
 
Example #5
Source File: TokenUtils.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private static Token<?> getDelegationTokenFromHS(HSClientProtocol hsProxy, Configuration conf) throws IOException {
  GetDelegationTokenRequest request =
      RecordFactoryProvider.getRecordFactory(null).newRecordInstance(GetDelegationTokenRequest.class);
  request.setRenewer(Master.getMasterPrincipal(conf));
  org.apache.hadoop.yarn.api.records.Token mrDelegationToken;
  mrDelegationToken = hsProxy.getDelegationToken(request).getDelegationToken();
  return ConverterUtils.convertFromYarn(mrDelegationToken, hsProxy.getConnectAddress());
}
 
Example #6
Source File: HadoopSecurityManager_H_2_0.java    From azkaban-plugins with Apache License 2.0 5 votes vote down vote up
private Token<?> getDelegationTokenFromHS(HSClientProtocol hsProxy)
    throws IOException, InterruptedException {
  GetDelegationTokenRequest request =
      recordFactory.newRecordInstance(GetDelegationTokenRequest.class);
  request.setRenewer(Master.getMasterPrincipal(conf));
  org.apache.hadoop.yarn.api.records.Token mrDelegationToken;
  mrDelegationToken =
      hsProxy.getDelegationToken(request).getDelegationToken();
  return ConverterUtils.convertFromYarn(mrDelegationToken,
      hsProxy.getConnectAddress());
}
 
Example #7
Source File: TestTokenCache.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
  conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/host@REALM");
  renewer = Master.getMasterPrincipal(conf);
}
 
Example #8
Source File: TestTokenCache.java    From big-c with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
  conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/host@REALM");
  renewer = Master.getMasterPrincipal(conf);
}