Package com.ibm.fhir.bucket.scanner
Class CosReader
- java.lang.Object
-
- com.ibm.fhir.bucket.scanner.CosReader
-
public class CosReader extends Object
Grabs work from the bucket database and dispatches items to the thread pool.
-
-
Constructor Summary
Constructors Constructor Description CosReader(ExecutorService commonPool, FileType fileType, CosClient client, Consumer<ResourceEntry> resourceHandler, int maxInflight, DataAccess da, boolean incremental, int recycleSeconds, boolean incrementalExact, int 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, String line)
Process the resource parsed from the input streamvoid
processNDJSON(BucketLoaderJob job, BufferedReader br)
Read the resources from the given readerprotected void
safeSleep(long millis)
Sleep this thread for the given millisecondsvoid
signalStop()
Tell the main thread of this active object that it should start shutting downList<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
-
CosReader
public CosReader(ExecutorService commonPool, FileType fileType, CosClient client, Consumer<ResourceEntry> resourceHandler, int maxInflight, DataAccess da, boolean incremental, int recycleSeconds, boolean incrementalExact, int bundleCostFactor)
Public constructor- Parameters:
commonPool
- thread pool shared by the readers and request handlerfileType
- the file type this read is responsible for processingclient
-resourceHandler
-poolSize
-da
-incremental
-recycleSeconds
-
-
-
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
-
safeSleep
protected void safeSleep(long millis)
Sleep this thread for the given milliseconds- Parameters:
millis
-
-
markJobDone
protected void markJobDone(BucketLoaderJob job)
Callback when the last record in the job completes- Parameters:
job
-
-
processNDJSON
public void processNDJSON(BucketLoaderJob job, BufferedReader br)
Read the resources from the given reader- Parameters:
is
-
-
process
protected boolean process(BucketLoaderJob job, Resource resource, int lineNumber, String line)
Process the resource parsed from the input stream- 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 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
-
-