By default each DurationFilter is initialized using the following
LogManager configuration properties where <filter-name> refers to the
fully qualified class name of the handler. If properties are not defined, or
contain invalid values, then the specified default values are used.
1000)
java.time package is available then
an ISO-8601 duration format of PnDTnHnMn.nS can be used as the value.
The suffixes of "D", "H", "M" and "S" are for days, hours, minutes and
seconds. The suffixes must occur in order. The seconds can be specified with
a fractional component to declare milliseconds. (defaults to PT15M)
For example, the settings to limit MailHandler with a default
capacity to only send a maximum of two email messages every six minutes would
be as follows:
com.sun.mail.util.logging.MailHandler.filter = com.sun.mail.util.logging.DurationFilter
com.sun.mail.util.logging.MailHandler.capacity = 1000
com.sun.mail.util.logging.DurationFilter.records = 2L * 1000L
com.sun.mail.util.logging.DurationFilter.duration = PT6M
| Modifier and Type | Field and Description |
|---|---|
| private long | count
The number of records seen for the current duration. |
| private final long | duration
The duration in milliseconds used to determine the rate. |
| private long | peak
The most recent record time seen for the current duration. |
| private final long | records
The number of expected records per duration. |
| private long | start
The start time for the current duration. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DurationFilter(final long
the number of records per duration. records, final long the number of milliseconds to suppress log records from
being published. duration)Creates the filter using the given properties. |
| Modifier and Type | Method and Description |
|---|---|
| private synchronized boolean | Returns: true if accepted false otherwise.the log record milliseconds. millis)Determines if the record is loggable by time. |
| private static long | Returns: a valid duration.the duration to check. duration)Converts the duration to a valid duration. |
| private static long | Returns: a valid number of record count.the record count. records)Converts record count to a valid record count. |
| protected DurationFilter | Returns: a copy of this filter.Overrides java. |
| public boolean | Returns: true if equal otherwise false.the given object. obj)Overrides java. |
| public int | Returns: hash code for this filter.Overrides java. |
| private long | |
| public boolean | Returns: true if the filter is idle; false otherwise.Determines if this filter is able to accept the maximum number of log records for this instant in time. |
| public boolean | Returns: true if allowed; false otherwise.the log record to check. record)Implements java. |
| public boolean | Returns: true if the filter is not saturated; false otherwise.Determines if this filter will accept log records for this instant in time. |
| private boolean | Returns: true if the entry is a time entry.the suffix property. suffix, final String the value of the property. value)Determines if the given suffix can be a time unit and the value is encoded as an ISO ISO-8601 duration format. |
| private static long | Returns: x times y.the first value. x, final long the second value. y)Multiply and check for overflow. |
| private boolean | Returns: true if not saturated or bellow the rate.the number of records allowed to be under the rate. limit, final long the current time in milliseconds. millis)Checks if this filter is not saturated or bellow a maximum rate. |
| private static String[] | Returns: an array of long tokens, never empty.the expression or value. value)Parse any long value or multiplication expressions into tokens. |
| public String | Returns: a string representation of this filter.Overrides java. |
| count | back to summary |
|---|---|
| private long count The number of records seen for the current duration. This value negative if saturated. Zero is considered saturated but is reserved for recording the first duration. | |
| duration | back to summary |
|---|---|
| private final long duration The duration in milliseconds used to determine the rate. The duration is also used as the amount of time that the filter will not allow records when saturated. | |
| peak | back to summary |
|---|---|
| private long peak The most recent record time seen for the current duration. | |
| records | back to summary |
|---|---|
| private final long records The number of expected records per duration. | |
| start | back to summary |
|---|---|
| private long start The start time for the current duration. | |
| DurationFilter | back to summary |
|---|---|
| public DurationFilter() Creates the filter using the default properties. | |
| DurationFilter | back to summary |
|---|---|
| public DurationFilter(final long records, final long duration) Creates the filter using the given properties. Default values are used if any of the given values are outside the allowed range.
| |
| accept | back to summary |
|---|---|
| private synchronized boolean accept(final long millis) Determines if the record is loggable by time.
| |
| checkDuration | back to summary |
|---|---|
| private static long checkDuration(final long duration) Converts the duration to a valid duration. If the value is out of bounds then the default duration is used.
| |
| checkRecords | back to summary |
|---|---|
| private static long checkRecords(final long records) Converts record count to a valid record count. If the value is out of bounds then the default record count is used.
| |
| clone | back to summary |
|---|---|
| protected DurationFilter clone() throws CloneNotSupportedException Overrides java. Creates a copy of this filter that retains the filter settings but does not include the current filter state. The newly create clone acts as if it has never seen any records.
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Determines if this filter is equal to another filter. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hash code value for this filter.
| |
| initLong | back to summary |
|---|---|
| private long initLong(final String suffix) Reads a long value or multiplication expression from the LogManager. If the value can not be parsed or is not defined then Long.MIN_VALUE is returned.
| |
| isIdle | back to summary |
|---|---|
| public boolean isIdle() Determines if this filter is able to accept the maximum number of log records for this instant in time. The result is a best-effort estimate and should be considered out of date as soon as it is produced. This method is designed for use in monitoring the state of this filter.
| |
| isLoggable | back to summary |
|---|---|
| public boolean isLoggable(final LogRecord record) Implements java. Check if the given log record should be published. This method will modify the internal state of this filter.
| |
| isLoggable | back to summary |
|---|---|
| public boolean isLoggable() Determines if this filter will accept log records for this instant in time. The result is a best-effort estimate and should be considered out of date as soon as it is produced. This method is designed for use in monitoring the state of this filter.
| |
| isTimeEntry | back to summary |
|---|---|
| private boolean isTimeEntry(final String suffix, final String value) Determines if the given suffix can be a time unit and the value is encoded as an ISO ISO-8601 duration format.
| |
| multiplyExact | back to summary |
|---|---|
| private static long multiplyExact(final long x, final long y) Multiply and check for overflow. This can be replaced with
| |
| test | back to summary |
|---|---|
| private boolean test(final long limit, final long millis) Checks if this filter is not saturated or bellow a maximum rate.
| |
| tokenizeLongs | back to summary |
|---|---|
| private static String[] tokenizeLongs(final String value) Parse any long value or multiplication expressions into tokens.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this filter. The result is a best-effort estimate and should be considered out of date as soon as it is produced. | |