Example usage for org.apache.http.pool PoolEntryCallback PoolEntryCallback

List of usage examples for org.apache.http.pool PoolEntryCallback PoolEntryCallback

Introduction

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

Prototype

PoolEntryCallback

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  w  w.  ja  va2s.c  o  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();
}