Netflix/RxNetty — pull request #95 by NiteshKant (2014-04-16 07:46:19+00:00)
Title: Connection pool refactoring

Made the following changes to ChannelPool:

* Improved the abstraction earlier provided by ChannelPool by converting it to a "ConnectionPool" to pool ObservableConnection. This fits in better with the rest of the code.
* Modified the interface to "assume" that a pool connects to one server. This also fits in better with the existing client abstraction.
* Provided a shutdown method on the pool. (Issue #80, #81)
* Modified the pool stats by not storing any monotonically increasing values as they overflow. Instead provided various callbacks which can be used to infer these stats.
* Removed the use of semaphores as they are easily replaced by an AtomicInteger. Also modified the method to update the max connections limit as atomic increment/decrements rather than a set, which is hard to make thread-safe and consistent without synchronization. (Discussed partially under issue #83)
* Fixed issue #82, #76 and #79

There are three pending tasks after this change:

* Provide a "cleanup thread" (using a threadpool) to cleanup idle connections.
* Provide a composite pool stats object encompassing multiple connection pools.
* Provide another PoolLimitDeterminationStrategy for max connections across pools which can be used to enforce connection limits over a pool of servers.