use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto in project ozone by apache.
the class OzoneManagerProtocolClientSideTranslatorPB method getDelegationToken.
/**
* Get a valid Delegation Token.
*
* @param renewer the designated renewer for the token
* @return Token<OzoneDelegationTokenSelector>
* @throws OMException
*/
@Override
public Token<OzoneTokenIdentifier> getDelegationToken(Text renewer) throws OMException {
GetDelegationTokenRequestProto req = GetDelegationTokenRequestProto.newBuilder().setRenewer(renewer == null ? "" : renewer.toString()).build();
OMRequest omRequest = createOMRequest(Type.GetDelegationToken).setGetDelegationTokenRequest(req).build();
final GetDelegationTokenResponseProto resp;
try {
resp = handleError(submitRequest(omRequest)).getGetDelegationTokenResponse();
return resp.getResponse().hasToken() ? OMPBHelper.convertToDelegationToken(resp.getResponse().getToken()) : null;
} catch (IOException e) {
if (e instanceof OMException) {
throw (OMException) e;
}
throw new OMException("Get delegation token failed.", e, TOKEN_ERROR_OTHER);
}
}
Aggregations