org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenRequest#org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto源码实例Demo

下面列出了org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenRequest#org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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);
  }
}
 
源代码2 项目: hadoop   文件: TestYarnApiClasses.java
/**
* 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());

}
 
源代码3 项目: big-c   文件: TestYarnApiClasses.java
/**
* 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());

}
 
@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;
  }
}
 
@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;
  }
}
 
@Override
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
源代码7 项目: hadoop   文件: MRClientProtocolPBServiceImpl.java
@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);
    }
}
 
源代码8 项目: hadoop   文件: MRClientProtocolPBClientImpl.java
@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);
  }
}
 
@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);
  }
}
 
@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);
  }
}
 
@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;
  }
}
 
@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;
  }
}
 
源代码13 项目: big-c   文件: RenewDelegationTokenRequestPBImpl.java
@Override
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
源代码14 项目: big-c   文件: MRClientProtocolPBServiceImpl.java
@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);
    }
}
 
源代码15 项目: big-c   文件: MRClientProtocolPBClientImpl.java
@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);
  }
}
 
@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);
  }
}
 
源代码17 项目: big-c   文件: ClientNamenodeProtocolTranslatorPB.java
@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);
  }
}
 
@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();
}
 
源代码19 项目: hadoop   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestPBImpl() {
  builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
源代码20 项目: hadoop   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestPBImpl (
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
源代码21 项目: hadoop   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
源代码22 项目: hadoop   文件: RenewDelegationTokenRequestPBImpl.java
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
源代码23 项目: hadoop   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestPBImpl() {
  this.builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
源代码24 项目: hadoop   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestPBImpl(
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
源代码25 项目: hadoop   文件: RenewDelegationTokenRequestPBImpl.java
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
源代码26 项目: big-c   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestPBImpl() {
  builder = RenewDelegationTokenRequestProto.newBuilder();
}
 
源代码27 项目: big-c   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestPBImpl (
    RenewDelegationTokenRequestProto proto) {
  this.proto = proto;
  this.viaProto = true;
}
 
源代码28 项目: big-c   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
源代码29 项目: big-c   文件: RenewDelegationTokenRequestPBImpl.java
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = RenewDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
源代码30 项目: big-c   文件: RenewDelegationTokenRequestPBImpl.java
public RenewDelegationTokenRequestPBImpl() {
  this.builder = RenewDelegationTokenRequestProto.newBuilder();
}