Java 类org.apache.http.conn.routing.RouteTracker 实例源码
项目:lams
文件:HttpPoolEntry.java
public HttpPoolEntry(
final Log log,
final String id,
final HttpRoute route,
final OperatedClientConnection conn,
final long timeToLive, final TimeUnit tunit) {
super(id, route, conn, timeToLive, tunit);
this.log = log;
this.tracker = new RouteTracker(route);
}
项目:purecloud-iot
文件:HttpPoolEntry.java
public HttpPoolEntry(
final Log log,
final String id,
final HttpRoute route,
final OperatedClientConnection conn,
final long timeToLive, final TimeUnit tunit) {
super(id, route, conn, timeToLive, tunit);
this.log = log;
this.tracker = new RouteTracker(route);
}
项目:purecloud-iot
文件:AbstractPoolEntry.java
/**
* Opens the underlying connection.
*
* @param route the route along which to open the connection
* @param context the context for opening the connection
* @param params the parameters for opening the connection
*
* @throws IOException in case of a problem
*/
public void open(final HttpRoute route,
final HttpContext context, final HttpParams params)
throws IOException {
Args.notNull(route, "Route");
Args.notNull(params, "HTTP parameters");
if (this.tracker != null) {
Asserts.check(!this.tracker.isConnected(), "Connection already open");
}
// - collect the arguments
// - call the operator
// - update the tracking data
// In this order, we can be sure that only a successful
// opening of the connection will be tracked.
this.tracker = new RouteTracker(route);
final HttpHost proxy = route.getProxyHost();
connOperator.openConnection
(this.connection,
(proxy != null) ? proxy : route.getTargetHost(),
route.getLocalAddress(),
context, params);
final RouteTracker localTracker = tracker; // capture volatile
// If this tracker was reset while connecting,
// fail early.
if (localTracker == null) {
throw new InterruptedIOException("Request aborted");
}
if (proxy == null) {
localTracker.connectTarget(this.connection.isSecure());
} else {
localTracker.connectProxy(proxy, this.connection.isSecure());
}
}
项目:lams
文件:SingleClientConnManager.java
/**
* Obtains a connection.
*
* @param route where the connection should point to
*
* @return a connection that can be used to communicate
* along the given route
*/
public ManagedClientConnection getConnection(HttpRoute route, Object state) {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
assertStillUp();
if (log.isDebugEnabled()) {
log.debug("Get connection for route " + route);
}
synchronized (this) {
if (managedConn != null)
throw new IllegalStateException(MISUSE_MESSAGE);
// check re-usability of the connection
boolean recreate = false;
boolean shutdown = false;
// Kill the connection if it expired.
closeExpiredConnections();
if (uniquePoolEntry.connection.isOpen()) {
RouteTracker tracker = uniquePoolEntry.tracker;
shutdown = (tracker == null || // can happen if method is aborted
!tracker.toRoute().equals(route));
} else {
// If the connection is not open, create a new PoolEntry,
// as the connection may have been marked not reusable,
// due to aborts -- and the PoolEntry should not be reused
// either. There's no harm in recreating an entry if
// the connection is closed.
recreate = true;
}
if (shutdown) {
recreate = true;
try {
uniquePoolEntry.shutdown();
} catch (IOException iox) {
log.debug("Problem shutting down connection.", iox);
}
}
if (recreate)
uniquePoolEntry = new PoolEntry();
managedConn = new ConnAdapter(uniquePoolEntry, route);
return managedConn;
}
}
项目:lams
文件:HttpPoolEntry.java
RouteTracker getTracker() {
return this.tracker;
}
项目:lams
文件:AbstractPoolEntry.java
/**
* Opens the underlying connection.
*
* @param route the route along which to open the connection
* @param context the context for opening the connection
* @param params the parameters for opening the connection
*
* @throws IOException in case of a problem
*/
public void open(HttpRoute route,
HttpContext context, HttpParams params)
throws IOException {
if (route == null) {
throw new IllegalArgumentException
("Route must not be null.");
}
if (params == null) {
throw new IllegalArgumentException
("Parameters must not be null.");
}
if ((this.tracker != null) && this.tracker.isConnected()) {
throw new IllegalStateException("Connection already open.");
}
// - collect the arguments
// - call the operator
// - update the tracking data
// In this order, we can be sure that only a successful
// opening of the connection will be tracked.
this.tracker = new RouteTracker(route);
final HttpHost proxy = route.getProxyHost();
connOperator.openConnection
(this.connection,
(proxy != null) ? proxy : route.getTargetHost(),
route.getLocalAddress(),
context, params);
RouteTracker localTracker = tracker; // capture volatile
// If this tracker was reset while connecting,
// fail early.
if (localTracker == null) {
throw new InterruptedIOException("Request aborted");
}
if (proxy == null) {
localTracker.connectTarget(this.connection.isSecure());
} else {
localTracker.connectProxy(proxy, this.connection.isSecure());
}
}
项目:purecloud-iot
文件:SingleClientConnManager.java
/**
* Obtains a connection.
*
* @param route where the connection should point to
*
* @return a connection that can be used to communicate
* along the given route
*/
public ManagedClientConnection getConnection(final HttpRoute route, final Object state) {
Args.notNull(route, "Route");
assertStillUp();
if (log.isDebugEnabled()) {
log.debug("Get connection for route " + route);
}
synchronized (this) {
Asserts.check(managedConn == null, MISUSE_MESSAGE);
// check re-usability of the connection
boolean recreate = false;
boolean shutdown = false;
// Kill the connection if it expired.
closeExpiredConnections();
if (uniquePoolEntry.connection.isOpen()) {
final RouteTracker tracker = uniquePoolEntry.tracker;
shutdown = (tracker == null || // can happen if method is aborted
!tracker.toRoute().equals(route));
} else {
// If the connection is not open, create a new PoolEntry,
// as the connection may have been marked not reusable,
// due to aborts -- and the PoolEntry should not be reused
// either. There's no harm in recreating an entry if
// the connection is closed.
recreate = true;
}
if (shutdown) {
recreate = true;
try {
uniquePoolEntry.shutdown();
} catch (final IOException iox) {
log.debug("Problem shutting down connection.", iox);
}
}
if (recreate) {
uniquePoolEntry = new PoolEntry();
}
managedConn = new ConnAdapter(uniquePoolEntry, route);
return managedConn;
}
}
项目:purecloud-iot
文件:HttpPoolEntry.java
RouteTracker getTracker() {
return this.tracker;
}
项目:cJUnit-mc626
文件:SingleClientConnManager.java
/**
* Obtains a connection.
*
* @param route where the connection should point to
*
* @return a connection that can be used to communicate
* along the given route
*/
public synchronized ManagedClientConnection getConnection(HttpRoute route, Object state) {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
assertStillUp();
if (log.isDebugEnabled()) {
log.debug("Get connection for route " + route);
}
if (managedConn != null)
throw new IllegalStateException(MISUSE_MESSAGE);
// check re-usability of the connection
boolean recreate = false;
boolean shutdown = false;
// Kill the connection if it expired.
closeExpiredConnections();
if (uniquePoolEntry.connection.isOpen()) {
RouteTracker tracker = uniquePoolEntry.tracker;
shutdown = (tracker == null || // can happen if method is aborted
!tracker.toRoute().equals(route));
} else {
// If the connection is not open, create a new PoolEntry,
// as the connection may have been marked not reusable,
// due to aborts -- and the PoolEntry should not be reused
// either. There's no harm in recreating an entry if
// the connection is closed.
recreate = true;
}
if (shutdown) {
recreate = true;
try {
uniquePoolEntry.shutdown();
} catch (IOException iox) {
log.debug("Problem shutting down connection.", iox);
}
}
if (recreate)
uniquePoolEntry = new PoolEntry();
managedConn = new ConnAdapter(uniquePoolEntry, route);
return managedConn;
}
项目:cJUnit-mc626
文件:AbstractPoolEntry.java
/**
* Opens the underlying connection.
*
* @param route the route along which to open the connection
* @param context the context for opening the connection
* @param params the parameters for opening the connection
*
* @throws IOException in case of a problem
*/
public void open(HttpRoute route,
HttpContext context, HttpParams params)
throws IOException {
if (route == null) {
throw new IllegalArgumentException
("Route must not be null.");
}
if (params == null) {
throw new IllegalArgumentException
("Parameters must not be null.");
}
if ((this.tracker != null) && this.tracker.isConnected()) {
throw new IllegalStateException("Connection already open.");
}
// - collect the arguments
// - call the operator
// - update the tracking data
// In this order, we can be sure that only a successful
// opening of the connection will be tracked.
this.tracker = new RouteTracker(route);
final HttpHost proxy = route.getProxyHost();
connOperator.openConnection
(this.connection,
(proxy != null) ? proxy : route.getTargetHost(),
route.getLocalAddress(),
context, params);
RouteTracker localTracker = tracker; // capture volatile
// If this tracker was reset while connecting,
// fail early.
if (localTracker == null) {
throw new IOException("Request aborted");
}
if (proxy == null) {
localTracker.connectTarget(this.connection.isSecure());
} else {
localTracker.connectProxy(proxy, this.connection.isSecure());
}
}