use of org.apache.synapse.transport.passthru.connections.HostConnections in project wso2-synapse by wso2.
the class ClientIODispatch method createConnection.
@Override
protected DefaultNHttpClientConnection createConnection(final IOSession session) {
HostConnections hostConnections = (HostConnections) session.getAttribute(IOSession.ATTACHMENT_KEY);
HttpRoute route = hostConnections.getRoute();
return this.connFactory.createConnection(session, route);
}
use of org.apache.synapse.transport.passthru.connections.HostConnections in project wso2-synapse by wso2.
the class ConnectCallback method cancelled.
public void cancelled(SessionRequest request) {
HostConnections pool = (HostConnections) request.getAttachment();
pool.pendingConnectionFailed();
deliveryAgent.errorConnecting(pool.getRoute(), ErrorCodes.CONNECT_CANCEL, "Connection Cancel");
handleError("Connection cancelled for : " + request.getRemoteAddress());
}
use of org.apache.synapse.transport.passthru.connections.HostConnections in project wso2-synapse by wso2.
the class TargetHandler method connected.
public void connected(NHttpClientConnection conn, Object o) {
assert o instanceof HostConnections : "Attachment should be a HostConnections";
HostConnections pool = (HostConnections) o;
conn.getContext().setAttribute(PassThroughConstants.CONNECTION_POOL, pool);
HttpRoute route = pool.getRoute();
// create the connection information and set it to request ready
TargetContext.create(conn, ProtocolState.REQUEST_READY, targetConfiguration);
// notify the pool about the new connection
targetConfiguration.getConnections().addConnection(conn);
// notify about the new connection
deliveryAgent.connected(pool.getRoute(), conn);
HttpContext context = conn.getContext();
context.setAttribute(PassThroughConstants.REQ_DEPARTURE_TIME, System.currentTimeMillis());
metrics.connected();
if (route.isTunnelled()) {
// Requires a proxy tunnel
ProxyTunnelHandler tunnelHandler = new ProxyTunnelHandler(route, connFactory);
context.setAttribute(PassThroughConstants.TUNNEL_HANDLER, tunnelHandler);
}
}
use of org.apache.synapse.transport.passthru.connections.HostConnections in project wso2-synapse by wso2.
the class ConnectCallback method failed.
public void failed(SessionRequest request) {
HostConnections pool = (HostConnections) request.getAttachment();
pool.pendingConnectionFailed();
deliveryAgent.errorConnecting(pool.getRoute(), ErrorCodes.CONNECTION_FAILED, "Connection Failed");
handleError("Connection refused or failed for : " + request.getRemoteAddress());
}
use of org.apache.synapse.transport.passthru.connections.HostConnections in project wso2-synapse by wso2.
the class ConnectCallback method timeout.
public void timeout(SessionRequest request) {
HostConnections pool = (HostConnections) request.getAttachment();
pool.pendingConnectionFailed();
deliveryAgent.errorConnecting(pool.getRoute(), ErrorCodes.CONNECT_TIMEOUT, "Connection Timeout");
handleError("Timeout connecting to : " + request.getRemoteAddress());
request.cancel();
}
Aggregations