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

The following examples show how to use org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenResponse. 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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #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: 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 #15
Source File: MRClientProtocol.java    From hadoop with Apache License 2.0 votes vote down vote up
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException; 
Example #16
Source File: MRClientProtocol.java    From big-c with Apache License 2.0 votes vote down vote up
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException;