484878 - Make BufferingFlowControlStrategy.bufferRatio configurable via JMX.

Made the property writable.
This commit is contained in:
Simone Bordet 2015-12-24 12:10:20 +01:00
parent 24b99d4b33
commit 997b868ecd
1 changed files with 10 additions and 3 deletions

View File

@ -57,7 +57,7 @@ public class BufferingFlowControlStrategy extends AbstractFlowControlStrategy
private final AtomicInteger maxSessionRecvWindow = new AtomicInteger(DEFAULT_WINDOW_SIZE);
private final AtomicInteger sessionLevel = new AtomicInteger();
private final Map<IStream, AtomicInteger> streamLevels = new ConcurrentHashMap<>();
private final float bufferRatio;
private float bufferRatio;
public BufferingFlowControlStrategy(float bufferRatio)
{
@ -76,6 +76,11 @@ public class BufferingFlowControlStrategy extends AbstractFlowControlStrategy
return bufferRatio;
}
public void setBufferRatio(float bufferRatio)
{
this.bufferRatio = bufferRatio;
}
@Override
public void onStreamCreated(IStream stream)
{
@ -96,9 +101,11 @@ public class BufferingFlowControlStrategy extends AbstractFlowControlStrategy
if (length <= 0)
return;
float ratio = bufferRatio;
WindowUpdateFrame windowFrame = null;
int level = sessionLevel.addAndGet(length);
int maxLevel = (int)(maxSessionRecvWindow.get() * bufferRatio);
int maxLevel = (int)(maxSessionRecvWindow.get() * ratio);
if (level > maxLevel)
{
level = sessionLevel.getAndSet(0);
@ -127,7 +134,7 @@ public class BufferingFlowControlStrategy extends AbstractFlowControlStrategy
if (streamLevel != null)
{
level = streamLevel.addAndGet(length);
maxLevel = (int)(getInitialStreamRecvWindow() * bufferRatio);
maxLevel = (int)(getInitialStreamRecvWindow() * ratio);
if (level > maxLevel)
{
level = streamLevel.getAndSet(0);