use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashRequest in project ozone by apache.
the class OMTrashRecoverRequest method validateAndUpdateCache.
@Override
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, long transactionLogIndex, OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) {
RecoverTrashRequest recoverTrashRequest = getOmRequest().getRecoverTrashRequest();
Preconditions.checkNotNull(recoverTrashRequest);
String volumeName = recoverTrashRequest.getVolumeName();
String bucketName = recoverTrashRequest.getBucketName();
String keyName = recoverTrashRequest.getKeyName();
String destinationBucket = recoverTrashRequest.getDestinationBucket();
/**
* TODO: HDDS-2818. New Metrics for Trash Key Recover and Fails.
* OMMetrics omMetrics = ozoneManager.getMetrics();
*/
OMResponse.Builder omResponse = OMResponse.newBuilder().setCmdType(Type.RecoverTrash).setStatus(Status.OK).setSuccess(true);
OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
boolean acquireLock = false;
OMClientResponse omClientResponse = null;
try {
ResolvedBucket bucket = ozoneManager.resolveBucketLink(Pair.of(volumeName, destinationBucket), this);
volumeName = bucket.realVolume();
destinationBucket = bucket.realBucket();
// Check acl for the destination bucket.
checkBucketAcls(ozoneManager, volumeName, destinationBucket, keyName, IAccessAuthorizer.ACLType.WRITE);
acquireLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volumeName, destinationBucket);
// Validate.
validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
validateBucketAndVolume(omMetadataManager, volumeName, destinationBucket);
/**
* TODO: HDDS-2425. HDDS-2426.
* Update cache.
* omMetadataManager.getKeyTable().addCacheEntry(
* new CacheKey<>(),
* new CacheValue<>()
* );
*
* Execute recovering trash in non-existing bucket.
* Execute recovering trash in existing bucket.
* omClientResponse = new OMTrashRecoverResponse(omKeyInfo,
* omResponse.setRecoverTrashResponse(
* RecoverTrashResponse.newBuilder())
* .build());
*/
omClientResponse = null;
} catch (IOException ex) {
LOG.error("Fail for recovering trash.", ex);
omClientResponse = new OMTrashRecoverResponse(null, createErrorOMResponse(omResponse, ex), getBucketLayout());
} finally {
if (omClientResponse != null) {
omClientResponse.setFlushFuture(ozoneManagerDoubleBufferHelper.add(omClientResponse, transactionLogIndex));
}
if (acquireLock) {
omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName, destinationBucket);
}
}
return omClientResponse;
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashRequest in project ozone by apache.
the class OMTrashRecoverRequest method preExecute.
@Override
public OMRequest preExecute(OzoneManager ozoneManager) {
RecoverTrashRequest recoverTrashRequest = getOmRequest().getRecoverTrashRequest();
Preconditions.checkNotNull(recoverTrashRequest);
return getOmRequest().toBuilder().build();
}
Aggregations