Search in sources :

Example 1 with HostConnections

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);
}
Also used : HttpRoute(org.apache.http.conn.routing.HttpRoute) HostConnections(org.apache.synapse.transport.passthru.connections.HostConnections)

Example 2 with HostConnections

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());
}
Also used : HostConnections(org.apache.synapse.transport.passthru.connections.HostConnections)

Example 3 with HostConnections

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);
    }
}
Also used : HttpRoute(org.apache.http.conn.routing.HttpRoute) HttpContext(org.apache.http.protocol.HttpContext) ProxyTunnelHandler(org.apache.synapse.transport.http.conn.ProxyTunnelHandler) HostConnections(org.apache.synapse.transport.passthru.connections.HostConnections)

Example 4 with HostConnections

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());
}
Also used : HostConnections(org.apache.synapse.transport.passthru.connections.HostConnections)

Example 5 with HostConnections

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();
}
Also used : HostConnections(org.apache.synapse.transport.passthru.connections.HostConnections)

Aggregations

HostConnections (org.apache.synapse.transport.passthru.connections.HostConnections)6 HttpRoute (org.apache.http.conn.routing.HttpRoute)2 HttpContext (org.apache.http.protocol.HttpContext)1 ProxyTunnelHandler (org.apache.synapse.transport.http.conn.ProxyTunnelHandler)1