Class PerformanceSection

java.lang.Object
org.tquadrat.foundation.perflog.PerformanceSection

@ClassVersion(sourceVersion="$Id: PerformanceSection.java 1258 2026-06-04 18:33:06Z tquadrat $") @API(status=STABLE, since="0.25.0") public final class PerformanceSection extends Object

This class describes a "Performance Section".

Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: PerformanceSection.java 1258 2026-06-04 18:33:06Z tquadrat $
Since:
0.25.0
UML Diagram
UML Diagram for "org.tquadrat.foundation.perflog.PerformanceSection"

UML Diagram for "org.tquadrat.foundation.perflog.PerformanceSection"

UML Diagram for "org.tquadrat.foundation.perflog.PerformanceSection"
  • Field Details

    • m_Description

      private final String m_Description
      The description for the performance section.
    • m_Ignore

      private boolean m_Ignore
      The flog that controls whether this performance section is ignored.
    • m_SendReportForAbort

      private boolean m_SendReportForAbort
      The flag that controls whether reports for this performance section are sent in case of an abort.
    • m_SendReportOnlyForExceededThreshold

      The flag that controls whether reports for this performance section are sent only when the threshold was exceeded.
    • m_Name

      The unique name of the performance section.
    • m_ReadGuard

      private final AutoLock m_ReadGuard
      The guard for read operations.
    • m_Threshold

      The threshold time. A value of null means that there is no threshold for this performance section.

    • m_Timeout

      The timeout time. A value of null means that there is no timeout for this performance section.

    • m_WriteGuard

      private final AutoLock m_WriteGuard
      The guard for write operations.
  • Constructor Details

    • PerformanceSection

      public PerformanceSection(String name, String description, Long threshold, Long timeout, PerformanceSection.PerformanceSectionFlags... flags)
      Creates a new instance of PerformanceSection.
      Parameters:
      name - The unique name of the performance section.
      description - The description for the performance section; can be null.
      threshold - The threshold time in milliseconds; a value of null means that no threshold was defined for this performance section. A value less than 1 is invalid and causes a ValidationException to be thrown.
      timeout - The timeout time in milliseconds; a value of null means that no timeout was defined for this performance section. A value less than 1 is invalid and causes a ValidationException to be thrown. The timeout value must be greater than the threshold value, if provided.
      flags - Provides the configuration for this performance section.
    • PerformanceSection

      Creates a new instance of PerformanceSection.
      Parameters:
      name - The unique name of the performance section.
      description - The description for the performance section; can be null.
      threshold - The threshold time; a value of null means that no threshold was defined for this performance section. A value of 0 is invalid and causes a ValidationException to be thrown.
      timeout - The timeout time; a value of null means that no timeout was defined for this performance section. A value of 0 is invalid and causes a ValidationException to be thrown. The timeout value must be greater than the threshold value, if provided.
      flags - Provides the configuration for this performance section.
  • Method Details

    • equals

      public final boolean equals(Object o)

      Two instances of PerformanceSection are equal if their names are equal.

      Overrides:
      equals in class Object
    • getDescription

      public final String getDescription()
      Returns the description for the performance section.
      Returns:
      The description for the performance section.
    • getName

      Returns the name of the performance section.
      Returns:
      The name of the performance section.
    • getThreshold

      public final Optional<TimeValue> getThreshold()
      Returns the threshold for this performance section.
      Returns:
      An instance of OptionalLong that holds the threshold in milliseconds.
    • getTimeout

      public final Optional<TimeValue> getTimeout()
      Returns the timeout for this performance section.
      Returns:
      An instance of OptionalLong that holds the timeout in milliseconds.
    • hashCode

      public final int hashCode()

      Two instances of PerformanceSection are equal if their names are equal.

      Overrides:
      hashCode in class Object
    • isIgnored

      public final boolean isIgnored()
      Returns the flag that controls whether this performance section is ignored.
      Returns:
      true if the performance section is currently ignored, false if the performance section is currently observed.
    • isSendingReportForAbort

      public final boolean isSendingReportForAbort()
      Returns the flag that indicates whether reports should be sent if a PerformanceTracker is aborted.
      Returns:
      true if a report should be sent, false if not.
      See Also:
    • isSendingReportOnlyForExceededThreshold

      Returns the flag that indicates whether reports should be sent only if the threshold was exceeded.
      Returns:
      true if a report should be sent only when the threshold was exceeded, false if a report should be sent always.
    • setIgnoreFlag

      public final void setIgnoreFlag(boolean flag)
      Sets the flag that controls whether this performance section is ignored.
      Parameters:
      flag - true if the performance section should be ignored from now on, false if it has to be observed in future.
    • setSendReportForAbortFlag

      public final void setSendReportForAbortFlag(boolean flag)
      Sets the flag that controls whether reports are sent also for aborted performance trackers.
      Parameters:
      flag - true if reports should be sent, false if not.
    • setSendReportOnlyForExceededThresholdFlag

      public final void setSendReportOnlyForExceededThresholdFlag(boolean flag)
      Sets the flag that controls whether reports are sent only when the threshold was exceeded.
      Parameters:
      flag - true if reports should be sent only when the threshold was exceeded, false if reports should be sent always.
    • setThreshold

      public final void setThreshold(TimeValue value)
      Sets the threshold and enables it.
      Parameters:
      value - The new threshold value; must be greater than 0.
    • setTimeout

      public final void setTimeout(TimeValue value)
      Sets the timeout and enables it.
      Parameters:
      value - The new timeout value; must be greater than 0.
    • switchOffThreshold

      public final void switchOffThreshold()
      Disables the threshold for this performance section.
    • switchOffTimeout

      public final void switchOffTimeout()
      Disables the timeout for this performance section.
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • validateThreshold

      Validates the given threshold.

      The value must be greater than 0, and, if the timeout is not null, it must be less than the timeout.

      Note:
      • The method is called from inside a guarded area only!
      Parameters:
      value - The value for the threshold.
      Returns:
      The given value.
      Throws:
      IllegalArgumentException - The value is invalid.
    • validateThresholdAndTimeout

      private static final TimeValue validateThresholdAndTimeout(TimeValue retValue, TimeValue threshold, TimeValue timeout) throws IllegalArgumentException

      Validates threshold and timeout.

      Both values must be either -1 or greater than 0, and, if the threshold is not -1, the timeout must be greater than the threshold.

      Parameters:
      retValue - The return value.
      threshold - The value for the threshold.
      timeout - The value for the timeout.
      Returns:
      The return value.
      Throws:
      IllegalArgumentException - A value is invalid.
    • validateTimeout

      Validates the given timeout.

      The value must be greater than 0, and, if the threshold is not null, the timeout must be greater than the threshold.

      Note:
      • The method is called from inside a guarded area only!
      Parameters:
      value - The value for the timeout.
      Returns:
      The given value.
      Throws:
      IllegalArgumentException - The value is invalid.