Example usage for org.apache.http.pool PoolEntry updateExpiry

List of usage examples for org.apache.http.pool PoolEntry updateExpiry

Introduction

In this page you can find the example usage for org.apache.http.pool PoolEntry updateExpiry.

Prototype

public synchronized void updateExpiry(long j, TimeUnit timeUnit) 

Source Link

Usage

From source file:com.couchbase.client.http.ViewPool.java

/**
 * Closes the underlying connections for the given {@link HttpHost}.
 *
 * Since on a rebalance out, all connections to this view node need to
 * be closed, regardless if they are currently available or leased.
 *
 * @param host the host to shutdown connections for.
 *//*from  w ww  .j  a  v a 2  s .  co  m*/
public void closeConnectionsForHost(final HttpHost host) {
    // In-flight operations will be cancelled and retried in other parts of
    // the codebase.
    enumAvailable(new PoolEntryCallback<HttpHost, NHttpClientConnection>() {
        @Override
        public void process(PoolEntry<HttpHost, NHttpClientConnection> entry) {
            if (entry.getRoute().equals(host)) {
                entry.updateExpiry(0, TimeUnit.MILLISECONDS);
            }
        }
    });

    enumLeased(new PoolEntryCallback<HttpHost, NHttpClientConnection>() {
        @Override
        public void process(PoolEntry<HttpHost, NHttpClientConnection> entry) {
            if (entry.getRoute().equals(host)) {
                entry.updateExpiry(0, TimeUnit.MILLISECONDS);
            }
        }
    });

    closeExpired();
}