org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto Java Examples

The following examples show how to use org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto. 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: TestYarnApiClasses.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
* Test RenewDelegationTokenRequestPBImpl.
* Test a transformation to prototype and back
*/

@Test
public void testRenewDelegationTokenRequestPBImpl() {

  Token token = getDelegationToken();

  RenewDelegationTokenRequestPBImpl original = new RenewDelegationTokenRequestPBImpl();
  original.setDelegationToken(token);
  RenewDelegationTokenRequestProto protoType = original.getProto();

  RenewDelegationTokenRequestPBImpl copy = new RenewDelegationTokenRequestPBImpl(protoType);
  assertNotNull(copy.getDelegationToken());
  //compare source and converted
  assertEquals(token, copy.getDelegationToken());

}
 
Example #2
Source File: TestYarnApiClasses.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
* Test RenewDelegationTokenRequestPBImpl.
* Test a transformation to prototype and back
*/

@Test
public void testRenewDelegationTokenRequestPBImpl() {

  Token token = getDelegationToken();

  RenewDelegationTokenRequestPBImpl original = new RenewDelegationTokenRequestPBImpl();
  original.setDelegationToken(token);
  RenewDelegationTokenRequestProto protoType = original.getProto();

  RenewDelegationTokenRequestPBImpl copy = new RenewDelegationTokenRequestPBImpl(protoType);
  assertNotNull(copy.getDelegationToken());
  //compare source and converted
  assertEquals(token, copy.getDelegationToken());

}
 
Example #3
Source File: OzoneManagerProtocolClientSideTranslatorPB.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Renew an existing delegation token.
 *
 * @param token delegation token obtained earlier
 * @return the new expiration time
 */
@Override
public long renewDelegationToken(Token<OzoneTokenIdentifier> token)
    throws OMException {
  RenewDelegationTokenRequestProto req =
      RenewDelegationTokenRequestProto.newBuilder().
          setToken(OMPBHelper.convertToTokenProto(token)).
          build();

  OMRequest omRequest = createOMRequest(Type.RenewDelegationToken)
      .setRenewDelegationTokenRequest(req)
      .build();

  final RenewDelegationTokenResponseProto resp;
  try {
    resp = handleError(submitRequest(omRequest))
        .getRenewDelegationTokenResponse();
    return resp.getResponse().getNewExpiryTime();
  } catch (IOException e) {
    if(e instanceof OMException) {
      throw (OMException)e;
    }
    throw new OMException("Renew delegation token failed.", e,
        TOKEN_ERROR_OTHER);
  }
}
 
Example #4
Source File: ClientNamenodeProtocolTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public long renewDelegationToken(Token<DelegationTokenIdentifier> token)
    throws IOException {
  RenewDelegationTokenRequestProto req = RenewDelegationTokenRequestProto.newBuilder().
      setToken(PBHelper.convert(token)).
      build();
  try {
    return rpcProxy.renewDelegationToken(null, req).getNewExpiryTime();
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example #5
Source File: ClientNamenodeProtocolTranslatorPB.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public long renewDelegationToken(Token<DelegationTokenIdentifier> token)
    throws IOException {
  RenewDelegationTokenRequestProto req = RenewDelegationTokenRequestProto.newBuilder().
      setToken(PBHelper.convert(token)).
      build();
  try {
    return rpcProxy.renewDelegationToken(null, req).getNewExpiryTime();
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example #6
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponseProto renewDelegationToken(
    RpcController controller, RenewDelegationTokenRequestProto req)
    throws ServiceException {
  try {
    long result = server.renewDelegationToken(PBHelper
        .convertDelegationToken(req.getToken()));
    return RenewDelegationTokenResponseProto.newBuilder()
        .setNewExpiryTime(result).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example #7
Source File: MRClientProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws IOException {
  RenewDelegationTokenRequestProto requestProto = 
      ((RenewDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example #8
Source File: MRClientProtocolPBServiceImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponseProto renewDelegationToken(
    RpcController controller, RenewDelegationTokenRequestProto proto)
    throws ServiceException {
  RenewDelegationTokenRequestPBImpl request =
      new RenewDelegationTokenRequestPBImpl(proto);
    try {
      RenewDelegationTokenResponse response = real.renewDelegationToken(request);
      return ((RenewDelegationTokenResponsePBImpl)response).getProto();
    } catch (IOException e) {
      throw new ServiceException(e);
    }
}
 
Example #9
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example #10
Source File: ApplicationClientProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws YarnException,
    IOException {
  RenewDelegationTokenRequestProto requestProto = 
      ((RenewDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #11
Source File: ApplicationHistoryProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws YarnException, IOException {
  RenewDelegationTokenRequestProto requestProto =
      ((RenewDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #12
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponseProto renewDelegationToken(
    RpcController controller, RenewDelegationTokenRequestProto req)
    throws ServiceException {
  try {
    long result = server.renewDelegationToken(PBHelper
        .convertDelegationToken(req.getToken()));
    return RenewDelegationTokenResponseProto.newBuilder()
        .setNewExpiryTime(result).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example #13
Source File: MRClientProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws IOException {
  RenewDelegationTokenRequestProto requestProto = 
      ((RenewDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example #14
Source File: MRClientProtocolPBServiceImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponseProto renewDelegationToken(
    RpcController controller, RenewDelegationTokenRequestProto proto)
    throws ServiceException {
  RenewDelegationTokenRequestPBImpl request =
      new RenewDelegationTokenRequestPBImpl(proto);
    try {
      RenewDelegationTokenResponse response = real.renewDelegationToken(request);
      return ((RenewDelegationTokenResponsePBImpl)response).getProto();
    } catch (IOException e) {
      throw new ServiceException(e);
    }
}
 
Example #15
Source File: RenewDelegationTokenRequestPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example #16
Source File: ApplicationClientProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws YarnException,
    IOException {
  RenewDelegationTokenRequestProto requestProto = 
      ((RenewDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #17
Source File: ApplicationHistoryProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws YarnException, IOException {
  RenewDelegationTokenRequestProto requestProto =
      ((RenewDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #18
Source File: OMRenewDelegationTokenRequest.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Override
public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
  RenewDelegationTokenRequestProto renewDelegationTokenRequest =
      getOmRequest().getRenewDelegationTokenRequest();

  // Call OM to renew token
  long renewTime = ozoneManager.renewDelegationToken(
      OMPBHelper.convertToDelegationToken(
          renewDelegationTokenRequest.getToken()));

  RenewDelegationTokenResponseProto.Builder renewResponse =
      RenewDelegationTokenResponseProto.newBuilder();

  renewResponse.setResponse(org.apache.hadoop.security.proto.SecurityProtos
      .RenewDelegationTokenResponseProto.newBuilder()
      .setNewExpiryTime(renewTime));


  // Client issues RenewDelegationToken request, when received by OM leader
  // it will renew the token. Original RenewDelegationToken request is
  // converted to UpdateRenewDelegationToken request with the token and renew
  // information. This updated request will be submitted to Ratis. In this
  // way delegation token renewd by leader, will be replicated across all
  // OMs. With this approach, original RenewDelegationToken request from
  // client does not need any proto changes.

  // Create UpdateRenewDelegationTokenRequest with original request and
  // expiry time.
  OMRequest.Builder omRequest = OMRequest.newBuilder()
      .setUserInfo(getUserInfo())
      .setUpdatedRenewDelegationTokenRequest(
          UpdateRenewDelegationTokenRequest.newBuilder()
              .setRenewDelegationTokenRequest(renewDelegationTokenRequest)
              .setRenewDelegationTokenResponse(renewResponse))
      .setCmdType(getOmRequest().getCmdType())
      .setClientId(getOmRequest().getClientId());

  if (getOmRequest().hasTraceID()) {
    omRequest.setTraceID(getOmRequest().getTraceID());
  }

  return omRequest.build();
}
 
Example #19
Source File: RenewDelegationTokenRequestPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
Example #20
Source File: RenewDelegationTokenRequestPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl (
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
Example #21
Source File: RenewDelegationTokenRequestPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example #22
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example #23
Source File: RenewDelegationTokenRequestPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example #24
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl(
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
Example #25
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  this.builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
Example #26
Source File: RenewDelegationTokenRequestPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  this.builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
Example #27
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example #28
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example #29
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl (
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
Example #30
Source File: RenewDelegationTokenRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  builder = RenewDelegationTokenRequestProto.newBuilder();
}