Class ImmediateLocalFileReader
- java.lang.Object
-
- org.linuxforhealth.fhir.bucket.scanner.ImmediateLocalFileReader
-
public class ImmediateLocalFileReader extends java.lang.Object
Reads local files directly and processes them to theResourceHandler
for processing. Does not rely on COS or the fhirbucket database. Useful for simpler load testing and loading something like a development database with test data
-
-
Constructor Summary
Constructors Constructor Description ImmediateLocalFileReader(java.util.concurrent.ExecutorService commonPool, java.util.Set<FileType> fileTypes, java.lang.String baseDirectory, java.util.function.Consumer<ResourceEntry> resourceHandler, int maxInflight, double bundleCostFactor)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
init()
start the allocation threadvoid
mainAllocationLoop()
The main loop of this active objectprotected void
markJobDone(BucketLoaderJob job)
Callback when the last record in the job completesprotected boolean
process(BucketLoaderJob job, Resource resource, int lineNumber, java.lang.String line)
Process the resource parsed from the input stream.void
processNDJSON(BucketLoaderJob job, java.io.BufferedReader br)
Read the resources from the given readervoid
signalStop()
Tell the main thread of this active object that it should start shutting downjava.util.List<OperationOutcome.Issue>
validateInput(Resource resource)
Validate the input resource and throw if there are validation errorsvoid
waitForStop()
Tell the main loop thread to stop
-
-
-
Constructor Detail
-
ImmediateLocalFileReader
public ImmediateLocalFileReader(java.util.concurrent.ExecutorService commonPool, java.util.Set<FileType> fileTypes, java.lang.String baseDirectory, java.util.function.Consumer<ResourceEntry> resourceHandler, int maxInflight, double bundleCostFactor)
Public constructor- Parameters:
commonPool
- thread pool shared by the readers and request handlerfileType
- the file type this read is responsible for processingbaseDirectory
-resourceHandler
-poolSize
-incremental
-recycleSeconds
-incrementalExact
-bundleCostFactor
-
-
-
Method Detail
-
signalStop
public void signalStop()
Tell the main thread of this active object that it should start shutting down
-
waitForStop
public void waitForStop()
Tell the main loop thread to stop
-
init
public void init()
start the allocation thread
-
mainAllocationLoop
public void mainAllocationLoop()
The main loop of this active object
-
markJobDone
protected void markJobDone(BucketLoaderJob job)
Callback when the last record in the job completes- Parameters:
job
-
-
processNDJSON
public void processNDJSON(BucketLoaderJob job, java.io.BufferedReader br)
Read the resources from the given reader- Parameters:
is
-
-
process
protected boolean process(BucketLoaderJob job, Resource resource, int lineNumber, java.lang.String line)
Process the resource parsed from the input stream. When processing NDJSON the lineNumber and line are logged when an error occurs to help locate the corresponding entry in the file. When processing JSON files, lineNumber doesn't but should be set to 0. The line value can be blank.- Parameters:
details
- of the job being processedresource
- parsed from the resource_bundle being processedlineNumber
- the line number of this resource in the sourceline
- the original resource string, for logging if we need to
-
validateInput
public java.util.List<OperationOutcome.Issue> validateInput(Resource resource) throws FHIRValidationException, FHIROperationException
Validate the input resource and throw if there are validation errors- Parameters:
resource
-- Throws:
FHIRValidationException
FHIROperationException
-
-