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 19 import java.util.List; 20 import java.util.Map; 21 22 /** 23 * Defines the methods that will be made available via JMX. 24 * <h2>Note</h2> 25 * <p> 26 * 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 27 * 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 28 * new minor or patch release without requiring code changes. 29 * </p> 30 * 31 * @param <K> The type of keys maintained by the pool. 32 * @since 2.0 33 */ 34 public interface GenericKeyedObjectPoolMXBean<K> { 35 36 /** 37 * See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}. 38 * 39 * @return See {@link GenericKeyedObjectPool#getBlockWhenExhausted()}. 40 */ 41 boolean getBlockWhenExhausted(); 42 43 /** 44 * See {@link GenericKeyedObjectPool#getBorrowedCount()}. 45 * 46 * @return See {@link GenericKeyedObjectPool#getBorrowedCount()}. 47 */ 48 long getBorrowedCount(); 49 50 /** 51 * See {@link GenericKeyedObjectPool#getCreatedCount()}. 52 * 53 * @return See {@link GenericKeyedObjectPool#getCreatedCount()}. 54 */ 55 long getCreatedCount(); 56 57 /** 58 * See {@link GenericKeyedObjectPool#getCreationStackTrace()}. 59 * 60 * @return See {@link GenericKeyedObjectPool#getCreationStackTrace()}. 61 */ 62 String getCreationStackTrace(); 63 64 /** 65 * See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}. 66 * 67 * @return See {@link GenericKeyedObjectPool#getDestroyedByBorrowValidationCount()}. 68 */ 69 long getDestroyedByBorrowValidationCount(); 70 71 /** 72 * See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}. 73 * 74 * @return See {@link GenericKeyedObjectPool#getDestroyedByEvictorCount()}. 75 */ 76 long getDestroyedByEvictorCount(); 77 78 /** 79 * See {@link GenericKeyedObjectPool#getDestroyedCount()}. 80 * 81 * @return See {@link GenericKeyedObjectPool#getDestroyedCount()}. 82 */ 83 long getDestroyedCount(); 84 85 /** 86 * See {@link GenericKeyedObjectPool#getFairness()}. 87 * 88 * @return See {@link GenericKeyedObjectPool#getFairness()}. 89 */ 90 boolean getFairness(); 91 92 /** 93 * See {@link GenericKeyedObjectPool#getLifo()}. 94 * 95 * @return See {@link GenericKeyedObjectPool#getLifo()}. 96 */ 97 boolean getLifo(); 98 99 /** 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 }