use of org.apache.hadoop.ozone.om.response.key.OMOpenKeysDeleteResponse in project ozone by apache.
the class OMOpenKeysDeleteRequest method validateAndUpdateCache.
@Override
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, long trxnLogIndex, OzoneManagerDoubleBufferHelper omDoubleBufferHelper) {
OMMetrics omMetrics = ozoneManager.getMetrics();
omMetrics.incNumOpenKeyDeleteRequests();
OzoneManagerProtocolProtos.DeleteOpenKeysRequest deleteOpenKeysRequest = getOmRequest().getDeleteOpenKeysRequest();
List<OpenKeyBucket> submittedOpenKeyBuckets = deleteOpenKeysRequest.getOpenKeysPerBucketList();
long numSubmittedOpenKeys = 0;
for (OpenKeyBucket keyBucket : submittedOpenKeyBuckets) {
numSubmittedOpenKeys += keyBucket.getKeysCount();
}
LOG.debug("{} open keys submitted for deletion.", numSubmittedOpenKeys);
omMetrics.incNumOpenKeysSubmittedForDeletion(numSubmittedOpenKeys);
OzoneManagerProtocolProtos.OMResponse.Builder omResponse = OmResponseUtil.getOMResponseBuilder(getOmRequest());
IOException exception = null;
OMClientResponse omClientResponse = null;
Result result = null;
Map<String, OmKeyInfo> deletedOpenKeys = new HashMap<>();
try {
for (OpenKeyBucket openKeyBucket : submittedOpenKeyBuckets) {
// For each bucket where keys will be deleted from,
// get its bucket lock and update the cache accordingly.
Map<String, OmKeyInfo> deleted = updateOpenKeyTableCache(ozoneManager, trxnLogIndex, openKeyBucket);
deletedOpenKeys.putAll(deleted);
}
omClientResponse = new OMOpenKeysDeleteResponse(omResponse.build(), deletedOpenKeys, ozoneManager.isRatisEnabled());
result = Result.SUCCESS;
} catch (IOException ex) {
result = Result.FAILURE;
exception = ex;
omClientResponse = new OMOpenKeysDeleteResponse(createErrorOMResponse(omResponse, exception), getBucketLayout());
} finally {
addResponseToDoubleBuffer(trxnLogIndex, omClientResponse, omDoubleBufferHelper);
}
processResults(omMetrics, numSubmittedOpenKeys, deletedOpenKeys.size(), deleteOpenKeysRequest, result);
return omClientResponse;
}
Aggregations