protected Http2SessionOutputSink newOutputSink() { return new Http2SessionOutputSink(this); }
private void close() { connection.closeSilently(); outputSink.close(); }
protected void onPeerWindowUpdate(final int delta) throws Http2SessionException { final int currentWindow = availConnectionWindowSize.get(); if (delta > 0 && currentWindow > 0 && currentWindow + delta < 0) { throw new Http2SessionException(ErrorCode.FLOW_CONTROL_ERROR, "Session flow-control window overflow."); } final int newWindowSize = availConnectionWindowSize.addAndGet(delta); if (LOGGER.isLoggable(LOGGER_LEVEL)) { LOGGER.log(LOGGER_LEVEL, "Http2Session. Expand connection window size by {0} bytes. Current connection window size is: {1}", new Object[] {delta, newWindowSize}); } flushOutputQueue(); }
writeDownStream(headerFrames, completionHandler, messageCloner); return; writeDownStream(msg, completionHandler, messageCloner); writeDownStream(headerFrames); outputQueue.reserveSpace(record.isZeroSizeData() ? 1 : dataSize); flushOutputQueue();
@SuppressWarnings("unchecked") protected <K> void writeDownStream(final K anyMessage, final CompletionHandler<WriteResult> completionHandler, final MessageCloner<Buffer> messageCloner) { // Encode Http2Frame -> Buffer final Object msg; if (anyMessage instanceof List) { msg = frameCodec().serializeAndRecycle( http2Session, (List<Http2Frame>) anyMessage); } else if (anyMessage instanceof Http2Frame) { msg = frameCodec().serializeAndRecycle( http2Session, (Http2Frame) anyMessage); } else { msg = anyMessage; } http2Session.getHttp2SessionChain().write(http2Session.getConnection(), null, msg, completionHandler, messageCloner); }
/** * TODO */ FutureImpl<Http2Session> terminateGracefully() { if (!isServer) { throw new IllegalStateException("Illegal use of graceful termination on client."); } final GoAwayFrame frame = setGoAwayLocally(ErrorCode.NO_ERROR, "Shutting Down", true); if (frame != null) { sessionClosed = Futures.createSafeFuture(); outputSink.writeDownStream(frame); } return sessionClosed; }
private void flushToConnectionOutputSink( final List<Http2Frame> headerFrames, final Buffer data, final CompletionHandler<WriteResult> completionHandler, final MessageCloner<Buffer> messageCloner, final boolean isLast) { http2Session.getOutputSink().writeDataDownStream(stream, headerFrames, data, completionHandler, messageCloner, isLast); if (isLast) { terminate(OUT_FIN_TERMINATION); } }
@SuppressWarnings("unused") public int getAvailablePeerConnectionWindowSize() { return outputSink.getAvailablePeerConnectionWindowSize(); }
private void processWindowUpdateFrame(final Http2Session http2Session, final Http2Frame frame) throws Http2StreamException, Http2SessionException { WindowUpdateFrame updateFrame = (WindowUpdateFrame) frame; final int streamId = updateFrame.getStreamId(); final int delta = updateFrame.getWindowSizeIncrement(); updateFrame.recycle(); if (streamId == 0) { if (delta == 0) { throw new Http2SessionException(ErrorCode.PROTOCOL_ERROR, "Illegal WINDOW_UPDATE with a delta of 0."); } http2Session.getOutputSink().onPeerWindowUpdate(delta); } else { if (delta == 0) { throw new Http2StreamException(streamId, ErrorCode.PROTOCOL_ERROR, "Illegal WINDOW_UPDATE with a delta of 0."); } final Http2Stream stream = http2Session.getStream(streamId); //noinspection Duplicates if (stream != null) { stream.getOutputSink().onPeerWindowUpdate(delta); } else { throw new Http2SessionException(ErrorCode.PROTOCOL_ERROR); } } }
writeDownStream(headerFrames, completionHandler, messageCloner); return; writeDownStream(msg, completionHandler, messageCloner); writeDownStream(headerFrames); outputQueue.reserveSpace(record.isZeroSizeData() ? 1 : dataSize); flushOutputQueue();
protected void writeDownStream(final Http2Frame frame) { http2Session.getHttp2SessionChain().write( http2Session.getConnection(), null, frameCodec().serializeAndRecycle(http2Session, frame), null, (MessageCloner) null); }
/** * TODO */ FutureImpl<Http2Session> terminateGracefully() { if (!isServer) { throw new IllegalStateException("Illegal use of graceful termination on client."); } final GoAwayFrame frame = setGoAwayLocally(ErrorCode.NO_ERROR, "Shutting Down", true); if (frame != null) { sessionClosed = Futures.createSafeFuture(); outputSink.writeDownStream(frame); } return sessionClosed; }
private void flushToConnectionOutputSink( final List<Http2Frame> headerFrames, final Buffer data, final CompletionHandler<WriteResult> completionHandler, final MessageCloner<Buffer> messageCloner, final boolean isLast) { http2Session.getOutputSink().writeDataDownStream(stream, headerFrames, data, completionHandler, messageCloner, isLast); if (isLast) { terminate(OUT_FIN_TERMINATION); } }
@SuppressWarnings("unused") public int getAvailablePeerConnectionWindowSize() { return outputSink.getAvailablePeerConnectionWindowSize(); }
private void processWindowUpdateFrame(final Http2Session http2Session, final Http2Frame frame) throws Http2StreamException, Http2SessionException { WindowUpdateFrame updateFrame = (WindowUpdateFrame) frame; final int streamId = updateFrame.getStreamId(); final int delta = updateFrame.getWindowSizeIncrement(); updateFrame.recycle(); if (streamId == 0) { if (delta == 0) { throw new Http2SessionException(ErrorCode.PROTOCOL_ERROR, "Illegal WINDOW_UPDATE with a delta of 0."); } http2Session.getOutputSink().onPeerWindowUpdate(delta); } else { if (delta == 0) { throw new Http2StreamException(streamId, ErrorCode.PROTOCOL_ERROR, "Illegal WINDOW_UPDATE with a delta of 0."); } final Http2Stream stream = http2Session.getStream(streamId); //noinspection Duplicates if (stream != null) { stream.getOutputSink().onPeerWindowUpdate(delta); } else { throw new Http2SessionException(ErrorCode.PROTOCOL_ERROR); } } }
writeDownStream(headerFrames, completionHandler, messageCloner); return; writeDownStream(msg, completionHandler, messageCloner); writeDownStream(headerFrames); outputQueue.reserveSpace(record.isZeroSizeData() ? 1 : dataSize); flushOutputQueue();
protected void writeDownStream(final List<Http2Frame> frames) { http2Session.getHttp2SessionChain().write( http2Session.getConnection(), null, frameCodec().serializeAndRecycle(http2Session, frames), null, (MessageCloner) null); }
/** * TODO */ FutureImpl<Http2Session> terminateGracefully() { if (!isServer) { throw new IllegalStateException("Illegal use of graceful termination on client."); } final GoAwayFrame frame = setGoAwayLocally(ErrorCode.NO_ERROR, "Shutting Down", true); if (frame != null) { sessionClosed = Futures.createSafeFuture(); outputSink.writeDownStream(frame); } return sessionClosed; }
private void flushToConnectionOutputSink( final List<Http2Frame> headerFrames, final Buffer data, final CompletionHandler<WriteResult> completionHandler, final MessageCloner<Buffer> messageCloner, final boolean isLast) { http2Session.getOutputSink().writeDataDownStream(stream, headerFrames, data, completionHandler, messageCloner, isLast); if (isLast) { terminate(OUT_FIN_TERMINATION); } }
protected void onPeerWindowUpdate(final int delta) throws Http2SessionException { final int currentWindow = availConnectionWindowSize.get(); if (delta > 0 && currentWindow > 0 && currentWindow + delta < 0) { throw new Http2SessionException(ErrorCode.FLOW_CONTROL_ERROR, "Session flow-control window overflow."); } final int newWindowSize = availConnectionWindowSize.addAndGet(delta); if (LOGGER.isLoggable(LOGGER_LEVEL)) { LOGGER.log(LOGGER_LEVEL, "Http2Session. Expand connection window size by {0} bytes. Current connection window size is: {1}", new Object[] {delta, newWindowSize}); } flushOutputQueue(); }