Author: markt
Date: Fri Jun 12 13:45:44 2015
New Revision: 1685091
URL: http://svn.apache.org/r1685091
Log:
Add some debug logging to the allocate process when there is a backlog.
Fix some bugs identified by unit test I haven't committed yet (because it is
still failing)
Modified:
tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties
Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java?rev=1685091&r1=1685090&r2=1685091&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
(original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Fri Jun
12 13:45:44 2015
@@ -563,7 +563,6 @@ public class Http2UpgradeHandler extends
while (leftToAllocate > 0) {
leftToAllocate = allocate(this, leftToAllocate);
}
- allocate(this, increment);
for (Entry<AbstractStream,int[]> entry :
backLogStreams.entrySet()) {
int allocation = entry.getValue()[1];
if (allocation > 0) {
@@ -578,6 +577,10 @@ public class Http2UpgradeHandler extends
private int allocate(AbstractStream stream, int allocation) {
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("upgradeHandler.allocate.debug",
getConnectionId(),
+ stream.getIdentifier(), Integer.toString(allocation)));
+ }
// Allocate to the specified stream
int[] value = backLogStreams.get(stream);
if (value[0] >= allocation) {
@@ -593,6 +596,11 @@ public class Http2UpgradeHandler extends
value[0] = 0;
leftToAllocate -= value[1];
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("upgradeHandler.allocate.left",
+ getConnectionId(), stream.getIdentifier(),
Integer.toString(leftToAllocate)));
+ }
+
// Recipients are children of the current stream that are in the
// backlog.
Set<AbstractStream> recipients = new HashSet<>();
@@ -608,6 +616,11 @@ public class Http2UpgradeHandler extends
int totalWeight = 0;
for (AbstractStream recipient : recipients) {
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("upgradeHandler.allocate.recipient",
+ getConnectionId(), stream.getIdentifier(),
recipient.getIdentifier(),
+ Integer.toString(recipient.getWeight())));
+ }
totalWeight += recipient.getWeight();
}
@@ -616,10 +629,13 @@ public class Http2UpgradeHandler extends
Iterator<AbstractStream> iter = recipients.iterator();
while (iter.hasNext()) {
AbstractStream recipient = iter.next();
- // +1 is to avoid rounding issues triggering an infinite loop.
- // Will cause a very slight over allocation but HTTP/2 should
- // cope with that.
- int share = 1 + leftToAllocate * recipient.getWeight() /
totalWeight;
+ int share = leftToAllocate * recipient.getWeight() /
totalWeight;
+ if (share == 0) {
+ // This is to avoid rounding issues triggering an infinite
+ // loop. It will cause a very slight over allocation but
+ // HTTP/2 should cope with that.
+ share = 1;
+ }
int remainder = allocate(recipient, share);
// Remove recipients that receive their full allocation so that
// they are excluded from the next allocation round.
Modified: tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties?rev=1685091&r1=1685090&r2=1685091&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties Fri Jun
12 13:45:44 2015
@@ -66,6 +66,9 @@ streamProcessor.httpupgrade.notsupported
streamStateMachine.debug.change=Connection [{0}], Stream [{1}], State changed
from [{2}] to [{3}]
streamStateMachine.invalidFrame=Connection [{0}], Stream [{1}], State [{2}],
Frame type [{3}]
+upgradeHandler.allocate.debug=Connection [{0}], Stream [{1}], allocated [{2}]
bytes
+upgradeHandler.allocate.left=Connection [{0}], Stream [{1}], [{2}] bytes
unallocated - trying to allocate to children
+upgradeHandler.allocate.recipient=Connection [{0}], Stream [{1}], potential
recipient [{2}] with weight [{3}]
upgradeHandler.rst.debug=Connection [{0}], Stream [{1}], Error [{2}], RST
(closing stream)
upgradeHandler.goaway.debug=Connection [{0}], Goaway, Last stream [{1}], Error
code [{2}], Debug data [{3}]
upgradeHandler.init=Connection [{0}]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]