001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.pool2.impl;
018
019import java.util.List;
020import java.util.Map;
021
022/**
023 * Defines the methods that will be made available via JMX.
024 * <h2>Note</h2>
025 * <p>
026 * This interface exists only to define those attributes and methods that will be made available via JMX. It must not be implemented by clients as it is subject
027 * to change between major, minor and patch version releases of commons pool. Clients that implement this interface may not, therefore, be able to upgrade to a
028 * new minor or patch release without requiring code changes.
029 * </p>
030 *
031 * @param <K> The type of keys maintained by the pool.
032 * @since 2.0
033 */
034public interface GenericKeyedObjectPoolMXBean<K> {
035
036    /**
037     * See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}.
038     *
039     * @return See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}.
040     */
041    boolean getBlockWhenExhausted();
042
043    /**
044     * See {@link GenericKeyedObjectPool#getBorrowedCount()}.
045     *
046     * @return See {@link GenericKeyedObjectPool#getBorrowedCount()}.
047     */
048    long getBorrowedCount();
049
050    /**
051     * See {@link GenericKeyedObjectPool#getCreatedCount()}.
052     *
053     * @return See {@link GenericKeyedObjectPool#getCreatedCount()}.
054     */
055    long getCreatedCount();
056
057    /**
058     * See {@link GenericKeyedObjectPool#getCreationStackTrace()}.
059     *
060     * @return See {@link GenericKeyedObjectPool#getCreationStackTrace()}.
061     */
062    String getCreationStackTrace();
063
064    /**
065     * See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}.
066     *
067     * @return See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}.
068     */
069    long getDestroyedByBorrowValidationCount();
070
071    /**
072     * See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}.
073     *
074     * @return See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}.
075     */
076    long getDestroyedByEvictorCount();
077
078    /**
079     * See {@link GenericKeyedObjectPool#getDestroyedCount()}.
080     *
081     * @return See {@link GenericKeyedObjectPool#getDestroyedCount()}.
082     */
083    long getDestroyedCount();
084
085    /**
086     * See {@link GenericKeyedObjectPool#getFairness()}.
087     *
088     * @return See {@link GenericKeyedObjectPool#getFairness()}.
089     */
090    boolean getFairness();
091
092    /**
093     * See {@link GenericKeyedObjectPool#getLifo()}.
094     *
095     * @return See {@link GenericKeyedObjectPool#getLifo()}.
096     */
097    boolean getLifo();
098
099    /**
100     * See {@link GenericKeyedObjectPool#getLogAbandoned()}.
101     *
102     * @return See {@link GenericKeyedObjectPool#getLogAbandoned()}.
103     * @since 2.10.0
104     */
105    default boolean getLogAbandoned() {
106        return false;
107    }
108
109    /**
110     * See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
111     *
112     * @return See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
113     */
114    long getMaxBorrowWaitTimeMillis();
115
116    /**
117     * See {@link GenericKeyedObjectPool#getMaxIdlePerKey()}.
118     *
119     * @return See {@link GenericKeyedObjectPool#getMaxIdlePerKey()}.
120     */
121    int getMaxIdlePerKey();
122
123    /**
124     * See {@link GenericKeyedObjectPool#getMaxTotal()}.
125     *
126     * @return See {@link GenericKeyedObjectPool#getMaxTotal()}.
127     */
128    int getMaxTotal();
129
130    /**
131     * See {@link GenericKeyedObjectPool#getMaxTotalPerKey()}.
132     *
133     * @return See {@link GenericKeyedObjectPool#getMaxTotalPerKey()}.
134     */
135    int getMaxTotalPerKey();
136
137    /**
138     * See {@link GenericKeyedObjectPool#getMaxWaitDuration()}.
139     *
140     * @return See {@link GenericKeyedObjectPool#getMaxWaitDuration()}.
141     */
142    long getMaxWaitMillis();
143
144    /**
145     * See {@link GenericKeyedObjectPool#getMeanActiveTimeMillis()}.
146     *
147     * @return See {@link GenericKeyedObjectPool#getMeanActiveTimeMillis()}.
148     */
149    long getMeanActiveTimeMillis();
150
151    /**
152     * See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
153     *
154     * @return See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
155     */
156    long getMeanBorrowWaitTimeMillis();
157
158    /**
159     * See {@link GenericKeyedObjectPool#getMeanIdleTimeMillis()}.
160     *
161     * @return See {@link GenericKeyedObjectPool#getMeanIdleTimeMillis()}.
162     */
163    long getMeanIdleTimeMillis();
164
165    /**
166     * See {@link GenericKeyedObjectPool#getMinEvictableIdleDuration()}.
167     *
168     * @return See {@link GenericKeyedObjectPool#getMinEvictableIdleDuration()}.
169     */
170    long getMinEvictableIdleTimeMillis();
171
172    // Expose getters for monitoring attributes
173
174    /**
175     * See {@link GenericKeyedObjectPool#getMinIdlePerKey()}.
176     *
177     * @return See {@link GenericKeyedObjectPool#getMinIdlePerKey()}.
178     */
179    int getMinIdlePerKey();
180
181    /**
182     * See {@link GenericKeyedObjectPool#getNumActive()}.
183     *
184     * @return See {@link GenericKeyedObjectPool#getNumActive()}.
185     */
186    int getNumActive();
187
188    /**
189     * See {@link GenericKeyedObjectPool#getNumActivePerKey()}.
190     *
191     * @return See {@link GenericKeyedObjectPool#getNumActivePerKey()}.
192     */
193    Map<String, Integer> getNumActivePerKey();
194
195    /**
196     * See {@link GenericKeyedObjectPool#getNumIdle()}.
197     *
198     * @return See {@link GenericKeyedObjectPool#getNumIdle()}.
199     */
200    int getNumIdle();
201
202    /**
203     * See {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun()}.
204     *
205     * @return See {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun()}.
206     */
207    int getNumTestsPerEvictionRun();
208
209    /**
210     * See {@link GenericKeyedObjectPool#getNumWaiters()}.
211     *
212     * @return See {@link GenericKeyedObjectPool#getNumWaiters()}.
213     */
214    int getNumWaiters();
215
216    /**
217     * See {@link GenericKeyedObjectPool#getNumWaitersByKey()}.
218     *
219     * @return See {@link GenericKeyedObjectPool#getNumWaitersByKey()}.
220     */
221    Map<String, Integer> getNumWaitersByKey();
222
223    /**
224     * See {@link GenericKeyedObjectPool#getRemoveAbandonedOnBorrow()}.
225     *
226     * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedOnBorrow()}.
227     * @since 2.10.0
228     */
229    default boolean getRemoveAbandonedOnBorrow() {
230        return false;
231    }
232
233    /**
234     * See {@link GenericKeyedObjectPool#getRemoveAbandonedOnMaintenance()}.
235     *
236     * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedOnMaintenance()}.
237     * @since 2.10.0
238     */
239    default boolean getRemoveAbandonedOnMaintenance() {
240        return false;
241    }
242
243    /**
244     * See {@link GenericKeyedObjectPool#getRemoveAbandonedTimeoutDuration()}.
245     *
246     * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedTimeoutDuration()}.
247     * @since 2.10.0
248     */
249    default int getRemoveAbandonedTimeout() {
250        return 0;
251    }
252
253    /**
254     * See {@link GenericKeyedObjectPool#getReturnedCount()}.
255     *
256     * @return See {@link GenericKeyedObjectPool#getReturnedCount()}.
257     */
258    long getReturnedCount();
259
260    /**
261     * See {@link GenericKeyedObjectPool#getTestOnBorrow()}.
262     *
263     * @return See {@link GenericKeyedObjectPool#getTestOnBorrow()}.
264     */
265    boolean getTestOnBorrow();
266
267    /**
268     * See {@link GenericKeyedObjectPool#getTestOnCreate()}.
269     *
270     * @return See {@link GenericKeyedObjectPool#getTestOnCreate()}.
271     * @since 2.2
272     */
273    boolean getTestOnCreate();
274
275    /**
276     * See {@link GenericKeyedObjectPool#getTestOnReturn()}.
277     *
278     * @return See {@link GenericKeyedObjectPool#getTestOnReturn()}.
279     */
280    boolean getTestOnReturn();
281
282    /**
283     * See {@link GenericKeyedObjectPool#getTestWhileIdle()}.
284     *
285     * @return See {@link GenericKeyedObjectPool#getTestWhileIdle()}.
286     */
287    boolean getTestWhileIdle();
288
289    /**
290     * See {@link GenericKeyedObjectPool#getDurationBetweenEvictionRuns}
291     *
292     * @return See {@link GenericKeyedObjectPool#getDurationBetweenEvictionRuns()}.
293     */
294    long getTimeBetweenEvictionRunsMillis();
295
296    /**
297     * See {@link GenericKeyedObjectPool#isAbandonedConfig()}.
298     *
299     * @return See {@link GenericKeyedObjectPool#isAbandonedConfig()}.
300     * @since 2.10.0
301     */
302    default boolean isAbandonedConfig() {
303        return false;
304    }
305
306    /**
307     * See {@link GenericKeyedObjectPool#isClosed()}.
308     *
309     * @return See {@link GenericKeyedObjectPool#isClosed()}.
310     */
311    boolean isClosed();
312
313    /**
314     * See {@link GenericKeyedObjectPool#listAllObjects()}.
315     *
316     * @return See {@link GenericKeyedObjectPool#listAllObjects()}.
317     */
318    Map<String, List<DefaultPooledObjectInfo>> listAllObjects();
319}