Package com.ibm.fhir.bucket.scanner
Class CosScanner
- java.lang.Object
-
- com.ibm.fhir.bucket.scanner.CosScanner
-
public class CosScanner extends Object
Active object to periodically scan COS buckets looking for new objects to load
-
-
Field Summary
Fields Modifier and Type Field Description static longHEARTBEAT_INTERVAL_MS
-
Constructor Summary
Constructors Constructor Description CosScanner(COSClient client, Collection<String> buckets, DataAccess dataAccess, Set<FileType> fileTypes, String pathPrefix, int scanIntervalMs)Public constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static FileTypefileTyper(String itemName)Determine the type of the file based on the suffixprotected voidhandle(CosItem item)Process the item returned by the scanprotected voidheartbeat()Update the heartbeat on a (reasonably) regular basis to demonstrate this loader instance is still alivevoidinit()Run the scanner threadvoidmainLoop()The main loop running inside this active object's threadprotected voidsafeSleep(long millis)Sleep this thread for the given millisecondsprotected voidscan()Perform a scan for each of the configured bucketsvoidsignalStop()Tell the active object to stop any new work, but existing work can completevoidwaitForStop()Tell the main loop thread to stop if it hasn't already and wait a reasonable time for the main thread loop to terminate
-
-
-
Field Detail
-
HEARTBEAT_INTERVAL_MS
public static final long HEARTBEAT_INTERVAL_MS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CosScanner
public CosScanner(COSClient client, Collection<String> buckets, DataAccess dataAccess, Set<FileType> fileTypes, String pathPrefix, int scanIntervalMs)
Public constructor- Parameters:
client-buckets- the COS buckets to scandataAccess- the data access layer for persisting items discovered during the scanfileTypes- set of FileType values accepted for processingprefix- only scan items with this prefix if setscanIntervalMs- the number of milliseconds between scans. -1 for automatic
-
-
Method Detail
-
init
public void init()
Run the scanner thread
-
signalStop
public void signalStop()
Tell the active object to stop any new work, but existing work can complete
-
waitForStop
public 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
-
mainLoop
public void mainLoop()
The main loop running inside this active object's thread
-
safeSleep
protected void safeSleep(long millis)
Sleep this thread for the given milliseconds- Parameters:
millis-
-
scan
protected void scan()
Perform a scan for each of the configured buckets
-
fileTyper
protected static FileType fileTyper(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
-
-