com.ning.http.client.providers.netty
Class NettyConnectionsPool

java.lang.Object
  extended by com.ning.http.client.providers.netty.NettyConnectionsPool
All Implemented Interfaces:
ConnectionsPool<String,org.jboss.netty.channel.Channel>

public class NettyConnectionsPool
extends Object
implements ConnectionsPool<String,org.jboss.netty.channel.Channel>

A simple implementation of ConnectionsPool based on a ConcurrentHashMap


Constructor Summary
NettyConnectionsPool(int maxTotalConnections, int maxConnectionPerHost, long maxIdleTime, int maxConnectionLifeTimeInMs, boolean sslConnectionPoolEnabled, org.jboss.netty.util.HashedWheelTimer hashedWheelTimer)
           
NettyConnectionsPool(NettyAsyncHttpProvider provider, org.jboss.netty.util.HashedWheelTimer hashedWheelTimer)
           
 
Method Summary
 boolean canCacheConnection()
          Return true if a connection can be cached.
 void destroy()
          Destroy all connections that has been cached by this instance.
 boolean offer(String uri, org.jboss.netty.channel.Channel channel)
          Add a connection tpo the pool
 org.jboss.netty.channel.Channel poll(String uri)
          Remove the connection associated with the uri.
 boolean removeAll(org.jboss.netty.channel.Channel channel)
          Remove all connections from the cache.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NettyConnectionsPool

public NettyConnectionsPool(NettyAsyncHttpProvider provider,
                            org.jboss.netty.util.HashedWheelTimer hashedWheelTimer)

NettyConnectionsPool

public NettyConnectionsPool(int maxTotalConnections,
                            int maxConnectionPerHost,
                            long maxIdleTime,
                            int maxConnectionLifeTimeInMs,
                            boolean sslConnectionPoolEnabled,
                            org.jboss.netty.util.HashedWheelTimer hashedWheelTimer)
Method Detail

offer

public boolean offer(String uri,
                     org.jboss.netty.channel.Channel channel)
Add a connection tpo the pool

Specified by:
offer in interface ConnectionsPool<String,org.jboss.netty.channel.Channel>
Parameters:
uri - a uri used to retrieve the cached connection
channel - an I/O connection
Returns:
true if added.

poll

public org.jboss.netty.channel.Channel poll(String uri)
Remove the connection associated with the uri.

Specified by:
poll in interface ConnectionsPool<String,org.jboss.netty.channel.Channel>
Parameters:
uri - the uri used when invoking addConnection
Returns:
the connection associated with the uri

removeAll

public boolean removeAll(org.jboss.netty.channel.Channel channel)
Remove all connections from the cache. A connection might have been associated with several uri.

Specified by:
removeAll in interface ConnectionsPool<String,org.jboss.netty.channel.Channel>
Parameters:
channel - a connection
Returns:
the true if the connection has been removed

canCacheConnection

public boolean canCacheConnection()
Return true if a connection can be cached. A implementation can decide based on some rules to allow caching Calling this method is equivalent of checking the returned value of ConnectionsPool.offer(Object, Object)

Specified by:
canCacheConnection in interface ConnectionsPool<String,org.jboss.netty.channel.Channel>
Returns:
true if a connection can be cached.

destroy

public void destroy()
Destroy all connections that has been cached by this instance.

Specified by:
destroy in interface ConnectionsPool<String,org.jboss.netty.channel.Channel>

toString

public final String toString()
Overrides:
toString in class Object


Copyright © 2014. All Rights Reserved.