Methods Summary |
---|
public org.apache.http.impl.conn.tsccm.BasicPoolEntry | allocEntry(java.lang.Object state)Obtains a free entry from this pool, if one is available.
if (!freeEntries.isEmpty()) {
ListIterator<BasicPoolEntry> it = freeEntries.listIterator(freeEntries.size());
while (it.hasPrevious()) {
BasicPoolEntry entry = it.previous();
if (LangUtils.equals(state, entry.getState())) {
it.remove();
return entry;
}
}
}
if (!freeEntries.isEmpty()) {
BasicPoolEntry entry = freeEntries.remove();
entry.setState(null);
OperatedClientConnection conn = entry.getConnection();
try {
conn.close();
} catch (IOException ex) {
log.debug("I/O error closing connection", ex);
}
return entry;
}
return null;
|
public void | createdEntry(org.apache.http.impl.conn.tsccm.BasicPoolEntry entry)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 {@link #freeEntry freeEntry}.
if (!route.equals(entry.getPlannedRoute())) {
throw new IllegalArgumentException
("Entry not planned for this pool." +
"\npool: " + route +
"\nplan: " + entry.getPlannedRoute());
}
numEntries++;
|
public boolean | deleteEntry(org.apache.http.impl.conn.tsccm.BasicPoolEntry entry)Deletes an entry from this pool.
Only entries that are currently free in this pool can be deleted.
Allocated entries can not be deleted.
final boolean found = freeEntries.remove(entry);
if (found)
numEntries--;
return found;
|
public void | dropEntry()Forgets about an entry from this pool.
This method is used to indicate that an entry
{@link #allocEntry allocated}
from this pool has been lost and will not be returned.
if (numEntries < 1) {
throw new IllegalStateException
("There is no entry that could be dropped.");
}
numEntries--;
|
public void | freeEntry(org.apache.http.impl.conn.tsccm.BasicPoolEntry entry)Returns an allocated entry to this pool.
if (numEntries < 1) {
throw new IllegalStateException
("No entry created for this pool. " + route);
}
if (numEntries <= freeEntries.size()) {
throw new IllegalStateException
("No entry allocated from this pool. " + route);
}
freeEntries.add(entry);
|
public int | getCapacity()Return remaining capacity of this pool
return maxEntries - numEntries;
|
public final int | getEntryCount()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.
return numEntries;
|
public final int | getMaxEntries()Obtains the maximum number of entries allowed for this pool.
return maxEntries;
|
public final org.apache.http.conn.routing.HttpRoute | getRoute()Obtains the route for which this pool is specific.
return route;
|
public boolean | hasThread()Checks whether there is a waiting thread in this pool.
return !this.waitingThreads.isEmpty();
|
public boolean | isUnused()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.
return (numEntries < 1) && waitingThreads.isEmpty();
|
public org.apache.http.impl.conn.tsccm.WaitingThread | nextThread()Returns the next thread in the queue.
return this.waitingThreads.peek();
|
public void | queueThread(org.apache.http.impl.conn.tsccm.WaitingThread wt)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.
if (wt == null) {
throw new IllegalArgumentException
("Waiting thread must not be null.");
}
this.waitingThreads.add(wt);
|
public void | removeThread(org.apache.http.impl.conn.tsccm.WaitingThread wt)Removes a waiting thread, if it is queued.
if (wt == null)
return;
this.waitingThreads.remove(wt);
|