Class SlowQueryReport.QueryStats

  • Enclosing class:
    SlowQueryReport

    public static class SlowQueryReport.QueryStats
    extends java.lang.Object
    Holds timing and invocation statistics for a single SQL query.
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryStats​(java.lang.String query)
      Creates a new QueryStats instance for the given SQL query.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(long invocationTime, long now)
      Records a successful query invocation, updating min/max/total timing statistics.
      boolean equals​(java.lang.Object other)  
      void failure​(long invocationTime, long now)
      Records a failed query invocation, updating timing statistics and failure count.
      javax.management.openmbean.CompositeDataSupport getCompositeData​(javax.management.openmbean.CompositeType type)
      Returns the query statistics as JMX CompositeData.
      static java.lang.String[] getFieldDescriptions()
      Returns the descriptions of the fields in the composite data representation.
      static java.lang.String[] getFieldNames()
      Returns the names of the fields in the composite data representation.
      static javax.management.openmbean.OpenType<?>[] getFieldTypes()
      Returns the JMX OpenType of each field in the composite data representation.
      long getMaxInvocationDate()
      Returns the timestamp when the longest query execution occurred.
      long getMaxInvocationTime()
      Returns the longest time this query took to execute.
      long getMinInvocationDate()
      Returns the timestamp when the shortest query execution occurred.
      long getMinInvocationTime()
      Returns the shortest time this query took to execute.
      int getNrOfInvocations()
      Returns the total number of times this query has been invoked.
      java.lang.String getQuery()
      Returns the SQL query string for these statistics.
      long getTotalInvocationTime()
      Returns the total time spent executing this query across all invocations.
      int hashCode()  
      boolean isOlderThan​(SlowQueryReport.QueryStats other)
      Returns whether this query was last invoked before the given query stats.
      void prepare​(long invocationTime)
      Records the time taken to prepare this query.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • QueryStats

        public QueryStats​(java.lang.String query)
        Creates a new QueryStats instance for the given SQL query.
        Parameters:
        query - the SQL query string
    • Method Detail

      • getFieldNames

        public static java.lang.String[] getFieldNames()
        Returns the names of the fields in the composite data representation.
        Returns:
        the field names
      • getFieldDescriptions

        public static java.lang.String[] getFieldDescriptions()
        Returns the descriptions of the fields in the composite data representation.
        Returns:
        the field descriptions
      • getFieldTypes

        public static javax.management.openmbean.OpenType<?>[] getFieldTypes()
        Returns the JMX OpenType of each field in the composite data representation.
        Returns:
        the field types
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getCompositeData

        public javax.management.openmbean.CompositeDataSupport getCompositeData​(javax.management.openmbean.CompositeType type)
                                                                         throws javax.management.openmbean.OpenDataException
        Returns the query statistics as JMX CompositeData.
        Parameters:
        type - the composite type definition
        Returns:
        the composite data representation of this query's statistics
        Throws:
        javax.management.openmbean.OpenDataException - if the data cannot be converted
      • prepare

        public void prepare​(long invocationTime)
        Records the time taken to prepare this query.
        Parameters:
        invocationTime - the time in milliseconds to prepare the query
      • add

        public void add​(long invocationTime,
                        long now)
        Records a successful query invocation, updating min/max/total timing statistics.
        Parameters:
        invocationTime - the time in milliseconds the query took
        now - the current timestamp in milliseconds
      • failure

        public void failure​(long invocationTime,
                            long now)
        Records a failed query invocation, updating timing statistics and failure count.
        Parameters:
        invocationTime - the time in milliseconds the query took before failing
        now - the current timestamp in milliseconds
      • getQuery

        public java.lang.String getQuery()
        Returns the SQL query string for these statistics.
        Returns:
        the SQL query string
      • getNrOfInvocations

        public int getNrOfInvocations()
        Returns the total number of times this query has been invoked.
        Returns:
        the number of invocations
      • getMaxInvocationTime

        public long getMaxInvocationTime()
        Returns the longest time this query took to execute.
        Returns:
        the maximum invocation time in milliseconds
      • getMaxInvocationDate

        public long getMaxInvocationDate()
        Returns the timestamp when the longest query execution occurred.
        Returns:
        the timestamp in milliseconds of the maximum invocation
      • getMinInvocationTime

        public long getMinInvocationTime()
        Returns the shortest time this query took to execute.
        Returns:
        the minimum invocation time in milliseconds
      • getMinInvocationDate

        public long getMinInvocationDate()
        Returns the timestamp when the shortest query execution occurred.
        Returns:
        the timestamp in milliseconds of the minimum invocation
      • getTotalInvocationTime

        public long getTotalInvocationTime()
        Returns the total time spent executing this query across all invocations.
        Returns:
        the total invocation time in milliseconds
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • isOlderThan

        public boolean isOlderThan​(SlowQueryReport.QueryStats other)
        Returns whether this query was last invoked before the given query stats.
        Parameters:
        other - the other query statistics to compare against
        Returns:
        true if this query's last invocation is older