Class Utils


  • public final class Utils
    extends java.lang.Object
    Amazon S3 utilities.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AWSDOTCOM
      constants to define endpoint to various AWS region
      static java.lang.String DASH  
      static java.lang.String DEFAULT_AWS_BUCKET_REGION
      The default value AWS bucket region.
      static java.lang.String DEFAULT_CONFIG_FILE  
      static java.lang.String DOT  
      static java.lang.String S3  
      static java.lang.String US_EAST_1_AWS_BUCKET_REGION
      The value for the us-east-1 region.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.Object> asMap​(java.util.Properties props)  
      static void deleteBucket​(java.lang.String bucketName)
      Delete S3 bucket.
      static com.amazonaws.services.s3.AmazonS3Client openService​(java.util.Properties prop)
      Create AmazonS3Client from properties.
      static java.util.Properties readConfig​(java.lang.String fileName)
      Read a configuration properties file.
      static boolean waitForBucket​(@NotNull com.amazonaws.services.s3.AmazonS3 s3Client, @NotNull java.lang.String bucketName)
      Waits for an S3 bucket, one we expect to exist, to report that it exists.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_CONFIG_FILE

        public static final java.lang.String DEFAULT_CONFIG_FILE
        See Also:
        Constant Field Values
      • DEFAULT_AWS_BUCKET_REGION

        public static final java.lang.String DEFAULT_AWS_BUCKET_REGION
        The default value AWS bucket region.
        See Also:
        Constant Field Values
      • US_EAST_1_AWS_BUCKET_REGION

        public static final java.lang.String US_EAST_1_AWS_BUCKET_REGION
        The value for the us-east-1 region.
        See Also:
        Constant Field Values
      • AWSDOTCOM

        public static final java.lang.String AWSDOTCOM
        constants to define endpoint to various AWS region
        See Also:
        Constant Field Values
    • Method Detail

      • openService

        public static com.amazonaws.services.s3.AmazonS3Client openService​(java.util.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 java.lang.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​(java.lang.String bucketName)
                                 throws java.io.IOException
        Delete S3 bucket. This method first deletes all objects from bucket and then delete empty bucket.
        Parameters:
        bucketName - the bucket name.
        Throws:
        java.io.IOException
      • readConfig

        public static java.util.Properties readConfig​(java.lang.String fileName)
                                               throws java.io.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:
        java.io.IOException - if the file doesn't exist
      • asMap

        public static java.util.Map<java.lang.String,​java.lang.Object> asMap​(java.util.Properties props)