Class Utils


  • public final class Utils
    extends Object
    Amazon S3 utilities.
    • Method Detail

      • openService

        public static com.amazonaws.services.s3.AmazonS3Client openService​(Properties prop)
        Create AmazonS3Client from properties.
        Parameters:
        prop - properties to configure @link AmazonS3Client
        Returns:
        AmazonS3Client
      • waitForBucket

        public static boolean waitForBucket​(@NotNull
                                            @NotNull com.amazonaws.services.s3.AmazonS3 s3Client,
                                            @NotNull
                                            @NotNull String bucketName)
        Waits for an S3 bucket, one we expect to exist, to report that it exists. A check for the bucket is called with a limited number of repeats with an increasing backoff. Usually you would call this after creating a bucket to block until the bucket is actually available before moving forward with other tasks that expect the bucket to be available.
        Parameters:
        s3Client - The AmazonS3 client connection to the storage service.
        bucketName - The name of the bucket to check.
        Returns:
        True if the bucket exists; false otherwise.
      • deleteBucket

        public static void deleteBucket​(String bucketName)
                                 throws IOException
        Delete S3 bucket. This method first deletes all objects from bucket and then delete empty bucket.
        Parameters:
        bucketName - the bucket name.
        Throws:
        IOException
      • readConfig

        public static Properties readConfig​(String fileName)
                                     throws IOException
        Read a configuration properties file. If the file name ends with ";burn", the file is deleted after reading.
        Parameters:
        fileName - the properties file name
        Returns:
        the properties
        Throws:
        IOException - if the file doesn't exist