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

The following examples show how to use org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenResponse. These examples are extracted from open source projects. 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 Project: hadoop   Source File: MRClientProtocolPBServiceImpl.java    License: 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 Project: hadoop   Source File: MRClientProtocolPBClientImpl.java    License: 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 Project: big-c   Source File: MRClientProtocolPBServiceImpl.java    License: 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 Project: big-c   Source File: MRClientProtocolPBClientImpl.java    License: 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 Project: hadoop   Source File: MRClientService.java    License: 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 Project: hadoop   Source File: NotRunningJob.java    License: 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 Project: hadoop   Source File: TestYARNRunner.java    License: 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,"[email protected]");

  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 Project: hadoop   Source File: TestRPCFactories.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  return null;
}
 
Example 9
Source Project: big-c   Source File: MRClientService.java    License: 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 Project: big-c   Source File: NotRunningJob.java    License: 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 Project: big-c   Source File: TestYARNRunner.java    License: 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,"[email protected]");

  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 Project: big-c   Source File: TestRPCFactories.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  return null;
}
 
Example 13
Source Project: incubator-tez   Source File: NotRunningJob.java    License: 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 Project: tez   Source File: NotRunningJob.java    License: 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 Project: hadoop   Source File: MRClientProtocol.java    License: Apache License 2.0 votes vote down vote up
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException; 
Example 16
Source Project: big-c   Source File: MRClientProtocol.java    License: Apache License 2.0 votes vote down vote up
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException;