use of org.eclipse.jetty.http2.frames.WindowUpdateFrame in project jetty.project by eclipse.
the class SimpleFlowControlStrategy method onDataConsumed.
@Override
public void onDataConsumed(ISession session, IStream stream, int length) {
if (length <= 0)
return;
// This is the simple algorithm for flow control.
// This method is called when a whole flow controlled frame has been consumed.
// We send a WindowUpdate every time, even if the frame was very small.
WindowUpdateFrame sessionFrame = new WindowUpdateFrame(0, length);
session.updateRecvWindow(length);
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, increased session recv window by {} for {}", length, session);
Frame[] streamFrame = Frame.EMPTY_ARRAY;
if (stream != null) {
if (stream.isClosed()) {
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, ignoring update stream recv window by {} for closed {}", length, stream);
} else {
streamFrame = new Frame[1];
streamFrame[0] = new WindowUpdateFrame(stream.getId(), length);
stream.updateRecvWindow(length);
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, increased stream recv window by {} for {}", length, stream);
}
}
session.frames(stream, Callback.NOOP, sessionFrame, streamFrame);
}
use of org.eclipse.jetty.http2.frames.WindowUpdateFrame in project jetty.project by eclipse.
the class AbstractFlowControlStrategy method updateInitialStreamWindow.
@Override
public void updateInitialStreamWindow(ISession session, int initialStreamWindow, boolean local) {
int previousInitialStreamWindow;
if (local) {
previousInitialStreamWindow = getInitialStreamRecvWindow();
this.initialStreamRecvWindow = initialStreamWindow;
} else {
previousInitialStreamWindow = getInitialStreamSendWindow();
this.initialStreamSendWindow = initialStreamWindow;
}
int delta = initialStreamWindow - previousInitialStreamWindow;
// SPEC: updates of the initial window size only affect stream windows, not session's.
for (Stream stream : session.getStreams()) {
if (local) {
((IStream) stream).updateRecvWindow(delta);
if (LOG.isDebugEnabled())
LOG.debug("Updated initial stream recv window {} -> {} for {}", previousInitialStreamWindow, initialStreamWindow, stream);
} else {
session.onWindowUpdate((IStream) stream, new WindowUpdateFrame(stream.getId(), delta));
}
}
}
use of org.eclipse.jetty.http2.frames.WindowUpdateFrame in project jetty.project by eclipse.
the class BufferingFlowControlStrategy method onDataConsumed.
@Override
public void onDataConsumed(ISession session, IStream stream, int length) {
if (length <= 0)
return;
float ratio = bufferRatio;
WindowUpdateFrame windowFrame = null;
int level = sessionLevel.addAndGet(length);
int maxLevel = (int) (maxSessionRecvWindow.get() * ratio);
if (level > maxLevel) {
if (sessionLevel.compareAndSet(level, 0)) {
session.updateRecvWindow(level);
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, {} bytes, updated session recv window by {}/{} for {}", length, level, maxLevel, session);
windowFrame = new WindowUpdateFrame(0, level);
} else {
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, {} bytes, concurrent session recv window level {}/{} for {}", length, sessionLevel, maxLevel, session);
}
} else {
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, {} bytes, session recv window level {}/{} for {}", length, level, maxLevel, session);
}
Frame[] windowFrames = Frame.EMPTY_ARRAY;
if (stream != null) {
if (stream.isClosed()) {
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, {} bytes, ignoring update stream recv window for closed {}", length, stream);
} else {
AtomicInteger streamLevel = streamLevels.get(stream);
if (streamLevel != null) {
level = streamLevel.addAndGet(length);
maxLevel = (int) (getInitialStreamRecvWindow() * ratio);
if (level > maxLevel) {
level = streamLevel.getAndSet(0);
stream.updateRecvWindow(level);
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, {} bytes, updated stream recv window by {}/{} for {}", length, level, maxLevel, stream);
WindowUpdateFrame frame = new WindowUpdateFrame(stream.getId(), level);
if (windowFrame == null)
windowFrame = frame;
else
windowFrames = new Frame[] { frame };
} else {
if (LOG.isDebugEnabled())
LOG.debug("Data consumed, {} bytes, stream recv window level {}/{} for {}", length, level, maxLevel, stream);
}
}
}
}
if (windowFrame != null)
session.frames(stream, Callback.NOOP, windowFrame, windowFrames);
}
use of org.eclipse.jetty.http2.frames.WindowUpdateFrame in project jetty.project by eclipse.
the class WindowUpdateBodyParser method onWindowUpdate.
private boolean onWindowUpdate(int windowDelta) {
WindowUpdateFrame frame = new WindowUpdateFrame(getStreamId(), windowDelta);
reset();
notifyWindowUpdate(frame);
return true;
}
use of org.eclipse.jetty.http2.frames.WindowUpdateFrame in project jetty.project by eclipse.
the class HTTP2ServerSession method onPreface.
@Override
public void onPreface() {
// SPEC: send a SETTINGS frame upon receiving the preface.
Map<Integer, Integer> settings = notifyPreface(this);
if (settings == null)
settings = Collections.emptyMap();
SettingsFrame settingsFrame = new SettingsFrame(settings, false);
WindowUpdateFrame windowFrame = null;
int sessionWindow = getInitialSessionRecvWindow() - FlowControlStrategy.DEFAULT_WINDOW_SIZE;
if (sessionWindow > 0) {
updateRecvWindow(sessionWindow);
windowFrame = new WindowUpdateFrame(0, sessionWindow);
}
if (windowFrame == null)
frames(null, Callback.NOOP, settingsFrame, Frame.EMPTY_ARRAY);
else
frames(null, Callback.NOOP, settingsFrame, windowFrame);
}
Aggregations