Class ImmediateLocalFileReader


  • public class ImmediateLocalFileReader
    extends java.lang.Object
    Reads local files directly and processes them to the ResourceHandler 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
    • 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 handler
        fileType - the file type this read is responsible for processing
        baseDirectory -
        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 processed
        resource - parsed from the resource_bundle being processed
        lineNumber - the line number of this resource in the source
        line - the original resource string, for logging if we need to