Class COSClient


  • public class COSClient
    extends java.lang.Object
    Encapsulates the AmazonS3 client for interaction with IBM Cloud Object Storage (COS)
    • Constructor Summary

      Constructors 
      Constructor Description
      COSClient​(java.util.Properties cosProperties)
      Public constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void process​(java.lang.String bucketName, java.lang.String itemName, java.util.function.Consumer<java.io.BufferedReader> consumer)
      Read and process the object, feeding the content to the given consumer as a BufferedReader.
      <T> T read​(java.lang.String bucketName, java.lang.String itemName, java.util.function.Function<java.io.PushbackInputStream,​T> fn)
      Read the object using the given function
      void scan​(java.lang.String bucketName, java.lang.String pathPrefix, java.util.function.Function<java.lang.String,​FileType> fileTyper, java.util.function.Consumer<CosItem> consumer)
      Scan the COS bucket, feeding each returned item to the given consumer
      void signalStop()
      Tell the scanner to stop.
      void write​(java.lang.String bucketName, java.lang.String objectName, java.lang.String payload)
      Write the payload to the given bundleName as key
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • COSClient

        public COSClient​(java.util.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​(java.lang.String bucketName,
                          java.lang.String itemName,
                          java.util.function.Function<java.io.PushbackInputStream,​T> fn)
        Read the object using the given function
        Type Parameters:
        T -
        Parameters:
        bucketName -
        itemName -
        fn -
        Returns:
      • process

        public void process​(java.lang.String bucketName,
                            java.lang.String itemName,
                            java.util.function.Consumer<java.io.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​(java.lang.String bucketName,
                         java.lang.String pathPrefix,
                         java.util.function.Function<java.lang.String,​FileType> fileTyper,
                         java.util.function.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
      • write

        public void write​(java.lang.String bucketName,
                          java.lang.String objectName,
                          java.lang.String payload)
        Write the payload to the given bundleName as key
        Parameters:
        bundleName -
        payload -