Class CosClient


  • public class CosClient
    extends Object
    Encapsulates the AmazonS3 client for interaction with IBM Cloud Object Storage (COS)
    • Constructor Detail

      • CosClient

        public CosClient​(Properties cosProperties)
        Public constructor
        Parameters:
        cosProperties -
    • Method Detail

      • signalStop

        public void signalStop()
        Tell the scanner to stop. Can be used to get scan() to finish early
      • read

        public <T> T read​(String bucketName,
                          String itemName,
                          Function<PushbackInputStream,​T> fn)
        Read the object using the given function
        Type Parameters:
        T -
        Parameters:
        bucketName -
        itemName -
        fn -
        Returns:
      • process

        public void process​(String bucketName,
                            String itemName,
                            Consumer<BufferedReader> consumer)
        Read and process the object, feeding the content to the given consumer as a BufferedReader. We keep control of the stream, and close it when the consumer accept call returns
        Parameters:
        bucketName -
        itemName -
        consumer -
      • scan

        public void scan​(String bucketName,
                         String pathPrefix,
                         Function<String,​FileType> fileTyper,
                         Consumer<CosItem> consumer)
        Scan the COS bucket, feeding each returned item to the given consumer
        Parameters:
        bucketName -
        fileType - function to derive fileType from the item key value
        consumer - target for each non-empty CosItem we find in the bucket