/** * 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 RenewDelegationTokenRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; }
@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); } }
@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 long renewDelegationToken(Token<DelegationTokenIdentifier> token) throws IOException { RenewDelegationTokenRequestProto req = RenewDelegationTokenRequestProto.newBuilder(). setToken(PBHelperClient.convert(token)). build(); try { return rpcProxy.renewDelegationToken(null, req).getNewExpiryTime(); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } }
@Override public RenewDelegationTokenResponseProto renewDelegationToken( RpcController controller, RenewDelegationTokenRequestProto req) throws ServiceException { try { long result = server.renewDelegationToken(PBHelperClient .convertDelegationToken(req.getToken())); return RenewDelegationTokenResponseProto.newBuilder() .setNewExpiryTime(result).build(); } catch (IOException e) { throw new ServiceException(e); } }