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

The following examples show how to use org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto. 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
/**
 * 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 2
Source Project: hadoop   Source File: TestYarnApiClasses.java    License: 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 Project: big-c   Source File: TestYarnApiClasses.java    License: 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 4
@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 5
@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 6
Source Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: 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 7
Source Project: hadoop   Source File: MRClientProtocolPBServiceImpl.java    License: 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 8
Source Project: hadoop   Source File: MRClientProtocolPBClientImpl.java    License: 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 9
@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 10
Source Project: hadoop   Source File: ClientNamenodeProtocolTranslatorPB.java    License: 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 11
@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
@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 13
Source Project: big-c   Source File: RenewDelegationTokenRequestPBImpl.java    License: 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 14
Source Project: big-c   Source File: MRClientProtocolPBServiceImpl.java    License: 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 Project: big-c   Source File: MRClientProtocolPBClientImpl.java    License: 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 16
@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 17
Source Project: big-c   Source File: ClientNamenodeProtocolTranslatorPB.java    License: 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 18
@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 Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
Example 20
Source Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl (
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
Example 21
Source Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: 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 Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: 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 Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  this.builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
Example 24
Source Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl(
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
Example 25
Source Project: hadoop   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example 26
Source Project: big-c   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
Example 27
Source Project: big-c   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl (
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
Example 28
Source Project: big-c   Source File: RenewDelegationTokenRequestPBImpl.java    License: 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 Project: big-c   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example 30
Source Project: big-c   Source File: RenewDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public RenewDelegationTokenRequestPBImpl() {
  this.builder = RenewDelegationTokenRequestProto.newBuilder();
}