void initialWindowSize(int newWindowSize) throws Http2Exception { if (newWindowSize < 0) { throw new IllegalArgumentException("Invalid initial window size: " + newWindowSize); } final int delta = newWindowSize - initialWindowSize; initialWindowSize = newWindowSize; connection.forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) throws Http2Exception { state(stream).incrementStreamWindow(delta); return true; } }); if (delta > 0 && isChannelWritable()) { // The window size increased, send any pending frames for all streams. writePendingBytes(); } }
private void checkAllWritabilityChanged() throws Http2Exception { // Make sure we mark that we have notified as a result of this change. connectionState.markedWritability(isWritableConnection()); connection.forEachActiveStream(this); } }
/** * Iterates over all active HTTP/2 streams. * * <p>This method must not be called outside of the event loop. */ final void forEachActiveStream(final Http2FrameStreamVisitor streamVisitor) throws Http2Exception { assert ctx.executor().inEventLoop(); connection().forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) { try { return streamVisitor.visit((Http2FrameStream) stream.getProperty(streamKey)); } catch (Throwable cause) { onError(ctx, false, cause); return false; } } }); }
@Override public void initialWindowSize(int newWindowSize) throws Http2Exception { assert ctx == null || ctx.executor().inEventLoop(); int delta = newWindowSize - initialWindowSize; initialWindowSize = newWindowSize; WindowUpdateVisitor visitor = new WindowUpdateVisitor(delta); connection.forEachActiveStream(visitor); visitor.throwIfError(); }
/** * Iterates over all active HTTP/2 streams. * * <p>This method must not be called outside of the event loop. */ final void forEachActiveStream(final Http2FrameStreamVisitor streamVisitor) throws Http2Exception { assert ctx.executor().inEventLoop(); connection().forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) { try { return streamVisitor.visit((Http2FrameStream) stream.getProperty(streamKey)); } catch (Throwable cause) { onError(ctx, false, cause); return false; } } }); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (!closing) { closing = true; if (needsImmediateDisconnection()) { connection().forEachActiveStream(closeAllStreams); } onCloseRequest(ctx); } super.close(ctx, promise); }
/** * Iterates over all active HTTP/2 streams. * * <p>This method must not be called outside of the event loop. */ final void forEachActiveStream(final Http2FrameStreamVisitor streamVisitor) throws Http2Exception { assert ctx.executor().inEventLoop(); connection().forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) { try { return streamVisitor.visit((Http2FrameStream) stream.getProperty(streamKey)); } catch (Throwable cause) { onError(ctx, false, cause); return false; } } }); }
void initialWindowSize(int newWindowSize) throws Http2Exception { if (newWindowSize < 0) { throw new IllegalArgumentException("Invalid initial window size: " + newWindowSize); } final int delta = newWindowSize - initialWindowSize; initialWindowSize = newWindowSize; connection.forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) throws Http2Exception { state(stream).incrementStreamWindow(delta); return true; } }); if (delta > 0 && isChannelWritable()) { // The window size increased, send any pending frames for all streams. writePendingBytes(); } }
@Override public void onError(ChannelHandlerContext ctx, boolean outbound, Throwable cause) { try { http2Connection.forEachActiveStream(stream -> { streamCallbackApply(stream, l -> l.onStreamError( ConnectionImpl.this, stream, new IOException(cause))); return true; }); } catch (Http2Exception e) { log.error("error occurs when notify listener. exception: ", e); } }
void initialWindowSize(int newWindowSize) throws Http2Exception { if (newWindowSize < 0) { throw new IllegalArgumentException("Invalid initial window size: " + newWindowSize); } final int delta = newWindowSize - initialWindowSize; initialWindowSize = newWindowSize; connection.forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) throws Http2Exception { state(stream).incrementStreamWindow(delta); return true; } }); if (delta > 0 && isChannelWritable()) { // The window size increased, send any pending frames for all streams. writePendingBytes(); } }
private void checkAllWritabilityChanged() throws Http2Exception { // Make sure we mark that we have notified as a result of this change. connectionState.markedWritability(isWritableConnection()); connection.forEachActiveStream(this); } }
private void checkAllWritabilityChanged() throws Http2Exception { // Make sure we mark that we have notified as a result of this change. connectionState.markedWritability(isWritableConnection()); connection.forEachActiveStream(this); } }
/** * Iterates over all active HTTP/2 streams. * * <p>This method must not be called outside of the event loop. */ final void forEachActiveStream(final Http2FrameStreamVisitor streamVisitor) throws Http2Exception { assert ctx.executor().inEventLoop(); connection().forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) { try { return streamVisitor.visit((Http2FrameStream) stream.getProperty(streamKey)); } catch (Throwable cause) { onError(ctx, false, cause); return false; } } }); }
/** * Iterates over all active HTTP/2 streams. * * <p>This method must not be called outside of the event loop. */ final void forEachActiveStream(final Http2FrameStreamVisitor streamVisitor) throws Http2Exception { assert ctx.executor().inEventLoop(); connection().forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) { try { return streamVisitor.visit((Http2FrameStream) stream.getProperty(streamKey)); } catch (Throwable cause) { onError(ctx, false, cause); return false; } } }); }
/** * Iterates over all active HTTP/2 streams. * * <p>This method must not be called outside of the event loop. */ final void forEachActiveStream(final Http2FrameStreamVisitor streamVisitor) throws Http2Exception { assert ctx.executor().inEventLoop(); connection().forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) { try { return streamVisitor.visit((Http2FrameStream) stream.getProperty(streamKey)); } catch (Throwable cause) { onError(ctx, false, cause); return false; } } }); }
@Override public void initialWindowSize(int newWindowSize) throws Http2Exception { assert ctx == null || ctx.executor().inEventLoop(); int delta = newWindowSize - initialWindowSize; initialWindowSize = newWindowSize; WindowUpdateVisitor visitor = new WindowUpdateVisitor(delta); connection.forEachActiveStream(visitor); visitor.throwIfError(); }
@Override public void initialWindowSize(int newWindowSize) throws Http2Exception { assert ctx == null || ctx.executor().inEventLoop(); int delta = newWindowSize - initialWindowSize; initialWindowSize = newWindowSize; WindowUpdateVisitor visitor = new WindowUpdateVisitor(delta); connection.forEachActiveStream(visitor); visitor.throwIfError(); }
@Override protected void onConnectionError(ChannelHandlerContext ctx, Throwable cause, Http2Exception connectionError) { // Logs the full exception here final String message = String.format( "HTTP/2 connection encountered an exception, streamCount=%d, remote=%s, channel=%s", connection().numActiveStreams(), ctx.channel().remoteAddress(), ctx.channel().id()); LOG.error(message, cause); try { connection().forEachActiveStream(stream -> { resetStream(ctx, stream.id(), Http2Error.CANCEL.code(), ctx.newPromise()); doOnStreamError(ctx, stream.id(), cause); return true; }); ctx.flush(); } catch (Http2Exception e) { LOG.error("Encountered exception while invoking request callbacks with errors", e); } finally { super.onConnectionError(ctx, cause, connectionError); } }