Class CosScanner

  • All Implemented Interfaces:
    IResourceScanner

    public class CosScanner
    extends java.lang.Object
    implements IResourceScanner
    Active object to periodically scan COS buckets looking for new objects to load
    • Constructor Summary

      Constructors 
      Constructor Description
      CosScanner​(COSClient client, java.util.Collection<java.lang.String> buckets, DataAccess dataAccess, java.util.Set<FileType> fileTypes, java.lang.String pathPrefix, int scanIntervalMs)
      Public constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static FileType fileTyper​(java.lang.String itemName)
      Determine the type of the file based on the suffix
      protected void handle​(CosItem item)
      Process the item returned by the scan
      protected void heartbeat()
      Update the heartbeat on a (reasonably) regular basis to demonstrate this loader instance is still alive
      void init()
      Start the scanner
      void mainLoop()
      The main loop running inside this active object's thread
      protected void scan()
      Perform a scan for each of the configured buckets
      void signalStop()
      Tells the scanner to stop
      void waitForStop()
      Tell the main loop thread to stop if it hasn't already and wait a reasonable time for the main thread loop to terminate
      • Methods inherited from class java.lang.Object

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

    • Constructor Detail

      • CosScanner

        public CosScanner​(COSClient client,
                          java.util.Collection<java.lang.String> buckets,
                          DataAccess dataAccess,
                          java.util.Set<FileType> fileTypes,
                          java.lang.String pathPrefix,
                          int scanIntervalMs)
        Public constructor
        Parameters:
        client - not null
        buckets - the COS buckets to scan
        dataAccess - the data access layer for persisting items discovered during the scan
        fileTypes - set of FileType values accepted for processing
        prefix - only scan items with this prefix if set
        scanIntervalMs - the number of milliseconds between scans. -1 for automatic
    • Method Detail

      • waitForStop

        public void waitForStop()
        Description copied from interface: IResourceScanner
        Tell the main loop thread to stop if it hasn't already and wait a reasonable time for the main thread loop to terminate
        Specified by:
        waitForStop in interface IResourceScanner
      • mainLoop

        public void mainLoop()
        The main loop running inside this active object's thread
      • scan

        protected void scan()
        Perform a scan for each of the configured buckets
      • fileTyper

        protected static FileType fileTyper​(java.lang.String itemName)
        Determine the type of the file based on the suffix
        Parameters:
        itemName -
        Returns:
      • handle

        protected void handle​(CosItem item)
        Process the item returned by the scan
        Parameters:
        item -
      • heartbeat

        protected void heartbeat()
        Update the heartbeat on a (reasonably) regular basis to demonstrate this loader instance is still alive