Refine search
/** * Tracks tunnelling to the target. * * @param secure <code>true</code> if the route is secure, * <code>false</code> otherwise */ public final void tunnelTarget(final boolean secure) { Asserts.check(this.connected, "No tunnel unless connected"); Asserts.notNull(this.proxyChain, "No tunnel without proxy"); this.tunnelled = TunnelType.TUNNELLED; this.secure = secure; }
@Override public HttpRequest generateRequest() throws IOException, HttpException { Asserts.check(this.requestProducerRef.get() == null, "Inconsistent state: request producer is not null"); final HttpAsyncRequestProducer requestProducer = this.requestProducerQueue.poll(); if (requestProducer == null) { return null; } this.requestProducerRef.set(requestProducer); final HttpRequest request = requestProducer.generateRequest(); this.httppocessor.process(request, this.localContext); this.requestQueue.add(request); return request; }
if (timeout > 0) { deadline = new Date (System.currentTimeMillis() + tunit.toMillis(timeout)); Asserts.check(!shutdown, "Connection pool shut down"); log.debug("[" + route + "] total kept alive: " + freeConnections.size() + ", total issued: " + leasedConnections.size() + ", total allocated: " + numConnections + " out of " + maxTotalConnections); } else if (hasCapacity && !freeConnections.isEmpty()) { try { rospl.queueThread(waitingThread); waitingThreads.add(waitingThread); success = waitingThread.await(deadline);
final Object state, final long keepalive, final TimeUnit tunit) { Args.notNull(conn, "Connection"); Asserts.check(conn == this.conn, "Connection not obtained from this manager"); if (this.log.isDebugEnabled()) { this.log.debug("Releasing connection " + conn); this.expiry = this.updated + tunit.toMillis(keepalive); } else { this.expiry = Long.MAX_VALUE;
@Override public void responseCompleted() throws IOException { final HttpAsyncResponseConsumer<T> responseConsumer = this.responseConsumerRef.getAndSet(null); Asserts.check(responseConsumer != null, "Inconsistent state: response consumer is null"); try { if (!this.keepAlive.get()) { final Exception ex = responseConsumer.getException(); if (result != null) { this.resultQueue.add(result); } else { this.future.failed(ex); if (!this.future.isDone() && this.responseConsumerQueue.isEmpty()) { this.future.completed(new ArrayList<T>(this.resultQueue)); this.resultQueue.clear();
@Override public void consumeContent( final ContentDecoder decoder, final IOControl ioctrl) throws IOException { final HttpAsyncResponseConsumer<T> responseConsumer = this.responseConsumerRef.get(); Asserts.check(responseConsumer != null, "Inconsistent state: response consumer is null"); responseConsumer.consumeContent(decoder, ioctrl); }
public void releaseConnection( final ManagedClientConnection conn, final long validDuration, final TimeUnit timeUnit) { Args.check(conn instanceof ConnAdapter, "Connection class mismatch, " + "connection not obtained from this manager"); assertStillUp(); Asserts.check(manager == this, "Connection not obtained from this manager"); try { lastReleaseTime = System.currentTimeMillis(); if(validDuration > 0) { connectionExpiresTime = timeUnit.toMillis(validDuration) + lastReleaseTime; } else { connectionExpiresTime = Long.MAX_VALUE;
final NHttpServerConnection conn) throws IOException, HttpException { final State state = getState(conn); Asserts.notNull(state, "Connection state"); Asserts.check(state.getResponseState() == MessageState.READY || state.getResponseState() == MessageState.INIT, "Unexpected response state %s", state.getResponseState()); Asserts.notNull(outgoing, "Outgoing response"); if (state.getResponseState() == MessageState.READY) { final Queue<PipelineEntry> pipeline = state.getPipeline(); final PipelineEntry pipelineEntry = pipeline.poll(); if (pipelineEntry == null) { conn.suspendOutput(); throw ex; } catch (Exception ex) { pipeline.add(new PipelineEntry( request, null,
final NHttpClientConnection conn) throws IOException, HttpException { final State state = getState(conn); Asserts.notNull(state, "Connection state"); Asserts.check(state.getRequestState() == MessageState.READY || state.getRequestState() == MessageState.COMPLETED, "Unexpected request state %s", state.getRequestState()); state.getRequestQueue().add(request);
final NHttpClientConnection conn) throws HttpException, IOException { final State state = getState(conn); Asserts.notNull(state, "Connection state"); Asserts.check(state.getResponseState() == MessageState.READY, "Unexpected request state %s", state.getResponseState()); Asserts.notNull(handler, "Client exchange handler"); request = state.getRequestQueue().poll(); Asserts.notNull(request, "HTTP request"); } else { request = state.getRequest();
Args.notNull(route, "Route"); Asserts.check(!this.isShutDown, "Connection pool shut down"); private final AtomicReference<E> entryRef = new AtomicReference<E>(null);
final NHttpServerConnection conn) throws IOException, HttpException { final State state = getState(conn); Asserts.notNull(state, "Connection state"); Asserts.check(state.getRequestState() == MessageState.READY, "Unexpected request state %s", state.getRequestState()); && state.getPipeline().isEmpty() && !(conn instanceof SessionBufferStatus && ((SessionBufferStatus) conn).hasBufferedInput())) {
public void connect( final HttpClientConnection conn, final HttpRoute route, final int connectTimeout, final HttpContext context) throws IOException { Args.notNull(conn, "Connection"); Args.notNull(route, "HTTP route"); Asserts.check(conn == this.conn, "Connection not obtained from this manager"); final HttpHost host; if (route.getProxyHost() != null) { host = route.getProxyHost(); } else { host = route.getTargetHost(); } final InetSocketAddress localAddress = route.getLocalSocketAddress(); this.connectionOperator.connect(this.conn, host, localAddress, connectTimeout, this.socketConfig, context); }
@Override public void upgrade( final HttpClientConnection conn, final HttpRoute route, final HttpContext context) throws IOException { Args.notNull(conn, "Connection"); Args.notNull(route, "HTTP route"); Asserts.check(conn == this.conn, "Connection not obtained from this manager"); this.connectionOperator.upgrade(this.conn, route.getTargetHost(), context); }
/** * Tracks connecting to the first proxy. * * @param proxy the proxy connected to * @param secure {@code true} if the route is secure, * {@code false} otherwise */ public final void connectProxy(final HttpHost proxy, final boolean secure) { Args.notNull(proxy, "Proxy host"); Asserts.check(!this.connected, "Already connected"); this.connected = true; this.proxyChain = new HttpHost[]{ proxy }; this.secure = secure; }
@Override public HttpRoute determineRoute(final HttpHost target, final HttpRequest request, final HttpContext context) throws HttpException { Args.notNull(request, "HTTP request"); // If we have a forced route, we can do without a target. HttpRoute route = ConnRouteParams.getForcedRoute(request.getParams()); if (route != null) { return route; } // If we get here, there is no forced route. // So we need a target to compute a route. Asserts.notNull(target, "Target host"); final InetAddress local = ConnRouteParams.getLocalAddress(request.getParams()); final HttpHost proxy = determineProxy(target, request, context); final Scheme schm = this.schemeRegistry.getScheme(target.getSchemeName()); // as it is typically used for TLS/SSL, we assume that // a layered scheme implies a secure connection final boolean secure = schm.isLayered(); if (proxy == null) { route = new HttpRoute(target, local, secure); } else { route = new HttpRoute(target, local, proxy, secure); } return route; }
public void connect( final HttpClientConnection conn, final HttpRoute route, final int connectTimeout, final HttpContext context) throws IOException { Args.notNull(conn, "Connection"); Args.notNull(route, "HTTP route"); Asserts.check(conn == this.conn, "Connection not obtained from this manager"); final HttpHost host; if (route.getProxyHost() != null) { host = route.getProxyHost(); } else { host = route.getTargetHost(); } final InetSocketAddress localAddress = route.getLocalAddress() != null ? new InetSocketAddress(route.getLocalAddress(), 0) : null;; this.connectionOperator.connect(this.conn, host, localAddress, connectTimeout, this.socketConfig, context); }