private void sendQuery(final DnsQuery query, final ChannelPromise writePromise) { if (parent.channelFuture.isDone()) { writeQuery(query, writePromise); } else { parent.channelFuture.addListener(new GenericFutureListener<Future<? super Channel>>() { @Override public void operationComplete(Future<? super Channel> future) throws Exception { if (future.isSuccess()) { writeQuery(query, writePromise); } else { Throwable cause = future.cause(); promise.tryFailure(cause); writePromise.setFailure(cause); } } }); } }
private void doHealthCheckOnRelease(final Channel channel, final Promise<Void> promise) throws Exception { final Future<Boolean> f = healthCheck.isHealthy(channel); if (f.isDone()) { releaseAndOfferIfHealthy(channel, promise, f); } else { f.addListener(new FutureListener<Boolean>() { @Override public void operationComplete(Future<Boolean> future) throws Exception { releaseAndOfferIfHealthy(channel, promise, f); } }); } }
private void finishPeerRead0(LocalChannel peer) { Future<?> peerFinishReadFuture = peer.finishReadFuture; if (peerFinishReadFuture != null) { if (!peerFinishReadFuture.isDone()) { runFinishPeerReadTask(peer); return; } else { // Lazy unset to make sure we don't prematurely unset it while scheduling a new task. FINISH_READ_FUTURE_UPDATER.compareAndSet(peer, peerFinishReadFuture, null); } } ChannelPipeline peerPipeline = peer.pipeline(); if (peer.readInProgress) { peer.readInProgress = false; for (;;) { Object received = peer.inboundBuffer.poll(); if (received == null) { break; } peerPipeline.fireChannelRead(received); } peerPipeline.fireChannelReadComplete(); } }
private void select(final ChannelHandlerContext ctx, final String hostname) throws Exception { Future<T> future = lookup(ctx, hostname); if (future.isDone()) { onLookupComplete(ctx, hostname, future); } else { suppressRead = true; future.addListener(new FutureListener<T>() { @Override public void operationComplete(Future<T> future) throws Exception { try { suppressRead = false; try { onLookupComplete(ctx, hostname, future); } catch (DecoderException err) { ctx.fireExceptionCaught(err); } catch (Exception cause) { ctx.fireExceptionCaught(new DecoderException(cause)); } catch (Throwable cause) { ctx.fireExceptionCaught(cause); } } finally { if (readPending) { readPending = false; ctx.read(); } } } }); } }
private void doHealthCheck(final Channel ch, final Promise<Channel> promise) { assert ch.eventLoop().inEventLoop(); Future<Boolean> f = healthCheck.isHealthy(ch); if (f.isDone()) { notifyHealthCheck(f, ch, promise); } else { f.addListener(new FutureListener<Boolean>() { @Override public void operationComplete(Future<Boolean> future) throws Exception { notifyHealthCheck(future, ch, promise); } }); } }
if (resolveFuture.isDone()) { final Throwable resolveFailureCause = resolveFuture.cause();