public class

RouteSpecificPool

extends Object
java.lang.Object
   ↳ org.apache.http.impl.conn.tsccm.RouteSpecificPool

Class Overview

A connection sub-pool for a specific route, used by ConnPoolByRoute. The methods in this class are unsynchronized. It is expected that the containing pool takes care of synchronization.

Summary

Fields
protected final LinkedList<BasicPoolEntry> freeEntries The list of free entries.
protected final int maxEntries the maximum number of entries allowed for this pool
protected int numEntries The number of created entries.
protected final HttpRoute route The route this pool is for.
protected final Queue<WaitingThread> waitingThreads The list of threads waiting for this pool.
Public Constructors
RouteSpecificPool(HttpRoute route, int maxEntries)
Creates a new route-specific pool.
Public Methods
BasicPoolEntry allocEntry(Object state)
Obtains a free entry from this pool, if one is available.
void createdEntry(BasicPoolEntry entry)
Indicates creation of an entry for this pool.
boolean deleteEntry(BasicPoolEntry entry)
Deletes an entry from this pool.
void dropEntry()
Forgets about an entry from this pool.
void freeEntry(BasicPoolEntry entry)
Returns an allocated entry to this pool.
int getCapacity()
Return remaining capacity of this pool
final int getEntryCount()
Obtains the number of entries.
final int getMaxEntries()
Obtains the maximum number of entries allowed for this pool.
final HttpRoute getRoute()
Obtains the route for which this pool is specific.
boolean hasThread()
Checks whether there is a waiting thread in this pool.
boolean isUnused()
Indicates whether this pool is unused.
WaitingThread nextThread()
Returns the next thread in the queue.
void queueThread(WaitingThread wt)
Adds a waiting thread.
void removeThread(WaitingThread wt)
Removes a waiting thread, if it is queued.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected final LinkedList<BasicPoolEntry> freeEntries

Since: API Level 1

The list of free entries. This list is managed LIFO, to increase idle times and allow for closing connections that are not really needed.

protected final int maxEntries

Since: API Level 1

the maximum number of entries allowed for this pool

protected int numEntries

Since: API Level 1

The number of created entries.

protected final HttpRoute route

Since: API Level 1

The route this pool is for.

protected final Queue<WaitingThread> waitingThreads

Since: API Level 1

The list of threads waiting for this pool.

Public Constructors

public RouteSpecificPool (HttpRoute route, int maxEntries)

Since: API Level 1

Creates a new route-specific pool.

Parameters
route the route for which to pool
maxEntries the maximum number of entries allowed for this pool

Public Methods

public BasicPoolEntry allocEntry (Object state)

Since: API Level 1

Obtains a free entry from this pool, if one is available.

Returns
  • an available pool entry, or null if there is none

public void createdEntry (BasicPoolEntry entry)

Since: API Level 1

Indicates creation of an entry for this pool. The entry will not be added to the list of free entries, it is only recognized as belonging to this pool now. It can then be passed to freeEntry.

Parameters
entry the entry that was created for this pool

public boolean deleteEntry (BasicPoolEntry entry)

Since: API Level 1

Deletes an entry from this pool. Only entries that are currently free in this pool can be deleted. Allocated entries can not be deleted.

Parameters
entry the entry to delete from this pool
Returns
  • true if the entry was found and deleted, or false if the entry was not found

public void dropEntry ()

Since: API Level 1

Forgets about an entry from this pool. This method is used to indicate that an entry allocated from this pool has been lost and will not be returned.

public void freeEntry (BasicPoolEntry entry)

Since: API Level 1

Returns an allocated entry to this pool.

Parameters
entry the entry obtained from allocEntry or presented to createdEntry

public int getCapacity ()

Since: API Level 1

Return remaining capacity of this pool

Returns
  • capacity

public final int getEntryCount ()

Since: API Level 1

Obtains the number of entries. This includes not only the free entries, but also those that have been created and are currently issued to an application.

Returns
  • the number of entries for the route of this pool

public final int getMaxEntries ()

Since: API Level 1

Obtains the maximum number of entries allowed for this pool.

Returns
  • the max entry number

public final HttpRoute getRoute ()

Since: API Level 1

Obtains the route for which this pool is specific.

Returns
  • the route

public boolean hasThread ()

Since: API Level 1

Checks whether there is a waiting thread in this pool.

Returns
  • true if there is a waiting thread, false otherwise

public boolean isUnused ()

Since: API Level 1

Indicates whether this pool is unused. A pool is unused if there is neither an entry nor a waiting thread. All entries count, not only the free but also the allocated ones.

Returns
  • true if this pool is unused, false otherwise

public WaitingThread nextThread ()

Since: API Level 1

Returns the next thread in the queue.

Returns
  • a waiting thread, or null if there is none

public void queueThread (WaitingThread wt)

Since: API Level 1

Adds a waiting thread. This pool makes no attempt to match waiting threads with pool entries. It is the caller's responsibility to check that there is no entry before adding a waiting thread.

Parameters
wt the waiting thread

public void removeThread (WaitingThread wt)

Since: API Level 1

Removes a waiting thread, if it is queued.

Parameters
wt the waiting thread