类org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenRequest源码实例Demo

下面列出了怎么用org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenRequest的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hadoop   文件: TestJHSSecurity.java
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;
}
 
源代码2 项目: big-c   文件: TestJHSSecurity.java
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;
}
 
源代码3 项目: hadoop   文件: YARNRunner.java
@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());
}
 
源代码4 项目: hadoop   文件: MRClientProtocolPBServiceImpl.java
@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);
  }
}
 
源代码5 项目: hadoop   文件: MRClientProtocolPBClientImpl.java
@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);
  }
}
 
源代码6 项目: big-c   文件: YARNRunner.java
@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());
}
 
源代码7 项目: big-c   文件: MRClientProtocolPBServiceImpl.java
@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);
  }
}
 
源代码8 项目: big-c   文件: MRClientProtocolPBClientImpl.java
@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);
  }
}
 
源代码9 项目: incubator-gobblin   文件: TokenUtils.java
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());
}
 
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());
}
 
源代码11 项目: hadoop   文件: MRClientService.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  throw new IOException("MR AM not authorized to issue delegation" +
  		" token");
}
 
源代码12 项目: hadoop   文件: NotRunningJob.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
源代码13 项目: hadoop   文件: TestYARNRunner.java
@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;
        }
      });
}
 
源代码14 项目: hadoop   文件: TestRPCFactories.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  return null;
}
 
源代码15 项目: big-c   文件: MRClientService.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  throw new IOException("MR AM not authorized to issue delegation" +
  		" token");
}
 
源代码16 项目: big-c   文件: NotRunningJob.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
源代码17 项目: big-c   文件: TestYARNRunner.java
@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;
        }
      });
}
 
源代码18 项目: big-c   文件: TestRPCFactories.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  return null;
}
 
源代码19 项目: incubator-tez   文件: NotRunningJob.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
源代码20 项目: tez   文件: NotRunningJob.java
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
源代码21 项目: hadoop   文件: MRClientProtocol.java
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException; 
源代码22 项目: big-c   文件: MRClientProtocol.java
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException; 
 类方法
 同包方法