Class SlowQueryReportJmx.PoolJmx
- java.lang.Object
-
- org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx.PoolJmx
-
- Enclosing class:
- SlowQueryReportJmx
protected static class SlowQueryReportJmx.PoolJmx extends java.lang.ObjectEverything this class publishes for one pool: the notification broadcaster its clients attach their listeners to and, in thenotifyPool=falsemode, the ObjectName the pool's MBean occupies.The state hangs from the pool's statistics store (see
SlowQueryReport.PoolStatistics.getJmxState()), which is 1:1 with the pool, and nothing a pool published can be given up by another pool's close. It is built by the first borrower that needs it and given up by the release of the store it hangs from, which is what the close of the pool is.The publication is attempted once per pool: JMX is a best-effort management channel, so a refusal is logged and not retried by later borrows. Publication and release are serialised against each other by this object's monitor, and the MBeanServer is called outside it: a borrow either publishes, finds that the attempt has already been made, or finds the state already superseded by the pool's close - in which case the borrow gives back the publication it just made. A published MBean can therefore never outlive the state that published it, and the ObjectName a release gives up is the one this state recorded when it published, whatever class or
objectNameproperty the interceptor instance running the close happens to carry.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPoolJmx(java.lang.String poolName)Creates the JMX state of one pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanbeginPublication()Decides whether the calling borrow is to make this pool's one publication attempt.protected javax.management.NotificationBroadcasterSupportbroadcaster()Returns the broadcaster all interceptor instances of this pool send their notifications through, building it on the first need.protected java.lang.StringgetPoolName()Returns the name of the pool this state belongs to.protected booleanisReleased()Returns whether the close of this pool has given this state up.protected booleanpublished(javax.management.ObjectName oname)Records a publication the MBeanServer accepted.protected javax.management.ObjectNamepublishedUnder()Returns the ObjectName this pool's MBean is published under.protected voidreleased()Gives up everything this state holds: the ObjectName the pool's MBean occupied, which the MBeanServer is asked to release, and with it the broadcaster the pool's clients' listeners are attached to.
-
-
-
Method Detail
-
getPoolName
protected java.lang.String getPoolName()
Returns the name of the pool this state belongs to.- Returns:
- the name recorded at the pool's start
-
publishedUnder
protected javax.management.ObjectName publishedUnder()
Returns the ObjectName this pool's MBean is published under.- Returns:
- the published ObjectName, or
nullwhile nothing is published for this pool
-
isReleased
protected boolean isReleased()
Returns whether the close of this pool has given this state up.- Returns:
trueif the pool has closed
-
broadcaster
protected javax.management.NotificationBroadcasterSupport broadcaster()
Returns the broadcaster all interceptor instances of this pool send their notifications through, building it on the first need.- Returns:
- this pool's broadcaster; never
null
-
beginPublication
protected boolean beginPublication()
Decides whether the calling borrow is to make this pool's one publication attempt.- Returns:
trueif the caller is to attempt the publication - none has been made or attempted yet, and the pool has not closed - andfalsewhen there is nothing left to do
-
published
protected boolean published(javax.management.ObjectName oname)
Records a publication the MBeanServer accepted.- Parameters:
oname- the ObjectName the MBean was published under- Returns:
trueif the publication stands and is now this pool's MBean, andfalsewhen the pool's close landed while the MBeanServer was taking it in - nothing else in this JVM will ever learn of that publication, so the borrow that made it has to give it back
-
released
protected void released()
Gives up everything this state holds: the ObjectName the pool's MBean occupied, which the MBeanServer is asked to release, and with it the broadcaster the pool's clients' listeners are attached to. The close of the pool's statistics store calls this, and it is idempotent: a later call, from any thread, does nothing.The broadcaster itself is left in place rather than dropped: whoever still holds this pool's registration can subscribe to it, and a subscription made after the pool came down is served by a broadcaster nothing will ever send through, which is what a released registration has to answer a stale handle with. What must not survive the release is the published MBean, and it does not: the ObjectName is given up here, against the name this state recorded when it published.
-
-