Search in sources :

Example 1 with OMCancelDelegationTokenResponse

use of org.apache.hadoop.ozone.om.response.security.OMCancelDelegationTokenResponse in project ozone by apache.

the class OMCancelDelegationTokenRequest method validateAndUpdateCache.

@Override
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, long transactionLogIndex, OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) {
    OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
    OMClientResponse omClientResponse = null;
    OMResponse.Builder omResponse = OmResponseUtil.getOMResponseBuilder(getOmRequest());
    OzoneTokenIdentifier ozoneTokenIdentifier = null;
    try {
        ozoneTokenIdentifier = OzoneTokenIdentifier.readProtoBuf(getToken().getIdentifier());
        // Remove token from in-memory.
        ozoneManager.getDelegationTokenMgr().removeToken(ozoneTokenIdentifier);
        // Update Cache.
        omMetadataManager.getDelegationTokenTable().addCacheEntry(new CacheKey<>(ozoneTokenIdentifier), new CacheValue<>(Optional.absent(), transactionLogIndex));
        omClientResponse = new OMCancelDelegationTokenResponse(ozoneTokenIdentifier, omResponse.setCancelDelegationTokenResponse(CancelDelegationTokenResponseProto.newBuilder().setResponse(SecurityProtos.CancelDelegationTokenResponseProto.newBuilder())).build());
    } catch (IOException ex) {
        LOG.error("Error in cancel DelegationToken {}", ozoneTokenIdentifier, ex);
        omClientResponse = new OMCancelDelegationTokenResponse(null, createErrorOMResponse(omResponse, ex));
    } finally {
        addResponseToDoubleBuffer(transactionLogIndex, omClientResponse, ozoneManagerDoubleBufferHelper);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Cancelled delegation token: {}", ozoneTokenIdentifier);
    }
    return omClientResponse;
}
Also used : OMCancelDelegationTokenResponse(org.apache.hadoop.ozone.om.response.security.OMCancelDelegationTokenResponse) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OzoneTokenIdentifier(org.apache.hadoop.ozone.security.OzoneTokenIdentifier) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) IOException(java.io.IOException) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)

Aggregations

IOException (java.io.IOException)1 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)1 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)1 OMCancelDelegationTokenResponse (org.apache.hadoop.ozone.om.response.security.OMCancelDelegationTokenResponse)1 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)1 OzoneTokenIdentifier (org.apache.hadoop.ozone.security.OzoneTokenIdentifier)1