Search in sources :

Example 1 with RecoverTrashRequest

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;
}
Also used : OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) RecoverTrashRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashRequest) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) OMTrashRecoverResponse(org.apache.hadoop.ozone.om.response.key.OMTrashRecoverResponse) IOException(java.io.IOException) ResolvedBucket(org.apache.hadoop.ozone.om.ResolvedBucket) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)

Example 2 with RecoverTrashRequest

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();
}
Also used : RecoverTrashRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashRequest)

Aggregations

RecoverTrashRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashRequest)2 IOException (java.io.IOException)1 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)1 ResolvedBucket (org.apache.hadoop.ozone.om.ResolvedBucket)1 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)1 OMTrashRecoverResponse (org.apache.hadoop.ozone.om.response.key.OMTrashRecoverResponse)1 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)1