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

The following examples show how to use org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenRequest. 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: MRDelegationTokenRenewer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public void cancel(Token<?> token, Configuration conf) throws IOException,
    InterruptedException {

  org.apache.hadoop.yarn.api.records.Token dToken =
      org.apache.hadoop.yarn.api.records.Token.newInstance(
        token.getIdentifier(), token.getKind().toString(),
        token.getPassword(), token.getService().toString());

  MRClientProtocol histProxy = instantiateHistoryProxy(conf,
      SecurityUtil.getTokenServiceAddr(token));
  try {
    CancelDelegationTokenRequest request = Records
        .newRecord(CancelDelegationTokenRequest.class);
    request.setDelegationToken(dToken);
    histProxy.cancelDelegationToken(request);
  } finally {
    stopHistoryProxy(histProxy);
  }
}
 
Example #2
Source File: HistoryClientService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
    if (!isAllowedDelegationTokenOp()) {
      throw new IOException(
          "Delegation Token can be cancelled only with kerberos authentication");
    }

    org.apache.hadoop.yarn.api.records.Token protoToken = request.getDelegationToken();
    Token<MRDelegationTokenIdentifier> token =
        new Token<MRDelegationTokenIdentifier>(
            protoToken.getIdentifier().array(), protoToken.getPassword()
                .array(), new Text(protoToken.getKind()), new Text(
                protoToken.getService()));

    String user = UserGroupInformation.getCurrentUser().getUserName();
    jhsDTSecretManager.cancelToken(token, user);
    return Records.newRecord(CancelDelegationTokenResponse.class);
}
 
Example #3
Source File: HistoryClientService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
    if (!isAllowedDelegationTokenOp()) {
      throw new IOException(
          "Delegation Token can be cancelled only with kerberos authentication");
    }

    org.apache.hadoop.yarn.api.records.Token protoToken = request.getDelegationToken();
    Token<MRDelegationTokenIdentifier> token =
        new Token<MRDelegationTokenIdentifier>(
            protoToken.getIdentifier().array(), protoToken.getPassword()
                .array(), new Text(protoToken.getKind()), new Text(
                protoToken.getService()));

    String user = UserGroupInformation.getCurrentUser().getUserName();
    jhsDTSecretManager.cancelToken(token, user);
    return Records.newRecord(CancelDelegationTokenResponse.class);
}
 
Example #4
Source File: MRDelegationTokenRenewer.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public void cancel(Token<?> token, Configuration conf) throws IOException,
    InterruptedException {

  org.apache.hadoop.yarn.api.records.Token dToken =
      org.apache.hadoop.yarn.api.records.Token.newInstance(
        token.getIdentifier(), token.getKind().toString(),
        token.getPassword(), token.getService().toString());

  MRClientProtocol histProxy = instantiateHistoryProxy(conf,
      SecurityUtil.getTokenServiceAddr(token));
  try {
    CancelDelegationTokenRequest request = Records
        .newRecord(CancelDelegationTokenRequest.class);
    request.setDelegationToken(dToken);
    histProxy.cancelDelegationToken(request);
  } finally {
    stopHistoryProxy(histProxy);
  }
}
 
Example #5
Source File: TestJHSSecurity.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void cancelDelegationToken(final UserGroupInformation loggedInUser,
    final MRClientProtocol hsService, final Token dToken)
    throws IOException, InterruptedException {

  loggedInUser.doAs(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws IOException {
      CancelDelegationTokenRequest request = Records
          .newRecord(CancelDelegationTokenRequest.class);
      request.setDelegationToken(dToken);
      hsService.cancelDelegationToken(request);
      return null;
    }
  });
}
 
Example #6
Source File: MRClientProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  CancelDelegationTokenRequestProto requestProto =
      ((CancelDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new CancelDelegationTokenResponsePBImpl(
        proxy.cancelDelegationToken(null, requestProto));

  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example #7
Source File: HadoopSecurityManager_H_2_0.java    From azkaban-plugins with Apache License 2.0 5 votes vote down vote up
private void cancelDelegationTokenFromHS(
    final org.apache.hadoop.yarn.api.records.Token t, HSClientProtocol hsProxy)
    throws IOException, InterruptedException {
  CancelDelegationTokenRequest request =
      recordFactory.newRecordInstance(CancelDelegationTokenRequest.class);
  request.setDelegationToken(t);
  hsProxy.cancelDelegationToken(request);
}
 
Example #8
Source File: HadoopSecurityManager_H_2_0.java    From azkaban-plugins with Apache License 2.0 5 votes vote down vote up
private void cancelJhsToken(final Token<? extends TokenIdentifier> t,
    String userToProxy) throws HadoopSecurityManagerException {
  // it appears yarn would clean up this token after app finish, after a long
  // while though.
  org.apache.hadoop.yarn.api.records.Token token =
      org.apache.hadoop.yarn.api.records.Token.newInstance(t.getIdentifier(),
          t.getKind().toString(), t.getPassword(), t.getService().toString());
  final YarnRPC rpc = YarnRPC.create(conf);
  final InetSocketAddress jhsAddress = SecurityUtil.getTokenServiceAddr(t);
  MRClientProtocol jhsProxy = null;
  try {
    jhsProxy =
        UserGroupInformation.getCurrentUser().doAs(
            new PrivilegedAction<MRClientProtocol>() {
              @Override
              public MRClientProtocol run() {
                return (MRClientProtocol) rpc.getProxy(
                    HSClientProtocol.class, jhsAddress, conf);
              }
            });
    CancelDelegationTokenRequest request =
        Records.newRecord(CancelDelegationTokenRequest.class);
    request.setDelegationToken(token);
    jhsProxy.cancelDelegationToken(request);
  } catch (Exception e) {
    throw new HadoopSecurityManagerException("Failed to cancel token. "
        + e.getMessage() + e.getCause(), e);
  } finally {
    RPC.stopProxy(jhsProxy);
  }

}
 
Example #9
Source File: TestJHSSecurity.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void cancelDelegationToken(final UserGroupInformation loggedInUser,
    final MRClientProtocol hsService, final Token dToken)
    throws IOException, InterruptedException {

  loggedInUser.doAs(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws IOException {
      CancelDelegationTokenRequest request = Records
          .newRecord(CancelDelegationTokenRequest.class);
      request.setDelegationToken(dToken);
      hsService.cancelDelegationToken(request);
      return null;
    }
  });
}
 
Example #10
Source File: MRClientProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  CancelDelegationTokenRequestProto requestProto =
      ((CancelDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new CancelDelegationTokenResponsePBImpl(
        proxy.cancelDelegationToken(null, requestProto));

  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example #11
Source File: NotRunningJob.java    From tez with Apache License 2.0 4 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest 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 CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  throw new IOException("MR AM not authorized to cancel delegation" +
      " token");
}
 
Example #13
Source File: NotRunningJob.java    From incubator-tez with Apache License 2.0 4 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest 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 CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  return null;
}
 
Example #15
Source File: NotRunningJob.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
Example #16
Source File: MRClientService.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  throw new IOException("MR AM not authorized to cancel delegation" +
      " token");
}
 
Example #17
Source File: TestRPCFactories.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  return null;
}
 
Example #18
Source File: NotRunningJob.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException {
  /* Should not be invoked by anyone. */
  throw new NotImplementedException();
}
 
Example #19
Source File: MRClientProtocol.java    From big-c with Apache License 2.0 2 votes vote down vote up
/**
 * Cancel an existing delegation token.
 * 
 * @param request the delegation token to be cancelled.
 * @return an empty response.
 * @throws IOException
 */
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException;
 
Example #20
Source File: MRClientProtocol.java    From hadoop with Apache License 2.0 2 votes vote down vote up
/**
 * Cancel an existing delegation token.
 * 
 * @param request the delegation token to be cancelled.
 * @return an empty response.
 * @throws IOException
 */
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws IOException;