Package opennlp.tools.util
Record Class ResourceInstaller.Limits
java.lang.Object
java.lang.Record
opennlp.tools.util.ResourceInstaller.Limits
- Record Components:
connectTimeout- How long to wait for a connection to be established. Must be positive.readTimeout- How long to wait for data on an established connection. Must be positive.maxRedirects- How many http redirects to follow before failing. Must not be negative; zero rejects all redirects.maxDownloadBytes- The largest download accepted, in bytes. Must be positive.maxExpandedBytes- The largest expanded byte count accepted. For gzip content, this counts the entire decompressed stream; otherwise, it counts installed file content. Must be positive.maxEntries- The largest number of archive entries accepted, counting every entry including directories, so an archive of many tiny files cannot exhaust directory entries while staying under the byte limits. Must be positive.maxExpansionRatio- The largest expanded size accepted per compressed byte of a source, so a small archive cannot expand to the whole expansion limit. Applies to gzip and zip content; a source may always expand to 1048576L bytes regardless of it. Must be positive.
- Enclosing class:
ResourceInstaller
public static record ResourceInstaller.Limits(Duration connectTimeout, Duration readTimeout, int maxRedirects, long maxDownloadBytes, long maxExpandedBytes, long maxEntries, long maxExpansionRatio)
extends Record
Safety limits and network behavior for one installation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCollects limit values and validates them onResourceInstaller.Limits.Builder.build(). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DurationThe field for theconnectTimeoutrecord component.static final ResourceInstaller.LimitsThe limits applied when none are given: 20 second connect timeout, 60 second read timeout, at most 5 redirects, a 1 GiB download limit, a 4 GiB expansion limit, 100000 archive entries, and an expansion ratio of 100.static final StringThe system property overriding the default download limit in bytes.static final StringThe system property overriding the default archive entry limit.static final StringThe system property overriding the default expansion limit in bytes.static final StringThe system property overriding the default expansion ratio.private final longThe field for themaxDownloadBytesrecord component.private final longThe field for themaxEntriesrecord component.private final longThe field for themaxExpandedBytesrecord component.private final longThe field for themaxExpansionRatiorecord component.private final intThe field for themaxRedirectsrecord component.private final DurationThe field for thereadTimeoutrecord component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Starts fromDEFAULTso a caller can state only the limits that differ from it, instead of repeating all seven in the canonical constructor.Returns the value of theconnectTimeoutrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longReturns the value of themaxDownloadBytesrecord component.longReturns the value of themaxEntriesrecord component.longReturns the value of themaxExpandedBytesrecord component.longReturns the value of themaxExpansionRatiorecord component.intReturns the value of themaxRedirectsrecord component.Returns the value of thereadTimeoutrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
connectTimeout
The field for theconnectTimeoutrecord component. -
readTimeout
The field for thereadTimeoutrecord component. -
maxRedirects
private final int maxRedirectsThe field for themaxRedirectsrecord component. -
maxDownloadBytes
private final long maxDownloadBytesThe field for themaxDownloadBytesrecord component. -
maxExpandedBytes
private final long maxExpandedBytesThe field for themaxExpandedBytesrecord component. -
maxEntries
private final long maxEntriesThe field for themaxEntriesrecord component. -
maxExpansionRatio
private final long maxExpansionRatioThe field for themaxExpansionRatiorecord component. -
MAX_DOWNLOAD_BYTES_PROPERTY
The system property overriding the default download limit in bytes.- See Also:
-
MAX_EXPANDED_BYTES_PROPERTY
The system property overriding the default expansion limit in bytes.- See Also:
-
MAX_ENTRIES_PROPERTY
The system property overriding the default archive entry limit.- See Also:
-
MAX_EXPANSION_RATIO_PROPERTY
The system property overriding the default expansion ratio.- See Also:
-
DEFAULT
The limits applied when none are given: 20 second connect timeout, 60 second read timeout, at most 5 redirects, a 1 GiB download limit, a 4 GiB expansion limit, 100000 archive entries, and an expansion ratio of 100. Each limit can be raised or lowered at startup through its system property (MAX_DOWNLOAD_BYTES_PROPERTY,MAX_EXPANDED_BYTES_PROPERTY,MAX_ENTRIES_PROPERTY,MAX_EXPANSION_RATIO_PROPERTY), read once at class load; a value that is absent, not a number, or not positive falls back to the built-in default.
-
-
Constructor Details
-
Limits
public Limits(Duration connectTimeout, Duration readTimeout, int maxRedirects, long maxDownloadBytes, long maxExpandedBytes, long maxEntries, long maxExpansionRatio) Validates the limit values before constructing an instance.- Parameters:
connectTimeout- How long to wait for a connection to be established.readTimeout- How long to wait for data on an established connection.maxRedirects- How many http redirects to follow before failing.maxDownloadBytes- The largest download accepted, in bytes.maxExpandedBytes- The largest expanded byte count accepted.maxEntries- The largest number of archive entries accepted.maxExpansionRatio- The largest expanded size accepted per compressed byte.- Throws:
IllegalArgumentException- Thrown if either timeout isnull, zero, or negative, a limit is not positive, or the redirect limit is negative.
-
-
Method Details
-
builder
Starts fromDEFAULTso a caller can state only the limits that differ from it, instead of repeating all seven in the canonical constructor.- Returns:
- A builder holding the default limits. Not
null.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
connectTimeout
Returns the value of theconnectTimeoutrecord component.- Returns:
- the value of the
connectTimeoutrecord component
-
readTimeout
Returns the value of thereadTimeoutrecord component.- Returns:
- the value of the
readTimeoutrecord component
-
maxRedirects
public int maxRedirects()Returns the value of themaxRedirectsrecord component.- Returns:
- the value of the
maxRedirectsrecord component
-
maxDownloadBytes
public long maxDownloadBytes()Returns the value of themaxDownloadBytesrecord component.- Returns:
- the value of the
maxDownloadBytesrecord component
-
maxExpandedBytes
public long maxExpandedBytes()Returns the value of themaxExpandedBytesrecord component.- Returns:
- the value of the
maxExpandedBytesrecord component
-
maxEntries
public long maxEntries()Returns the value of themaxEntriesrecord component.- Returns:
- the value of the
maxEntriesrecord component
-
maxExpansionRatio
public long maxExpansionRatio()Returns the value of themaxExpansionRatiorecord component.- Returns:
- the value of the
maxExpansionRatiorecord component
-