コード例 #1
0
ファイル: Cluster.java プロジェクト: bharathravi/hadoop
 /**
  * Get a delegation token for the user from the JobTracker.
  *
  * @param renewer the user who can renew the token
  * @return the new token
  * @throws IOException
  */
 public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
     throws IOException, InterruptedException {
   Token<DelegationTokenIdentifier> result = client.getDelegationToken(renewer);
   InetSocketAddress addr = Master.getMasterAddress(conf);
   StringBuilder service = new StringBuilder();
   service.append(NetUtils.normalizeHostName(addr.getAddress().getHostAddress()));
   service.append(':');
   service.append(addr.getPort());
   result.setService(new Text(service.toString()));
   return result;
 }
コード例 #2
0
 /**
  * verify _HOST substitution
  *
  * @throws IOException
  */
 @Test
 public void testGetJTPrincipal() throws IOException {
   String serviceName = "jt/";
   String hostName = "foo";
   String domainName = "@BAR";
   Configuration conf = new Configuration();
   conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.CLASSIC_FRAMEWORK_NAME);
   conf.set(JTConfig.JT_IPC_ADDRESS, hostName + ":8888");
   conf.set(JTConfig.JT_USER_NAME, serviceName + SecurityUtil.HOSTNAME_PATTERN + domainName);
   assertEquals(
       "Failed to substitute HOSTNAME_PATTERN with hostName",
       serviceName + hostName + domainName,
       Master.getMasterPrincipal(conf));
 }