List of usage examples for org.apache.commons.pool2 PooledObject getIdleTimeMillis
long getIdleTimeMillis();
From source file:com.magnet.mmx.server.plugin.mmxmgmt.apns.StubAPNSConnectionKeyedPooledObjectFactory.java
@Override public void destroyObject(APNSConnectionPoolImpl.APNSConnectionKey key, PooledObject<APNSConnection> connection) throws Exception { long activeFor = connection.getActiveTimeMillis(); long idleFor = connection.getIdleTimeMillis(); int hashCode = connection.getObject().hashCode(); super.destroyObject(key, connection); LOGGER.info(String.format("Destroyed APNS Connection for key:%s, active:%d idle:%d hashcode:%d", key, activeFor / 1000L, idleFor / 1000L, hashCode)); }
From source file:JDBCPool.dbcp.demo.sourcecode.BaseGenericObjectPool.java
/** * Updates statistics after an object is borrowed from the pool. * @param p object borrowed from the pool * @param waitTime time (in milliseconds) that the borrowing thread had to wait *///w ww. j a va 2 s. c o m final void updateStatsBorrow(PooledObject<T> p, long waitTime) { borrowedCount.incrementAndGet(); idleTimes.add(p.getIdleTimeMillis()); waitTimes.add(waitTime); // lock-free optimistic-locking maximum long currentMax; do { currentMax = maxBorrowWaitTimeMillis.get(); if (currentMax >= waitTime) { break; } } while (!maxBorrowWaitTimeMillis.compareAndSet(currentMax, waitTime)); }