org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenRequest Java Examples

The following examples show how to use org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenRequest. 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: TestJHSSecurity.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private Token getDelegationToken(
    final UserGroupInformation loggedInUser,
    final MRClientProtocol hsService, final String renewerString)
    throws IOException, InterruptedException {
  // Get the delegation token directly as it is a little difficult to setup
  // the kerberos based rpc.
  Token token = loggedInUser
      .doAs(new PrivilegedExceptionAction<Token>() {
        @Override
        public Token run() throws IOException {
          GetDelegationTokenRequest request = Records
              .newRecord(GetDelegationTokenRequest.class);
          request.setRenewer(renewerString);
          return hsService.getDelegationToken(request).getDelegationToken();
        }

      });
  return token;
}
 
Example #2
Source File: TestJHSSecurity.java    From big-c with Apache License 2.0 6 votes vote down vote up
private Token getDelegationToken(
    final UserGroupInformation loggedInUser,
    final MRClientProtocol hsService, final String renewerString)
    throws IOException, InterruptedException {
  // Get the delegation token directly as it is a little difficult to setup
  // the kerberos based rpc.
  Token token = loggedInUser
      .doAs(new PrivilegedExceptionAction<Token>() {
        @Override
        public Token run() throws IOException {
          GetDelegationTokenRequest request = Records
              .newRecord(GetDelegationTokenRequest.class);
          request.setRenewer(renewerString);
          return hsService.getDelegationToken(request).getDelegationToken();
        }

      });
  return token;
}
 
Example #3
Source File: YARNRunner.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
Token<?> getDelegationTokenFromHS(MRClientProtocol 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 #4
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 #5
Source File: MRClientProtocolPBServiceImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponseProto getDelegationToken(
    RpcController controller, GetDelegationTokenRequestProto proto)
    throws ServiceException {
  GetDelegationTokenRequest request = new GetDelegationTokenRequestPBImpl(proto);
  try {
    GetDelegationTokenResponse response = real.getDelegationToken(request);
    return ((GetDelegationTokenResponsePBImpl)response).getProto();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example #6
Source File: MRClientProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  GetDelegationTokenRequestProto requestProto = ((GetDelegationTokenRequestPBImpl)
      request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example #7
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 #8
Source File: MRClientProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  GetDelegationTokenRequestProto requestProto = ((GetDelegationTokenRequestPBImpl)
      request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example #9
Source File: YARNRunner.java    From big-c with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
Token<?> getDelegationTokenFromHS(MRClientProtocol 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 #10
Source File: MRClientProtocolPBServiceImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponseProto getDelegationToken(
    RpcController controller, GetDelegationTokenRequestProto proto)
    throws ServiceException {
  GetDelegationTokenRequest request = new GetDelegationTokenRequestPBImpl(proto);
  try {
    GetDelegationTokenResponse response = real.getDelegationToken(request);
    return ((GetDelegationTokenResponsePBImpl)response).getProto();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example #11
Source File: NotRunningJob.java    From tez with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
Example #12
Source File: MRClientService.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  throw new IOException("MR AM not authorized to issue delegation" +
  		" token");
}
 
Example #13
Source File: NotRunningJob.java    From incubator-tez with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
Example #14
Source File: TestRPCFactories.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  return null;
}
 
Example #15
Source File: TestYARNRunner.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test(timeout=20000)
public void testHistoryServerToken() throws Exception {
  //Set the master principal in the config
  conf.set(YarnConfiguration.RM_PRINCIPAL,"foo@LOCAL");

  final String masterPrincipal = Master.getMasterPrincipal(conf);

  final MRClientProtocol hsProxy = mock(MRClientProtocol.class);
  when(hsProxy.getDelegationToken(any(GetDelegationTokenRequest.class))).thenAnswer(
      new Answer<GetDelegationTokenResponse>() {
        public GetDelegationTokenResponse answer(InvocationOnMock invocation) {
          GetDelegationTokenRequest request =
              (GetDelegationTokenRequest)invocation.getArguments()[0];
          // check that the renewer matches the cluster's RM principal
          assertEquals(masterPrincipal, request.getRenewer() );

          org.apache.hadoop.yarn.api.records.Token token =
              recordFactory.newRecordInstance(org.apache.hadoop.yarn.api.records.Token.class);
          // none of these fields matter for the sake of the test
          token.setKind("");
          token.setService("");
          token.setIdentifier(ByteBuffer.allocate(0));
          token.setPassword(ByteBuffer.allocate(0));
          GetDelegationTokenResponse tokenResponse =
              recordFactory.newRecordInstance(GetDelegationTokenResponse.class);
          tokenResponse.setDelegationToken(token);
          return tokenResponse;
        }
      });
  
  UserGroupInformation.createRemoteUser("someone").doAs(
      new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
          yarnRunner = new YARNRunner(conf, null, null);
          yarnRunner.getDelegationTokenFromHS(hsProxy);
          verify(hsProxy).
            getDelegationToken(any(GetDelegationTokenRequest.class));
          return null;
        }
      });
}
 
Example #16
Source File: NotRunningJob.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
Example #17
Source File: MRClientService.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  throw new IOException("MR AM not authorized to issue delegation" +
  		" token");
}
 
Example #18
Source File: TestRPCFactories.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  return null;
}
 
Example #19
Source File: TestYARNRunner.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test(timeout=20000)
public void testHistoryServerToken() throws Exception {
  //Set the master principal in the config
  conf.set(YarnConfiguration.RM_PRINCIPAL,"foo@LOCAL");

  final String masterPrincipal = Master.getMasterPrincipal(conf);

  final MRClientProtocol hsProxy = mock(MRClientProtocol.class);
  when(hsProxy.getDelegationToken(any(GetDelegationTokenRequest.class))).thenAnswer(
      new Answer<GetDelegationTokenResponse>() {
        public GetDelegationTokenResponse answer(InvocationOnMock invocation) {
          GetDelegationTokenRequest request =
              (GetDelegationTokenRequest)invocation.getArguments()[0];
          // check that the renewer matches the cluster's RM principal
          assertEquals(masterPrincipal, request.getRenewer() );

          org.apache.hadoop.yarn.api.records.Token token =
              recordFactory.newRecordInstance(org.apache.hadoop.yarn.api.records.Token.class);
          // none of these fields matter for the sake of the test
          token.setKind("");
          token.setService("");
          token.setIdentifier(ByteBuffer.allocate(0));
          token.setPassword(ByteBuffer.allocate(0));
          GetDelegationTokenResponse tokenResponse =
              recordFactory.newRecordInstance(GetDelegationTokenResponse.class);
          tokenResponse.setDelegationToken(token);
          return tokenResponse;
        }
      });
  
  UserGroupInformation.createRemoteUser("someone").doAs(
      new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
          yarnRunner = new YARNRunner(conf, null, null);
          yarnRunner.getDelegationTokenFromHS(hsProxy);
          verify(hsProxy).
            getDelegationToken(any(GetDelegationTokenRequest.class));
          return null;
        }
      });
}
 
Example #20
Source File: NotRunningJob.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
Example #21
Source File: MRClientProtocol.java    From big-c with Apache License 2.0 votes vote down vote up
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException; 
Example #22
Source File: MRClientProtocol.java    From hadoop with Apache License 2.0 votes vote down vote up
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException;