Record Class StreamingUploadOptions

java.lang.Object
java.lang.Record
org.openehealth.ipf.commons.ihe.fhir.streaming.StreamingUploadOptions
Record Components:
engageAboveBytes - only request bodies larger than this are split; smaller ones are passed through byte for byte, so that ordinary requests behave exactly as they do without the filter. This is measured on the whole request body, i.e. metadata plus the base64 of all documents in it.
memoryThresholdBytes - extracted document content up to this size is kept in memory instead of being written to a temporary file. This is measured on a single decoded document and is therefore deliberately independent of engageAboveBytes; it is quite normal for it to be the larger of the two. Splitting the body is what avoids the expensive part — the base64 text and the decoded array that the FHIR parser would otherwise materialize — whereas a temporary file is only needed to also avoid a large contiguous heap allocation. Small documents therefore stay in memory and cause no disk I/O at all.
maxDocumentSizeBytes - maximum size of a single extracted document. Bounds how much temporary disk space one request can use.
tempDirectory - directory for temporary document files
inlineDocumentResources - types of the resources whose create interaction carries a document inline, i.e. the resource types below the FHIR base for which a POST is a candidate for the split. A POST to the FHIR base itself always is one, because a transaction bundle may contain anything. See MHD_INLINE_DOCUMENT_RESOURCES for the value that covers MHD.

public record StreamingUploadOptions(int engageAboveBytes, int memoryThresholdBytes, long maxDocumentSizeBytes, Path tempDirectory, Set<String> inlineDocumentResources) extends Record
Settings of the streaming upload split, see Base64SplittingFilter.

These are the only settings the split needs; whether it is active at all, and where the values come from, is up to whoever registers the filter. The defaults are meant to be usable as they are — see defaults().

Author:
Christian Ohr
  • Field Details

    • DEFAULT_ENGAGE_ABOVE_BYTES

      public static final int DEFAULT_ENGAGE_ABOVE_BYTES
      See Also:
    • DEFAULT_MEMORY_THRESHOLD_BYTES

      public static final int DEFAULT_MEMORY_THRESHOLD_BYTES
      See Also:
    • DEFAULT_MAX_DOCUMENT_SIZE_BYTES

      public static final long DEFAULT_MAX_DOCUMENT_SIZE_BYTES
      See Also:
    • MHD_INLINE_DOCUMENT_RESOURCES

      public static final Set<String> MHD_INLINE_DOCUMENT_RESOURCES
      The resource types that carry a document inline in MHD: only ITI-105 does, as a DocumentReference with the document in content.attachment.data. ITI-65 arrives as a transaction bundle posted to the FHIR base instead and is therefore covered without being named here. The remaining MHD transactions that accept a DocumentReference body — the ITI-57 based updates — are metadata-only, so they are of no interest here even though they are uploads.
  • Constructor Details

    • StreamingUploadOptions

      public StreamingUploadOptions(int engageAboveBytes, int memoryThresholdBytes, long maxDocumentSizeBytes, Path tempDirectory, Set<String> inlineDocumentResources)
      Creates an instance of a StreamingUploadOptions record class.
      Parameters:
      engageAboveBytes - the value for the engageAboveBytes record component
      memoryThresholdBytes - the value for the memoryThresholdBytes record component
      maxDocumentSizeBytes - the value for the maxDocumentSizeBytes record component
      tempDirectory - the value for the tempDirectory record component
      inlineDocumentResources - the value for the inlineDocumentResources record component
  • Method Details

    • defaults

      public static StreamingUploadOptions defaults()
      Returns:
      options that split MHD uploads into the JVM temporary directory, with the thresholds the measurements this implementation was built on found reasonable
    • defaultTempDirectory

      public static Path defaultTempDirectory()
      Returns:
      the JVM temporary directory
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • engageAboveBytes

      public int engageAboveBytes()
      Returns the value of the engageAboveBytes record component.
      Returns:
      the value of the engageAboveBytes record component
    • memoryThresholdBytes

      public int memoryThresholdBytes()
      Returns the value of the memoryThresholdBytes record component.
      Returns:
      the value of the memoryThresholdBytes record component
    • maxDocumentSizeBytes

      public long maxDocumentSizeBytes()
      Returns the value of the maxDocumentSizeBytes record component.
      Returns:
      the value of the maxDocumentSizeBytes record component
    • tempDirectory

      public Path tempDirectory()
      Returns the value of the tempDirectory record component.
      Returns:
      the value of the tempDirectory record component
    • inlineDocumentResources

      public Set<String> inlineDocumentResources()
      Returns the value of the inlineDocumentResources record component.
      Returns:
      the value of the inlineDocumentResources record component