• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
AbstractConnPool Class Referenceabstract

An abstract connection pool. More...

Inheritance diagram for AbstractConnPool:
RefQueueHandler ConnPoolByRoute

Description

It is used by the com.good.gd.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager. The abstract pool includes a poolLock, which is used to synchronize access to the internal pool datastructures. Don't use synchronized for that purpose!

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

void enableConnectionGC () throws IllegalStateException
 Enables connection garbage collection (GC). More...
 
final BasicPoolEntry getEntry (HttpRoute route, Object state, long timeout, TimeUnit tunit) throws ConnectionPoolTimeoutException, InterruptedException
 Obtains a pool entry with a connection within the given timeout. More...
 
abstract PoolEntryRequest requestPoolEntry (HttpRoute route, Object state)
 Returns a new com.good.gd.apache.http.impl.conn.tsccm.PoolEntryRequest, from which a com.good.gd.apache.http.impl.conn.tsccm.BasicPoolEntry can be obtained, or the request can be aborted. More...
 
abstract void freeEntry (BasicPoolEntry entry, boolean reusable, long validDuration, TimeUnit timeUnit)
 Returns an entry into the pool. More...
 
void closeIdleConnections (long idletime, TimeUnit tunit)
 Closes idle connections. More...
 
abstract void deleteClosedConnections ()
 Deletes all entries for closed connections.
 
void shutdown ()
 Shuts down this pool and all associated resources. More...
 
- Public Member Functions inherited from RefQueueHandler
void handleReference (Reference<?> ref)
 Invoked when a reference is found on the queue. More...
 

Protected Member Functions

 AbstractConnPool ()
 Creates a new connection pool.
 
abstract void handleLostEntry (HttpRoute route)
 Handles cleaning up for a lost pool entry with the given route. More...
 
void closeConnection (final OperatedClientConnection conn)
 Closes a connection from this pool. More...
 

Protected Attributes

final Lock poolLock
 The global lock for this pool.
 
Set< BasicPoolEntryRefissuedConnections
 References to issued connections. More...
 
IdleConnectionHandler idleConnHandler
 The handler for idle connections. More...
 
int numConnections
 The current total number of connections. More...
 
ReferenceQueue< Object > refQueue
 A reference queue to track loss of pool entries to GC. More...
 
volatile boolean isShutDown
 Indicates whether this pool is shut down. More...
 

Member Function Documentation

◆ enableConnectionGC()

void enableConnectionGC ( ) throws IllegalStateException

This method must be called immediately after creating the connection pool. It is not possible to enable connection GC after pool entries have been created. Neither is it possible to disable connection GC.

Exceptions
IllegalStateExceptionif connection GC is already enabled, or if it cannot be enabled because there already are pool entries

◆ getEntry()

final BasicPoolEntry getEntry ( HttpRoute  route,
Object  state,
long  timeout,
TimeUnit  tunit 
) throws ConnectionPoolTimeoutException, InterruptedException
Parameters
routethe route for which to get the connection
state
timeoutthe timeout, 0 or negative for no timeout
tunitthe unit for the timeout, may be null only if there is no timeout
Returns
pool entry holding a connection for the route
Exceptions
ConnectionPoolTimeoutExceptionif the timeout expired
InterruptedExceptionif the calling thread was interrupted

◆ requestPoolEntry()

abstract PoolEntryRequest requestPoolEntry ( HttpRoute  route,
Object  state 
)
abstract
Parameters
route
state

Reimplemented in ConnPoolByRoute.

◆ freeEntry()

abstract void freeEntry ( BasicPoolEntry  entry,
boolean  reusable,
long  validDuration,
TimeUnit  timeUnit 
)
abstract

The connection of the entry is expected to be in a suitable state, either open and re-usable, or closed. The pool will not make any attempt to determine whether it can be re-used or not.

Parameters
entrythe entry for the connection to release
reusabletrue if the entry is deemed reusable, false otherwise.
validDurationThe duration that the entry should remain free and reusable.
timeUnitThe unit of time the duration is measured in.

Reimplemented in ConnPoolByRoute.

◆ handleLostEntry()

abstract void handleLostEntry ( HttpRoute  route)
abstractprotected

A lost pool entry corresponds to a connection that was garbage collected instead of being properly released.

Parameters
routethe route of the pool entry that was lost

Reimplemented in ConnPoolByRoute.

◆ closeIdleConnections()

void closeIdleConnections ( long  idletime,
TimeUnit  tunit 
)
Parameters
idletimethe time the connections should have been idle in order to be closed now
tunitthe unit for the idletime

◆ shutdown()

void shutdown ( )

Overriding methods MUST call the implementation here!

Reimplemented in ConnPoolByRoute.

◆ closeConnection()

void closeConnection ( final OperatedClientConnection  conn)
protected
Parameters
connthe connection to close, or null

Member Data Documentation

◆ issuedConnections

Set<BasicPoolEntryRef> issuedConnections
protected

Objects in this set are of class BasicPoolEntryRef , and point to the pool entry for the issued connection. GCed connections are detected by the missing pool entries.

◆ idleConnHandler

IdleConnectionHandler idleConnHandler
protected

◆ numConnections

int numConnections
protected

◆ refQueue

ReferenceQueue<Object> refQueue
protected

The same queue is used to track loss of the connection manager, so we cannot specialize the type.

◆ isShutDown

volatile boolean isShutDown
protected