/** * Tracks connecting to the target. * * @param secure {@code true} if the route is secure, * {@code false} otherwise */ public final void connectTarget(final boolean secure) { Asserts.check(!this.connected, "Already connected"); this.connected = true; this.secure = secure; }
/** * Tracks layering a protocol. * * @param secure {@code true} if the route is secure, * {@code false} otherwise */ public final void layerProtocol(final boolean secure) { // it is possible to layer a protocol over a direct connection, // although this case is probably not considered elsewhere Asserts.check(this.connected, "No layered protocol unless connected"); this.layered = LayerType.LAYERED; this.secure = secure; }
private T ensureRunning() { final T ioReactor = ioReactorRef.get(); Asserts.check(ioReactor != null, "I/O reactor has not been started"); return ioReactor; }
/** * Removes the header that was returned last. */ @Override public void remove() throws UnsupportedOperationException { Asserts.check(this.lastIndex >= 0, "No header to remove"); this.allHeaders.remove(this.lastIndex); this.lastIndex = -1; this.currentIndex--; // adjust for the removed element }
private T ensureRunning() { final T ioReactor = ioReactorRef.get(); Asserts.check(ioReactor != null, "I/O reactor has not been started"); return ioReactor; }
/** * Removes the header that was returned last. */ @Override public void remove() throws UnsupportedOperationException { Asserts.check(this.lastIndex >= 0, "No header to remove"); this.allHeaders.remove(this.lastIndex); this.lastIndex = -1; this.currentIndex--; // adjust for the removed element }
private void ensureNotCommitted() { Asserts.check(!responseCommitted.get(), "Response already committed"); }
public void free(final PoolEntry<T, C> entry, final boolean reusable) { final boolean found = this.leased.remove(entry); Asserts.check(found, "Entry %s has not been leased from this pool", entry); if (reusable) { this.available.addFirst(entry); } }
public void free(final PoolEntry<T, C> entry, final boolean reusable) { final boolean found = this.leased.remove(entry); Asserts.check(found, "Entry %s has not been leased from this pool", entry); if (reusable) { this.available.addFirst(entry); } }
/** * Tracks tunnelling to the target. * * @param secure {@code true} if the route is secure, * {@code false} 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; }
public void execute( final AsyncClientExchangeHandler exchangeHandler, final HandlerFactory<AsyncPushConsumer> pushHandlerFactory, final HttpContext context) { Asserts.check(!closed.get(), "Connection is already closed"); final Command executionCommand = new RequestExecutionCommand(exchangeHandler, pushHandlerFactory, null, context); execute(executionCommand, Command.Priority.NORMAL); }
public void execute( final AsyncClientExchangeHandler exchangeHandler, final HandlerFactory<AsyncPushConsumer> pushHandlerFactory, final HttpContext context) { Asserts.check(!closed.get(), "Connection is already closed"); final Command executionCommand = new RequestExecutionCommand(exchangeHandler, pushHandlerFactory, null, context); execute(executionCommand, Command.Priority.NORMAL); }
private void evict() { while (currentSize > maxSize) { final HPackHeader header = headers.removeLast(); if (header != null) { currentSize -= header.getTotalSize(); } else { Asserts.check(currentSize == 0, "Current table size must be zero"); break; } } }
ManagedHttpClientConnection getValidatedConnection() { final ManagedHttpClientConnection conn = getConnection(); Asserts.check(conn.isOpen(), "Endpoint is not connected"); return conn; }
@Override public Future<PoolEntry<T, C>> lease( final T route, final Object state, final Timeout requestTimeout, final FutureCallback<PoolEntry<T, C>> callback) { Args.notNull(route, "Route"); Asserts.check(!isShutDown.get(), "Connection pool shut down"); final PerRoutePool<T, C> routePool = getPool(route); return routePool.lease(state, requestTimeout, callback); }
@Override public Future<PoolEntry<T, C>> lease( final T route, final Object state, final Timeout requestTimeout, final FutureCallback<PoolEntry<T, C>> callback) { Args.notNull(route, "Route"); Asserts.check(!isShutDown.get(), "Connection pool shut down"); final PerRoutePool<T, C> routePool = getPool(route); return routePool.lease(state, requestTimeout, callback); }
PoolEntry<HttpRoute, ManagedAsyncClientConnection> getValidatedPoolEntry() { final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry = getPoolEntry(); final ManagedAsyncClientConnection connection = poolEntry.getConnection(); Asserts.check(connection != null && connection.isOpen(), "Endpoint is not connected"); return poolEntry; }
PoolEntry<HttpRoute, ManagedHttpClientConnection> getValidatedPoolEntry() { final PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry = getPoolEntry(); final ManagedHttpClientConnection connection = poolEntry.getConnection(); Asserts.check(connection != null && connection.isOpen(), "Endpoint is not connected"); return poolEntry; }
@Test(expected=IllegalStateException.class) public void testExpressionCheckFail() { Asserts.check(false, "Oopsie"); }
@Override public int write(final ByteBuffer src) throws IOException { if (src == null) { return 0; } Asserts.check(!isCompleted(), "Decoding process already completed"); return this.channel().write(src); }