Class SlowQueryReport.PoolStatistics

java.lang.Object
org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.PoolStatistics
Enclosing class:
SlowQueryReport

protected static class SlowQueryReport.PoolStatistics extends Object
The query statistics of one pool: the map its connections book into and the name the map is published under.

The store refers to the pool only weakly. The name identifies the pool and must be unique among live pools - Tomcat names every pool it manages, and the default name of a programmatic pool is unique as well - so the store can outlive a pool abandoned without closing without pinning that pool, together with everything it reaches: its queues, its pooled connections and their open physical sessions. The weak reference is what tells a live holder of the name from an abandoned pool's leftover store.

  • Constructor Details

    • PoolStatistics

      protected PoolStatistics(ConnectionPool pool, String name)
      Creates the statistics store of one pool.
      Parameters:
      pool - the pool the store belongs to
      name - the name the store is published under
  • Method Details

    • getPool

      protected ConnectionPool getPool()
      Returns the pool this store belongs to while it is still reachable.
      Returns:
      the owning pool, or null once it has been collected
    • getName

      protected String getName()
      Returns the name this store is published under.
      Returns:
      the pool name recorded when the store was created
    • isReleased

      protected boolean isReleased()
      Returns whether this store has been released with the close of its pool.
      Returns:
      true if the pool's close has given this store up
    • getJmxState

      protected SlowQueryReportJmx.PoolJmx getJmxState()
      Returns what the reporting subclass has published for this pool with JMX.
      Returns:
      the pool's JMX state, or null while no borrow of the pool has needed one or after the store has been released with its pool's close
    • setJmxState

      protected void setJmxState(SlowQueryReportJmx.PoolJmx jmxState)
      Records what the reporting subclass has published for this pool, so that the release of this store gives it up. Callers publish one state per store under this store's monitor (see SlowQueryReportJmx).
      Parameters:
      jmxState - the state to hang from this store
    • release

      protected void release()
      Releases the store with the close of its pool: later reads of its statistics answer as if nothing were published, and the JMX state published for this pool is given up with it.

      Whether a state exists is decided under this store's monitor, which is the one a borrow publishes a new state under, so no state can be created behind the release and left for nothing to give up. The state's own release then runs outside the monitor: it gives the MBean back to the MBeanServer, and a close has no business holding the store while it does.

    • getQueryStats

      Returns the statistics map, or null once the store has been released with the close of its pool.
      Returns:
      this pool's query statistics