AbstractConnPool
@Deprecated public class ConnPoolByRoute extends AbstractConnPool
MultiThreadedHttpConnectionManager ,见原作者。
它实现了连接重用和连接每个主机强制的相同算法:
poolLock进行池数据结构的访问,而不是通过synchronized方法进行访问。
| Modifier and Type | Field and Description |
|---|---|
protected ConnPerRoute |
connPerRoute
已过时。
每个路由查找连接
|
protected Queue<BasicPoolEntry> |
freeConnections
已过时。
免费连接列表
|
protected Set<BasicPoolEntry> |
leasedConnections
已过时。
参考发出的连接
|
protected int |
maxTotalConnections
已过时。
|
protected int |
numConnections
已过时。
|
protected ClientConnectionOperator |
operator
已过时。
此池的连接运算符
|
protected Map<HttpRoute,RouteSpecificPool> |
routeToPool
已过时。
路线专用池的映射
|
protected boolean |
shutdown
已过时。
|
protected Queue<WaitingThread> |
waitingThreads
已过时。
WaitingThreads等待连接的列表
|
idleConnHandler, isShutDown, issuedConnections, refQueue| Constructor and Description |
|---|
ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections)
已过时。
创建一个新的连接池,由路由管理。
|
ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit)
已过时。
|
ConnPoolByRoute(ClientConnectionOperator operator, HttpParams params)
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeExpiredConnections()
已过时。
|
void |
closeIdleConnections(long idletime, TimeUnit tunit)
已过时。
关闭空闲连接。
|
protected BasicPoolEntry |
createEntry(RouteSpecificPool rospl, ClientConnectionOperator op)
已过时。
创建一个新的池条目。
|
protected Queue<BasicPoolEntry> |
createFreeConnQueue()
已过时。
创建队列
freeConnections 。
|
protected Map<HttpRoute,RouteSpecificPool> |
createRouteToPoolMap()
已过时。
创建
routeToPool的地图。
|
protected Queue<WaitingThread> |
createWaitingThreadQueue()
已过时。
创建队列为
waitingThreads 。
|
void |
deleteClosedConnections()
已过时。
删除所有连接关闭的条目。
|
protected void |
deleteEntry(BasicPoolEntry entry)
已过时。
删除给定的池条目。
|
protected void |
deleteLeastUsedEntry()
已过时。
删除一个旧的,免费的池条目,为新的空间腾出空间。
|
void |
freeEntry(BasicPoolEntry entry, boolean reusable, long validDuration, TimeUnit timeUnit)
已过时。
返回到池中的条目。
|
int |
getConnectionsInPool()
已过时。
|
int |
getConnectionsInPool(HttpRoute route)
已过时。
|
protected BasicPoolEntry |
getEntryBlocking(HttpRoute route, Object state, long timeout, TimeUnit tunit, WaitingThreadAborter aborter)
已过时。
在给定的超时内获取连接的池条目。
|
protected BasicPoolEntry |
getFreeEntry(RouteSpecificPool rospl, Object state)
已过时。
如果可用,请获取路线的空闲池条目。
|
protected Lock |
getLock()
已过时。
|
int |
getMaxTotalConnections()
已过时。
自4.1
|
protected RouteSpecificPool |
getRoutePool(HttpRoute route, boolean create)
已过时。
获取可用连接的路由特定池。
|
protected void |
handleLostEntry(HttpRoute route)
已过时。
|
protected RouteSpecificPool |
newRouteSpecificPool(HttpRoute route)
已过时。
创建一个新的路由特定池。
|
protected WaitingThread |
newWaitingThread(Condition cond, RouteSpecificPool rospl)
已过时。
创建一个新的等待线程。
|
protected void |
notifyWaitingThread(RouteSpecificPool rospl)
已过时。
通知等待线程连接可用。
|
PoolEntryRequest |
requestPoolEntry(HttpRoute route, Object state)
已过时。
返回一个新的 PoolEntryRequest ,从中可以获得BasicPoolEntry ,或者请求可以中止。
|
void |
setMaxTotalConnections(int max)
已过时。
自4.1
|
void |
shutdown()
已过时。
关闭此池和所有相关资源。
|
closeConnection, enableConnectionGC, getEntry, handleReferenceprotected final ClientConnectionOperator operator
protected final ConnPerRoute connPerRoute
protected final Set<BasicPoolEntry> leasedConnections
protected final Queue<BasicPoolEntry> freeConnections
protected final Queue<WaitingThread> waitingThreads
protected final Map<HttpRoute,RouteSpecificPool> routeToPool
protected volatile boolean shutdown
protected volatile int maxTotalConnections
protected volatile int numConnections
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections)
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit)
@Deprecated public ConnPoolByRoute(ClientConnectionOperator operator, HttpParams params)
protected Lock getLock()
protected Queue<BasicPoolEntry> createFreeConnQueue()
freeConnections 。
由构造函数调用一次。
protected Queue<WaitingThread> createWaitingThreadQueue()
waitingThreads 。
由构造函数调用一次。
protected Map<HttpRoute,RouteSpecificPool> createRouteToPoolMap()
routeToPool的地图。
由构造函数调用一次。
protected RouteSpecificPool newRouteSpecificPool(HttpRoute route)
getRoutePool(org.apache.http.conn.routing.HttpRoute, boolean) 。
route - 路线
protected WaitingThread newWaitingThread(Condition cond, RouteSpecificPool rospl)
getRoutePool(org.apache.http.conn.routing.HttpRoute, boolean) 。
cond - 等待的条件
rospl - 路由特定池,或
null
protected RouteSpecificPool getRoutePool(HttpRoute route, boolean create)
route - 路线
create - 是否创建池(如果不存在)
null如果
create是
true
public int getConnectionsInPool(HttpRoute route)
public int getConnectionsInPool()
public PoolEntryRequest requestPoolEntry(HttpRoute route, Object state)
AbstractConnPool复制
PoolEntryRequest ,从中可以获得BasicPoolEntry ,或者请求可以中止。
requestPoolEntry在
AbstractConnPool
route - 路线
state - 状态
protected BasicPoolEntry getEntryBlocking(HttpRoute route, Object state, long timeout, TimeUnit tunit, WaitingThreadAborter aborter) throws ConnectionPoolTimeoutException, InterruptedException
WaitingThread被用来阻塞, WaitingThreadAborter.setWaitingThread(WaitingThread)必须在阻塞之前调用,才允许线程中断。
route - 获取连接的路由
timeout - 超时,0或否定超时
tunit -为对所述单元
timeout ,可以是
null只有如果没有超时
aborter - 一个可以中止WaitingThread的对象。
ConnectionPoolTimeoutException - 如果超时过期
InterruptedException - 如果调用线程中断
public void freeEntry(BasicPoolEntry entry, boolean reusable, long validDuration, TimeUnit timeUnit)
AbstractConnPool复制
freeEntry在类
AbstractConnPool
entry - 释放连接的条目
reusable -
true如果该条目被视为可重用,否则为
false 。
validDuration - 条目应保持自由和可重用的持续时间。
timeUnit - 测量持续时间的时间单位
protected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl, Object state)
rospl - 从中获取条目的路由特定池
null
protected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op)
rospl - 要为其创建条目的路由特定池
op - 创建连接的操作员
protected void deleteEntry(BasicPoolEntry entry)
注意:不从freeConnections列表中删除该条目。 假定主叫方已经处理了这一步。
entry - 要删除的连接的池条目
protected void deleteLeastUsedEntry()
protected void handleLostEntry(HttpRoute route)
handleLostEntry在
AbstractConnPool
protected void notifyWaitingThread(RouteSpecificPool rospl)
rospl - 要通知的池,或
null
public void deleteClosedConnections()
AbstractConnPool复制
deleteClosedConnections在
AbstractConnPool
public void closeIdleConnections(long idletime,
TimeUnit tunit)
closeIdleConnections在类
AbstractConnPool
idletime - 连接应该空闲的时间,以便现在关闭
tunit - 单位为
idletime
public void closeExpiredConnections()
public void shutdown()
AbstractConnPool复制
shutdown在
AbstractConnPool
public void setMaxTotalConnections(int max)
public int getMaxTotalConnections()
Copyright © 1999–2017 The Apache Software Foundation. All rights reserved.