Example usage for org.apache.http.impl.conn.tsccm BasicPoolEntry updateExpiry

List of usage examples for org.apache.http.impl.conn.tsccm BasicPoolEntry updateExpiry

Introduction

In this page you can find the example usage for org.apache.http.impl.conn.tsccm BasicPoolEntry updateExpiry.

Prototype

public void updateExpiry(final long time, final TimeUnit timeunit) 

Source Link

Usage

From source file:org.apache.http.impl.conn.tsccm.ConnPoolByRoute.java

@Override
public void freeEntry(final BasicPoolEntry entry, final boolean reusable, final long validDuration,
        final TimeUnit timeUnit) {

    final HttpRoute route = entry.getPlannedRoute();
    if (log.isDebugEnabled()) {
        log.debug("Releasing connection" + " [" + route + "][" + entry.getState() + "]");
    }//w w  w.  j  a va2  s  .  co  m

    poolLock.lock();
    try {
        if (shutdown) {
            // the pool is shut down, release the
            // connection's resources and get out of here
            closeConnection(entry);
            return;
        }

        // no longer issued, we keep a hard reference now
        leasedConnections.remove(entry);

        final RouteSpecificPool rospl = getRoutePool(route, true);

        if (reusable && rospl.getCapacity() >= 0) {
            if (log.isDebugEnabled()) {
                final String s;
                if (validDuration > 0) {
                    s = "for " + validDuration + " " + timeUnit;
                } else {
                    s = "indefinitely";
                }
                log.debug("Pooling connection" + " [" + route + "][" + entry.getState() + "]; keep alive " + s);
            }
            rospl.freeEntry(entry);
            entry.updateExpiry(validDuration, timeUnit);
            freeConnections.add(entry);
        } else {
            closeConnection(entry);
            rospl.dropEntry();
            numConnections--;
        }

        notifyWaitingThread(rospl);

    } finally {
        poolLock.unlock();
    }
}