Search in sources :

Example 1 with OMCancelPrepareResponse

use of org.apache.hadoop.ozone.om.response.upgrade.OMCancelPrepareResponse in project ozone by apache.

the class OMCancelPrepareRequest method validateAndUpdateCache.

@Override
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, long transactionLogIndex, OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) {
    LOG.info("OM {} Received cancel prepare request with log index {}", ozoneManager.getOMNodeId(), transactionLogIndex);
    OMRequest omRequest = getOmRequest();
    OMResponse.Builder responseBuilder = OmResponseUtil.getOMResponseBuilder(omRequest);
    responseBuilder.setCmdType(Type.CancelPrepare);
    OMClientResponse response = null;
    try {
        String username = getOmRequest().getUserInfo().getUserName();
        if (ozoneManager.getAclsEnabled() && !ozoneManager.isAdmin(username)) {
            throw new OMException("Access denied for user " + username + ". " + "Superuser privilege is required to cancel ozone manager " + "preparation.", OMException.ResultCodes.ACCESS_DENIED);
        }
        // Create response.
        CancelPrepareResponse omResponse = CancelPrepareResponse.newBuilder().build();
        responseBuilder.setCancelPrepareResponse(omResponse);
        response = new OMCancelPrepareResponse(responseBuilder.build());
        // Deletes on disk marker file, does not update DB and therefore does
        // not update cache.
        ozoneManager.getPrepareState().cancelPrepare();
        ozoneManagerDoubleBufferHelper.add(response, transactionLogIndex);
        LOG.info("OM {} prepare state cancelled at log index {}. Returning " + "response {}", ozoneManager.getOMNodeId(), transactionLogIndex, omResponse);
    } catch (IOException e) {
        LOG.error("Cancel Prepare Request apply failed in {}. ", ozoneManager.getOMNodeId(), e);
        response = new OMPrepareResponse(createErrorOMResponse(responseBuilder, e));
    }
    return response;
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) CancelPrepareResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelPrepareResponse) OMCancelPrepareResponse(org.apache.hadoop.ozone.om.response.upgrade.OMCancelPrepareResponse) IOException(java.io.IOException) OMCancelPrepareResponse(org.apache.hadoop.ozone.om.response.upgrade.OMCancelPrepareResponse) OMException(org.apache.hadoop.ozone.om.exceptions.OMException) OMPrepareResponse(org.apache.hadoop.ozone.om.response.upgrade.OMPrepareResponse) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)

Aggregations

IOException (java.io.IOException)1 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)1 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)1 OMCancelPrepareResponse (org.apache.hadoop.ozone.om.response.upgrade.OMCancelPrepareResponse)1 OMPrepareResponse (org.apache.hadoop.ozone.om.response.upgrade.OMPrepareResponse)1 CancelPrepareResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelPrepareResponse)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)1