List of usage examples for org.apache.commons.pool2.impl GenericObjectPool getMaxIdle
@Override public int getMaxIdle()
From source file:com.netflix.spinnaker.orca.config.RedisConfiguration.java
@Deprecated // rz - Kept for backwards compat with old connection configs @Bean/*from ww w . jav a 2 s .c om*/ HealthIndicator redisHealth(@Qualifier("jedisPool") Pool<Jedis> jedisPool) { try { final Pool<Jedis> src = jedisPool; final Field poolAccess = Pool.class.getDeclaredField("internalPool"); poolAccess.setAccessible(true); GenericObjectPool<Jedis> internal = (GenericObjectPool<Jedis>) poolAccess.get(jedisPool); return () -> { Jedis jedis = null; Health.Builder health; try { jedis = src.getResource(); if ("PONG".equals(jedis.ping())) { health = Health.up(); } else { health = Health.down(); } } catch (Exception ex) { health = Health.down(ex); } finally { if (jedis != null) jedis.close(); } health.withDetail("maxIdle", internal.getMaxIdle()); health.withDetail("minIdle", internal.getMinIdle()); health.withDetail("numActive", internal.getNumActive()); health.withDetail("numIdle", internal.getNumIdle()); health.withDetail("numWaiters", internal.getNumWaiters()); return health.build(); }; } catch (IllegalAccessException | NoSuchFieldException e) { throw new BeanCreationException("Error creating Redis health indicator", e); } }
From source file:org.apache.ofbiz.entity.connection.DebugManagedDataSource.java
@Override public Connection getConnection() throws SQLException { if (Debug.verboseOn()) { if (super.getPool() instanceof GenericObjectPool) { GenericObjectPool objectPool = (GenericObjectPool) super.getPool(); Debug.logVerbose("Borrowing a connection from the pool; used/idle/total: " + objectPool.getNumActive() + "/" + objectPool.getNumIdle() + "/" + (objectPool.getNumActive() + objectPool.getNumIdle()) + "; min idle/max idle/max total: " + objectPool.getMinIdle() + "/" + objectPool.getMaxIdle() + "/" + objectPool.getMaxTotal(), module);//from ww w . j a v a 2 s . c o m } else { Debug.logVerbose("Borrowing a connection from the pool; used/idle/total: " + super.getPool().getNumActive() + "/" + super.getPool().getNumIdle() + "/" + (super.getPool().getNumActive() + super.getPool().getNumIdle()), module); } } return super.getConnection(); }
From source file:org.apache.ofbiz.entity.connection.DebugManagedDataSource.java
public Map<String, Object> getInfo() { Map<String, Object> dataSourceInfo = new HashMap<String, Object>(); dataSourceInfo.put("poolNumActive", super.getPool().getNumActive()); dataSourceInfo.put("poolNumIdle", super.getPool().getNumIdle()); dataSourceInfo.put("poolNumTotal", (super.getPool().getNumIdle() + super.getPool().getNumActive())); if (super.getPool() instanceof GenericObjectPool) { GenericObjectPool objectPool = (GenericObjectPool) super.getPool(); dataSourceInfo.put("poolMaxActive", objectPool.getMaxTotal()); dataSourceInfo.put("poolMaxIdle", objectPool.getMaxIdle()); dataSourceInfo.put("poolMaxWait", objectPool.getMaxWaitMillis()); dataSourceInfo.put("poolMinEvictableIdleTimeMillis", objectPool.getMinEvictableIdleTimeMillis()); dataSourceInfo.put("poolMinIdle", objectPool.getMinIdle()); }//from w w w . j a va 2s . co m return dataSourceInfo; }