    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 *
    025 * NOTE: This interface exists only to define those attributes and methods that
    026 *       will be made available via JMX. It must not be implemented by clients
    027 *       as it is subject to change between major, minor and patch version
    028 *       releases of commons pool. Clients that implement this interface may
    029 *       not, therefore, be able to upgrade to a new minor or patch release
    030 *       without requiring code changes.
    031 *
    032 * @param <K> The type of keys maintained by the pool.
    033 *
    034 * @since 2.0
    035 */
    036public interface GenericKeyedObjectPoolMXBean<K> {
    037
    038    // Expose getters for configuration settings
    039
    040    /**
    041     * See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}
    042     * @return See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}
    043     */
    044    boolean getBlockWhenExhausted();
    045
    046    /**
    047     * See {@link GenericKeyedObjectPool#getBorrowedCount()}
    048     * @return See {@link GenericKeyedObjectPool#getBorrowedCount()}
    049     */
    050    long getBorrowedCount();
    051
    052    /**
    053     * See {@link GenericKeyedObjectPool#getCreatedCount()}
    054     * @return See {@link GenericKeyedObjectPool#getCreatedCount()}
    055     */
    056    long getCreatedCount();
    057
    058    /**
    059     * See {@link GenericKeyedObjectPool#getCreationStackTrace()}
    060     * @return See {@link GenericKeyedObjectPool#getCreationStackTrace()}
    061     */
    062    String getCreationStackTrace();
    063
    064    /**
    065     * See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}
    066     * @return See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}
    067     */
    068    long getDestroyedByBorrowValidationCount();
    069
    070    /**
    071     * See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}
    072     * @return See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}
    073     */
    074    long getDestroyedByEvictorCount();
    075
    076    /**
    077     * See {@link GenericKeyedObjectPool#getDestroyedCount()}
    078     * @return See {@link GenericKeyedObjectPool#getDestroyedCount()}
    079     */
    080    long getDestroyedCount();
    081
    082    /**
    083     * See {@link GenericKeyedObjectPool#getFairness()}
    084     * @return See {@link GenericKeyedObjectPool#getFairness()}
    085     */
    086    boolean getFairness();
    087
    088    /**
    089     * See {@link GenericKeyedObjectPool#getLifo()}
    090     * @return See {@link GenericKeyedObjectPool#getLifo()}
    091     */
    092    boolean getLifo();
    093
    094    /**
    095     * See {@link GenericKeyedObjectPool#getLogAbandoned()}
    096     * @return See {@link GenericKeyedObjectPool#getLogAbandoned()}
    097     * @since 2.10.0
    098     */
    099    default boolean getLogAbandoned() {
    100        return false;
    101    }
    102
    103    /**
    104     * See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}
    105     * @return See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}
    106     */
    107    long getMaxBorrowWaitTimeMillis();
    108
    109    /**
    110     * See {@link GenericKeyedObjectPool#getMaxIdlePerKey()}
    111     * @return See {@link GenericKeyedObjectPool#getMaxIdlePerKey()}
    112     */
    113    int getMaxIdlePerKey();
    114
    115    /**
    116     * See {@link GenericKeyedObjectPool#getMaxTotal()}
    117     * @return See {@link GenericKeyedObjectPool#getMaxTotal()}
    118     */
    119    int getMaxTotal();
    120
    121    /**
    122     * See {@link GenericKeyedObjectPool#getMaxTotalPerKey()}
    123     * @return See {@link GenericKeyedObjectPool#getMaxTotalPerKey()}
    124     */
    125    int getMaxTotalPerKey();
    126
    127    /**
    128     * See {@link GenericKeyedObjectPool#getMaxWaitMillis()}
    129     * @return See {@link GenericKeyedObjectPool#getMaxWaitMillis()}
    130     */
    131    long getMaxWaitMillis();
    132
    133    /**
    134     * See {@link GenericKeyedObjectPool#getMeanActiveTimeMillis()}
    135     * @return See {@link GenericKeyedObjectPool#getMeanActiveTimeMillis()}
    136     */
    137    long getMeanActiveTimeMillis();
    138
    139    /**
    140     * See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}
    141     * @return See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}
    142     */
    143    long getMeanBorrowWaitTimeMillis();
    144
    145    /**
    146     * See {@link GenericKeyedObjectPool#getMeanIdleTimeMillis()}
    147     * @return See {@link GenericKeyedObjectPool#getMeanIdleTimeMillis()}
    148     */
    149    long getMeanIdleTimeMillis();
    150
    151    /**
    152     * See {@link GenericKeyedObjectPool#getMinEvictableIdleTimeMillis()}
    153     * @return See {@link GenericKeyedObjectPool#getMinEvictableIdleTimeMillis()}
    154     */
    155    long getMinEvictableIdleTimeMillis();
    156
    157    // Expose getters for monitoring attributes
    158
    159    /**
    160     * See {@link GenericKeyedObjectPool#getMinIdlePerKey()}
    161     * @return See {@link GenericKeyedObjectPool#getMinIdlePerKey()}
    162     */
    163    int getMinIdlePerKey();
    164
    165    /**
    166     * See {@link GenericKeyedObjectPool#getNumActive()}
    167     * @return See {@link GenericKeyedObjectPool#getNumActive()}
    168     */
    169    int getNumActive();
    170
    171    /**
    172     * See {@link GenericKeyedObjectPool#getNumActivePerKey()}
    173     * @return See {@link GenericKeyedObjectPool#getNumActivePerKey()}
    174     */
    175    Map<String,Integer> getNumActivePerKey();
    176
    177    /**
    178     * See {@link GenericKeyedObjectPool#getNumIdle()}
    179     * @return See {@link GenericKeyedObjectPool#getNumIdle()}
    180     */
    181    int getNumIdle();
    182
    183    /**
    184     * See {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun()}
    185     * @return See {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun()}
    186     */
    187    int getNumTestsPerEvictionRun();
    188
    189    /**
    190     * See {@link GenericKeyedObjectPool#getNumWaiters()}
    191     * @return See {@link GenericKeyedObjectPool#getNumWaiters()}
    192     */
    193    int getNumWaiters();
    194
    195    /**
    196     * See {@link GenericKeyedObjectPool#getNumWaitersByKey()}
    197     * @return See {@link GenericKeyedObjectPool#getNumWaitersByKey()}
    198     */
    199    Map<String,Integer> getNumWaitersByKey();
    200
    201    /**
    202     * See {@link GenericKeyedObjectPool#getRemoveAbandonedOnBorrow()}
    203     * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedOnBorrow()}
    204     * @since 2.10.0
    205     */
    206    default boolean getRemoveAbandonedOnBorrow() {
    207        return false;
    208    }
    209
    210    /**
    211     * See {@link GenericKeyedObjectPool#getRemoveAbandonedOnMaintenance()}
    212     * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedOnMaintenance()}
    213     * @since 2.10.0
    214     */
    215    default boolean getRemoveAbandonedOnMaintenance()  {
    216        return false;
    217    }
    218
    219    /**
    220     * See {@link GenericKeyedObjectPool#getRemoveAbandonedTimeout()}
    221     * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedTimeout()}
    222     * @since 2.10.0
    223     */
    224    default int getRemoveAbandonedTimeout() {
    225        return 0;
    226    }
    227
    228    /**
    229     * See {@link GenericKeyedObjectPool#getReturnedCount()}
    230     * @return See {@link GenericKeyedObjectPool#getReturnedCount()}
    231     */
    232    long getReturnedCount();
    233
    234    /**
    235     * See {@link GenericKeyedObjectPool#getTestOnBorrow()}
    236     * @return See {@link GenericKeyedObjectPool#getTestOnBorrow()}
    237     */
    238    boolean getTestOnBorrow();
    239
    240    /**
    241     * See {@link GenericKeyedObjectPool#getTestOnCreate()}
    242     * @return See {@link GenericKeyedObjectPool#getTestOnCreate()}
    243     * @since 2.2
    244     */
    245    boolean getTestOnCreate();
    246
    247    /**
    248     * See {@link GenericKeyedObjectPool#getTestOnReturn()}
    249     * @return See {@link GenericKeyedObjectPool#getTestOnReturn()}
    250     */
    251    boolean getTestOnReturn();
    252
    253    /**
    254     * See {@link GenericKeyedObjectPool#getTestWhileIdle()}
    255     * @return See {@link GenericKeyedObjectPool#getTestWhileIdle()}
    256     */
    257    boolean getTestWhileIdle();
    258
    259    /**
    260     * See {@link GenericKeyedObjectPool#getTimeBetweenEvictionRunsMillis()}
    261     * @return See {@link GenericKeyedObjectPool#getTimeBetweenEvictionRunsMillis()}
    262     */
    263    long getTimeBetweenEvictionRunsMillis();
    264
    265    /**
    266     * See {@link GenericKeyedObjectPool#isAbandonedConfig()}
    267     * @return See {@link GenericKeyedObjectPool#isAbandonedConfig()}
    268     * @since 2.10.0
    269     */
    270    default boolean isAbandonedConfig() {
    271        return false;
    272    }
    273
    274    /**
    275     * See {@link GenericKeyedObjectPool#isClosed()}
    276     * @return See {@link GenericKeyedObjectPool#isClosed()}
    277     */
    278    boolean isClosed();
    279
    280    /**
    281     * See {@link GenericKeyedObjectPool#listAllObjects()}
    282     * @return See {@link GenericKeyedObjectPool#listAllObjects()}
    283     */
    284    Map<String,List<DefaultPooledObjectInfo>> listAllObjects();
    285}