GenericKeyedObjectPoolMXBean.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.pool2.impl;

  18. import java.util.List;
  19. import java.util.Map;

  20. /**
  21.  * Defines the methods that will be made available via JMX.
  22.  * <h2>Note</h2>
  23.  * <p>
  24.  * 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
  25.  * 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
  26.  * new minor or patch release without requiring code changes.
  27.  * </p>
  28.  *
  29.  * @param <K> The type of keys maintained by the pool.
  30.  * @since 2.0
  31.  */
  32. public interface GenericKeyedObjectPoolMXBean<K> {

  33.     /**
  34.      * See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}.
  35.      *
  36.      * @return See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}.
  37.      */
  38.     boolean getBlockWhenExhausted();

  39.     /**
  40.      * See {@link GenericKeyedObjectPool#getBorrowedCount()}.
  41.      *
  42.      * @return See {@link GenericKeyedObjectPool#getBorrowedCount()}.
  43.      */
  44.     long getBorrowedCount();

  45.     /**
  46.      * See {@link GenericKeyedObjectPool#getCreatedCount()}.
  47.      *
  48.      * @return See {@link GenericKeyedObjectPool#getCreatedCount()}.
  49.      */
  50.     long getCreatedCount();

  51.     /**
  52.      * See {@link GenericKeyedObjectPool#getCreationStackTrace()}.
  53.      *
  54.      * @return See {@link GenericKeyedObjectPool#getCreationStackTrace()}.
  55.      */
  56.     String getCreationStackTrace();

  57.     /**
  58.      * See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}.
  59.      *
  60.      * @return See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}.
  61.      */
  62.     long getDestroyedByBorrowValidationCount();

  63.     /**
  64.      * See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}.
  65.      *
  66.      * @return See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}.
  67.      */
  68.     long getDestroyedByEvictorCount();

  69.     /**
  70.      * See {@link GenericKeyedObjectPool#getDestroyedCount()}.
  71.      *
  72.      * @return See {@link GenericKeyedObjectPool#getDestroyedCount()}.
  73.      */
  74.     long getDestroyedCount();

  75.     /**
  76.      * See {@link GenericKeyedObjectPool#getFairness()}.
  77.      *
  78.      * @return See {@link GenericKeyedObjectPool#getFairness()}.
  79.      */
  80.     boolean getFairness();

  81.     /**
  82.      * See {@link GenericKeyedObjectPool#getLifo()}.
  83.      *
  84.      * @return See {@link GenericKeyedObjectPool#getLifo()}.
  85.      */
  86.     boolean getLifo();

  87.     /**
  88.      * See {@link GenericKeyedObjectPool#getLogAbandoned()}.
  89.      *
  90.      * @return See {@link GenericKeyedObjectPool#getLogAbandoned()}.
  91.      * @since 2.10.0
  92.      */
  93.     default boolean getLogAbandoned() {
  94.         return false;
  95.     }

  96.     /**
  97.      * See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
  98.      *
  99.      * @return See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
  100.      */
  101.     long getMaxBorrowWaitTimeMillis();

  102.     /**
  103.      * See {@link GenericKeyedObjectPool#getMaxIdlePerKey()}.
  104.      *
  105.      * @return See {@link GenericKeyedObjectPool#getMaxIdlePerKey()}.
  106.      */
  107.     int getMaxIdlePerKey();

  108.     /**
  109.      * See {@link GenericKeyedObjectPool#getMaxTotal()}.
  110.      *
  111.      * @return See {@link GenericKeyedObjectPool#getMaxTotal()}.
  112.      */
  113.     int getMaxTotal();

  114.     /**
  115.      * See {@link GenericKeyedObjectPool#getMaxTotalPerKey()}.
  116.      *
  117.      * @return See {@link GenericKeyedObjectPool#getMaxTotalPerKey()}.
  118.      */
  119.     int getMaxTotalPerKey();

  120.     /**
  121.      * See {@link GenericKeyedObjectPool#getMaxWaitDuration()}.
  122.      *
  123.      * @return See {@link GenericKeyedObjectPool#getMaxWaitDuration()}.
  124.      */
  125.     long getMaxWaitMillis();

  126.     /**
  127.      * See {@link GenericKeyedObjectPool#getMeanActiveTimeMillis()}.
  128.      *
  129.      * @return See {@link GenericKeyedObjectPool#getMeanActiveTimeMillis()}.
  130.      */
  131.     long getMeanActiveTimeMillis();

  132.     /**
  133.      * See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
  134.      *
  135.      * @return See {@link GenericKeyedObjectPool#getMaxBorrowWaitTimeMillis()}.
  136.      */
  137.     long getMeanBorrowWaitTimeMillis();

  138.     /**
  139.      * See {@link GenericKeyedObjectPool#getMeanIdleTimeMillis()}.
  140.      *
  141.      * @return See {@link GenericKeyedObjectPool#getMeanIdleTimeMillis()}.
  142.      */
  143.     long getMeanIdleTimeMillis();

  144.     /**
  145.      * See {@link GenericKeyedObjectPool#getMinEvictableIdleDuration()}.
  146.      *
  147.      * @return See {@link GenericKeyedObjectPool#getMinEvictableIdleDuration()}.
  148.      */
  149.     long getMinEvictableIdleTimeMillis();

  150.     // Expose getters for monitoring attributes

  151.     /**
  152.      * See {@link GenericKeyedObjectPool#getMinIdlePerKey()}.
  153.      *
  154.      * @return See {@link GenericKeyedObjectPool#getMinIdlePerKey()}.
  155.      */
  156.     int getMinIdlePerKey();

  157.     /**
  158.      * See {@link GenericKeyedObjectPool#getNumActive()}.
  159.      *
  160.      * @return See {@link GenericKeyedObjectPool#getNumActive()}.
  161.      */
  162.     int getNumActive();

  163.     /**
  164.      * See {@link GenericKeyedObjectPool#getNumActivePerKey()}.
  165.      *
  166.      * @return See {@link GenericKeyedObjectPool#getNumActivePerKey()}.
  167.      */
  168.     Map<String, Integer> getNumActivePerKey();

  169.     /**
  170.      * See {@link GenericKeyedObjectPool#getNumIdle()}.
  171.      *
  172.      * @return See {@link GenericKeyedObjectPool#getNumIdle()}.
  173.      */
  174.     int getNumIdle();

  175.     /**
  176.      * See {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun()}.
  177.      *
  178.      * @return See {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun()}.
  179.      */
  180.     int getNumTestsPerEvictionRun();

  181.     /**
  182.      * See {@link GenericKeyedObjectPool#getNumWaiters()}.
  183.      *
  184.      * @return See {@link GenericKeyedObjectPool#getNumWaiters()}.
  185.      */
  186.     int getNumWaiters();

  187.     /**
  188.      * See {@link GenericKeyedObjectPool#getNumWaitersByKey()}.
  189.      *
  190.      * @return See {@link GenericKeyedObjectPool#getNumWaitersByKey()}.
  191.      */
  192.     Map<String, Integer> getNumWaitersByKey();

  193.     /**
  194.      * See {@link GenericKeyedObjectPool#getRemoveAbandonedOnBorrow()}.
  195.      *
  196.      * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedOnBorrow()}.
  197.      * @since 2.10.0
  198.      */
  199.     default boolean getRemoveAbandonedOnBorrow() {
  200.         return false;
  201.     }

  202.     /**
  203.      * See {@link GenericKeyedObjectPool#getRemoveAbandonedOnMaintenance()}.
  204.      *
  205.      * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedOnMaintenance()}.
  206.      * @since 2.10.0
  207.      */
  208.     default boolean getRemoveAbandonedOnMaintenance() {
  209.         return false;
  210.     }

  211.     /**
  212.      * See {@link GenericKeyedObjectPool#getRemoveAbandonedTimeoutDuration()}.
  213.      *
  214.      * @return See {@link GenericKeyedObjectPool#getRemoveAbandonedTimeoutDuration()}.
  215.      * @since 2.10.0
  216.      */
  217.     default int getRemoveAbandonedTimeout() {
  218.         return 0;
  219.     }

  220.     /**
  221.      * See {@link GenericKeyedObjectPool#getReturnedCount()}.
  222.      *
  223.      * @return See {@link GenericKeyedObjectPool#getReturnedCount()}.
  224.      */
  225.     long getReturnedCount();

  226.     /**
  227.      * See {@link GenericKeyedObjectPool#getTestOnBorrow()}.
  228.      *
  229.      * @return See {@link GenericKeyedObjectPool#getTestOnBorrow()}.
  230.      */
  231.     boolean getTestOnBorrow();

  232.     /**
  233.      * See {@link GenericKeyedObjectPool#getTestOnCreate()}.
  234.      *
  235.      * @return See {@link GenericKeyedObjectPool#getTestOnCreate()}.
  236.      * @since 2.2
  237.      */
  238.     boolean getTestOnCreate();

  239.     /**
  240.      * See {@link GenericKeyedObjectPool#getTestOnReturn()}.
  241.      *
  242.      * @return See {@link GenericKeyedObjectPool#getTestOnReturn()}.
  243.      */
  244.     boolean getTestOnReturn();

  245.     /**
  246.      * See {@link GenericKeyedObjectPool#getTestWhileIdle()}.
  247.      *
  248.      * @return See {@link GenericKeyedObjectPool#getTestWhileIdle()}.
  249.      */
  250.     boolean getTestWhileIdle();

  251.     /**
  252.      * See {@link GenericKeyedObjectPool#getDurationBetweenEvictionRuns}
  253.      *
  254.      * @return See {@link GenericKeyedObjectPool#getDurationBetweenEvictionRuns()}.
  255.      */
  256.     long getTimeBetweenEvictionRunsMillis();

  257.     /**
  258.      * See {@link GenericKeyedObjectPool#isAbandonedConfig()}.
  259.      *
  260.      * @return See {@link GenericKeyedObjectPool#isAbandonedConfig()}.
  261.      * @since 2.10.0
  262.      */
  263.     default boolean isAbandonedConfig() {
  264.         return false;
  265.     }

  266.     /**
  267.      * See {@link GenericKeyedObjectPool#isClosed()}.
  268.      *
  269.      * @return See {@link GenericKeyedObjectPool#isClosed()}.
  270.      */
  271.     boolean isClosed();

  272.     /**
  273.      * See {@link GenericKeyedObjectPool#listAllObjects()}.
  274.      *
  275.      * @return See {@link GenericKeyedObjectPool#listAllObjects()}.
  276.      */
  277.     Map<String, List<DefaultPooledObjectInfo>> listAllObjects();
  278. }