use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelPrepareResponse 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;
}
Aggregations