hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/BucketManagerImpl.java
public void deleteBucket(String volumeName, String bucketName)
      throws IOException {
    Preconditions.checkNotNull(volumeName);
    Preconditions.checkNotNull(bucketName);
    metadataManager.writeLock().lock();
    try {
      byte[] bucketKey = metadataManager.getBucketKey(volumeName, bucketName);
      //Check if volume exists
      if (metadataManager.get(metadataManager.getVolumeKey(volumeName))
          == null) {
        LOG.debug("volume: {} not found ", volumeName);
        throw new KSMException("Volume doesn't exist",
            KSMException.ResultCodes.FAILED_VOLUME_NOT_FOUND);
      }
      //Check if bucket exist
      if (metadataManager.get(bucketKey) == null) {
        LOG.debug("bucket: {} not found ", bucketName);
        throw new KSMException("Bucket doesn't exist",
            KSMException.ResultCodes.FAILED_BUCKET_NOT_FOUND);
      }
      //Check if bucket is empty
      if (!metadataManager.isBucketEmpty(volumeName, bucketName)) {
        LOG.debug("bucket: {} is not empty ", bucketName);
        throw new KSMException("Bucket is not empty",
            KSMException.ResultCodes.FAILED_BUCKET_NOT_EMPTY);
      }
      metadataManager.delete(bucketKey);
    } catch (IOException ex) {
      if (!(ex instanceof KSMException)) {
        LOG.error("Delete bucket failed for bucket:{} in volume:{}", bucketName,
            volumeName, ex);
      }
      throw ex;
    } finally {
      metadataManager.writeLock().unlock();
    }
  }
/**
   * Deletes an existing empty bucket from volume.
   * @param volumeName - Name of the volume.
   * @param bucketName - Name of the bucket.
   * @throws IOException
   */
Deletes an existing empty bucket from volume.
@param volumeName - Name of the volume.
@param bucketName - Name of the bucket.
Deletes an existing empty bucket from volume . @param volumeName - Name of the volume . @param bucketName - Name of the bucket .
public void deleteBucket(String volumeName, String bucketName)
      throws IOException {
    Preconditions.checkNotNull(volumeName);
    Preconditions.checkNotNull(bucketName);
    metadataManager.writeLock().lock();
    try {
      byte[] bucketKey = metadataManager.getBucketKey(volumeName, bucketName);
      if (metadataManager.get(metadataManager.getVolumeKey(volumeName))
          == null) {
        LOG.debug("volume: {} not found ", volumeName);
        throw new KSMException("Volume doesn't exist",
            KSMException.ResultCodes.FAILED_VOLUME_NOT_FOUND);
      }
      if (metadataManager.get(bucketKey) == null) {
        LOG.debug("bucket: {} not found ", bucketName);
        throw new KSMException("Bucket doesn't exist",
            KSMException.ResultCodes.FAILED_BUCKET_NOT_FOUND);
      }
      if (!metadataManager.isBucketEmpty(volumeName, bucketName)) {
        LOG.debug("bucket: {} is not empty ", bucketName);
        throw new KSMException("Bucket is not empty",
            KSMException.ResultCodes.FAILED_BUCKET_NOT_EMPTY);
      }
      metadataManager.delete(bucketKey);
    } catch (IOException ex) {
      if (!(ex instanceof KSMException)) {
        LOG.error("Delete bucket failed for bucket:{} in volume:{}", bucketName,
            volumeName, ex);
      }
      throw ex;
    } finally {
      metadataManager.writeLock().unlock();
    }
  }
public void deleteBucket ( String volumeName , String bucketName ) throws IOException { Preconditions . checkNotNull ( volumeName ) ; Preconditions . checkNotNull ( bucketName ) ; metadataManager . writeLock ( ) . lock ( ) ; try { byte [ ] bucketKey = metadataManager . getBucketKey ( volumeName , bucketName ) ; if ( metadataManager . get ( metadataManager . getVolumeKey ( volumeName ) ) == null ) { LOG . debug ( "volume: {} not found " , volumeName ) ; throw new KSMException ( "Volume doesn't exist" , KSMException . ResultCodes . FAILED_VOLUME_NOT_FOUND ) ; } if ( metadataManager . get ( bucketKey ) == null ) { LOG . debug ( "bucket: {} not found " , bucketName ) ; throw new KSMException ( "Bucket doesn't exist" , KSMException . ResultCodes . FAILED_BUCKET_NOT_FOUND ) ; } if ( ! metadataManager . isBucketEmpty ( volumeName , bucketName ) ) { LOG . debug ( "bucket: {} is not empty " , bucketName ) ; throw new KSMException ( "Bucket is not empty" , KSMException . ResultCodes . FAILED_BUCKET_NOT_EMPTY ) ; } metadataManager . delete ( bucketKey ) ; } catch ( IOException ex ) { if ( ! ( ex instanceof KSMException ) ) { LOG . error ( "Delete bucket failed for bucket:{} in volume:{}" , bucketName , volumeName , ex ) ; } throw ex ; } finally { metadataManager . writeLock ( ) . unlock ( ) ; } }
Deletes an existing empty bucket from volume.
Deletes an existing empty bucket from volume .
//Check if volume exists //Check if bucket exist //Check if bucket is empty