List of usage examples for org.apache.http.impl.conn.tsccm BasicPoolEntry getUpdated
public long getUpdated()
From source file:org.apache.http.impl.conn.tsccm.ConnPoolByRoute.java
/** * Closes idle connections.// w w w . j a va 2 s. co m * * @param idletime the time the connections should have been idle * in order to be closed now * @param tunit the unit for the <code>idletime</code> */ @Override public void closeIdleConnections(final long idletime, final TimeUnit tunit) { Args.notNull(tunit, "Time unit"); final long t = idletime > 0 ? idletime : 0; if (log.isDebugEnabled()) { log.debug("Closing connections idle longer than " + t + " " + tunit); } // the latest time for which connections will be closed final long deadline = System.currentTimeMillis() - tunit.toMillis(t); poolLock.lock(); try { final Iterator<BasicPoolEntry> iter = freeConnections.iterator(); while (iter.hasNext()) { final BasicPoolEntry entry = iter.next(); if (entry.getUpdated() <= deadline) { if (log.isDebugEnabled()) { log.debug("Closing connection last used @ " + new Date(entry.getUpdated())); } iter.remove(); deleteEntry(entry); } } } finally { poolLock.unlock(); } }