@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { // Fail promise if not failed to write PromiseAndTimestamp pending = pendingRequests.remove(requestId); if (pending != null && pending.promise.tryFailure(future.cause())) { stats.reportFailedRequest(); } } } });
@Override public void onRequestFailure(long requestId, Throwable cause) { PromiseAndTimestamp pending = pendingRequests.remove(requestId); if (pending != null && pending.promise.tryFailure(cause)) { stats.reportFailedRequest(); } }
/** * Close the connecting channel with an Exception (can be * <code>null</code>) or forward to the established channel. */ private void close(Throwable cause) { synchronized (connectLock) { if (!closed) { if (failureCause == null) { failureCause = cause; } if (established != null) { established.close(); } else { PendingRequest pending; while ((pending = queuedRequests.poll()) != null) { pending.promise.tryFailure(cause); } } closed = true; } } }
/** * Close the channel with a cause. * * @param cause The cause to close the channel with. * @return Channel close future */ private boolean close(Throwable cause) { if (failureCause.compareAndSet(null, cause)) { channel.close(); stats.reportInactiveConnection(); for (long requestId : pendingRequests.keySet()) { PromiseAndTimestamp pending = pendingRequests.remove(requestId); if (pending != null && pending.promise.tryFailure(cause)) { stats.reportFailedRequest(); } } return true; } return false; }
if (p != null && p.promise.tryFailure(failure)) { stats.reportFailedRequest(); requestPromiseTs.promise.tryFailure(t);