private void updateLastStreamId(IStream stream) { int streamId = stream.getId(); if (streamId % 2 != streamIds.get() % 2) Atomics.updateMax(lastStreamId, streamId); }
private void removeStream(IStream stream) { if (stream.isUnidirectional()) stream.getAssociatedStream().disassociate(stream); IStream removed = streams.remove(stream.getId()); if (removed != null) { assert removed == stream; if (streamIds.get() % 2 == stream.getId() % 2) localStreamCount.decrementAndGet(); if (LOG.isDebugEnabled()) LOG.debug("Removed {}", stream); notifyStreamClosed(stream); } }
frameBytes.failed(new StreamException(frameBytes.getStream().getId(), StreamStatus.INVALID_STREAM, "Stream: " + frameBytes.getStream() + " is reset!")); continue;
size = windowSize; buffer = generator.data(stream.getId(), size, dataInfo); return buffer;
@Override public void onDataConsumed(ISession session, IStream stream, DataInfo dataInfo, int delta) { // This is the algorithm for flow control. // This method may be called multiple times with delta=1, but we only send a window // update when the whole dataInfo has been consumed. // Other policies may be to send window updates when consumed() is greater than // a certain threshold, etc. but for now the policy is not pluggable for simplicity. // Note that the frequency of window updates depends on the read buffer, that // should not be too smaller than the window size to avoid frequent window updates. // Therefore, a pluggable policy should be able to modify the read buffer capacity. int length = dataInfo.length(); if (dataInfo.consumed() == length && !stream.isClosed() && length > 0) { WindowUpdateFrame windowUpdateFrame = new WindowUpdateFrame(session.getVersion(), stream.getId(), length); session.control(stream, windowUpdateFrame, 0, TimeUnit.MILLISECONDS, Callback.Adapter.INSTANCE); } } }
int streamId = stream.getId();