@Override public Throwable cause() { return delegate.cause(); } }
@Override public Throwable cause() { return delegate.cause(); } }
@Override public Throwable cause() { return delegate.cause(); } }
/** * Wait for this handler to be added after the upgrade to HTTP/2, and for initial preface * handshake to complete. * * @param timeout Time to wait * @param unit {@link TimeUnit} for {@code timeout} * @throws Exception if timeout or other failure occurs */ public void awaitSettings(long timeout, TimeUnit unit) throws Exception { if (!promise.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting for settings"); } if (!promise.isSuccess()) { throw new RuntimeException(promise.cause()); } }
/** * Wait for this handler to be added after the upgrade to HTTP/2, and for initial preface * handshake to complete. * * @param timeout Time to wait * @param unit {@link TimeUnit} for {@code timeout} * @throws Exception if timeout or other failure occurs */ public void awaitSettings(long timeout, TimeUnit unit) throws Exception { if (!promise.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting for settings"); } if (!promise.isSuccess()) { throw new RuntimeException(promise.cause()); } }
public void finishOverarchingWritePromiseIfAllPromisesFinished() { for (ChannelPromise aPromise : allPromises) { if (aPromise.isDone()) { if (!aPromise.isSuccess()) { overarchingPromise.tryFailure(aPromise.cause()); return; } } else { overarchingPromise.tryFailure(new IllegalStateException("A write promise did not complete.")); return; } } overarchingPromise.trySuccess(); }
@Override public Throwable cause() { return delegate.cause(); } }
@Override public Throwable cause() { return delegate.cause(); } }
@Override public Throwable cause() { return delegate.cause(); } }
public Throwable getCause() { return promise == null ? null : promise.cause(); }
@Override public void operationComplete(final ChannelPromise future) throws Exception { if (future.isSuccess()) { ApnsClientHandler.this.pushNotificationsByStreamId.put(streamId, pushNotification); if (ApnsClientHandler.this.useTokenAuthentication) { ApnsClientHandler.this.authenticationTokensByStreamId.put(streamId, authenticationToken); } } else { log.trace("Failed to write push notification on stream {}.", streamId, future.cause()); } } });
/** * Wait (sequentially) for a time duration for each anticipated response * * @param timeout Value of time to wait for each response * @param unit Units associated with {@code timeout} * @see io.netty.example.http2.client.HttpResponseHandler#put(int, ChannelPromise) */ public void awaitResponses(long timeout, TimeUnit unit) { Iterator<Entry<Integer, ChannelPromise>> itr = streamidPromiseMap.entrySet().iterator(); while (itr.hasNext()) { Entry<Integer, ChannelPromise> entry = itr.next(); ChannelPromise promise = entry.getValue(); if (!promise.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting for response on stream id " + entry.getKey()); } if (!promise.isSuccess()) { throw new RuntimeException(promise.cause()); } itr.remove(); } }
/** * Wait for this handler to be added after the upgrade to HTTP/2, and for initial preface * handshake to complete. * * @param timeout Time to wait * @param unit {@link TimeUnit} for {@code timeout} * @throws Exception if timeout or other failure occurs */ public void awaitSettings(long timeout, TimeUnit unit) throws Exception { if (!promise.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting for settings"); } if (!promise.isSuccess()) { throw new RuntimeException(promise.cause()); } }
/** * Wait for this handler to be added after the upgrade to HTTP/2, and for initial preface * handshake to complete. * * @param timeout Time to wait * @param unit {@link TimeUnit} for {@code timeout} * @throws Exception if timeout or other failure occurs */ public void awaitSettings(long timeout, TimeUnit unit) throws Exception { if (!promise.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting for settings"); } if (!promise.isSuccess()) { throw new RuntimeException(promise.cause()); } }
/** * Wait for this handler to be added after the upgrade to HTTP/2, and for initial preface * handshake to complete. * * @param timeout Time to wait * @param unit {@link java.util.concurrent.TimeUnit} for {@code timeout} * @throws Exception if timeout or other failure occurs */ public void awaitSettings(long timeout, TimeUnit unit) throws Exception { if (!promise.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting for settings"); } if (!promise.isSuccess()) { throw new RuntimeException(promise.cause()); } }
private void awaitResponses(long timeout, TimeUnit unit) { Iterator<Entry<Integer, Entry<ChannelFuture, ChannelPromise>>> itr = streamidPromiseMap.entrySet().iterator(); while (itr.hasNext()) { Entry<Integer, Entry<ChannelFuture, ChannelPromise>> entry = itr.next(); ChannelFuture writeFuture = entry.getValue().getKey(); if (!writeFuture.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting to write for stream id " + entry.getKey()); } if (!writeFuture.isSuccess()) { throw new RuntimeException(writeFuture.cause()); } ChannelPromise promise = entry.getValue().getValue(); if (!promise.awaitUninterruptibly(timeout, unit)) { throw new IllegalStateException("Timed out waiting for response on stream id " + entry.getKey()); } if (!promise.isSuccess()) { throw new RuntimeException(promise.cause()); } itr.remove(); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { super.write(ctx, msg, promise); NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler); try { // if error happens from write, mock a BAD_REQUEST response so that invoker can return immediately without // waiting until timeout. FIXME: not sure if this is the right approach, but exceptionCaught doesn't work // as expected. if (promise.cause() != null && msg instanceof Request) { Request request = (Request) msg; Response response = new Response(request.getId(), request.getVersion()); response.setStatus(Response.BAD_REQUEST); response.setErrorMessage(StringUtils.toString(promise.cause())); handler.received(channel, response); } else { handler.sent(channel, msg); } } finally { NettyChannel.removeChannelIfDisconnected(ctx.channel()); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { super.write(ctx, msg, promise); NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler); try { // if error happens from write, mock a BAD_REQUEST response so that invoker can return immediately without // waiting until timeout. FIXME: not sure if this is the right approach, but exceptionCaught doesn't work // as expected. if (promise.cause() != null && msg instanceof Request) { Request request = (Request) msg; Response response = new Response(request.getId(), request.getVersion()); response.setStatus(Response.BAD_REQUEST); response.setErrorMessage(StringUtils.toString(promise.cause())); handler.received(channel, response); } else { handler.sent(channel, msg); } } finally { NettyChannel.removeChannelIfDisconnected(ctx.channel()); } }