[CalendarServer-changes] [11688] CalendarServer/trunk/twext/web2
source_changes at macosforge.org
source_changes at macosforge.org
Thu Sep 12 18:17:55 PDT 2013
Revision: 11688
http://trac.calendarserver.org//changeset/11688
Author: glyph at apple.com
Date: 2013-09-12 18:17:55 -0700 (Thu, 12 Sep 2013)
Log Message:
-----------
Sort sockets satisfying restrictions.
Modified Paths:
--------------
CalendarServer/trunk/twext/web2/metafd.py
CalendarServer/trunk/twext/web2/test/test_metafd.py
Modified: CalendarServer/trunk/twext/web2/metafd.py
===================================================================
--- CalendarServer/trunk/twext/web2/metafd.py 2013-09-13 01:17:48 UTC (rev 11687)
+++ CalendarServer/trunk/twext/web2/metafd.py 2013-09-13 01:17:55 UTC (rev 11688)
@@ -225,7 +225,7 @@
def __lt__(self, other):
if not isinstance(other, WorkerStatus):
return NotImplemented
- return self._tuplify() < other._tuplify()
+ return self.effective() < other.effective()
def __eq__(self, other):
Modified: CalendarServer/trunk/twext/web2/test/test_metafd.py
===================================================================
--- CalendarServer/trunk/twext/web2/test/test_metafd.py 2013-09-13 01:17:48 UTC (rev 11687)
+++ CalendarServer/trunk/twext/web2/test/test_metafd.py 2013-09-13 01:17:55 UTC (rev 11688)
@@ -188,6 +188,25 @@
self.assertEquals(builder.port.reading, True)
+ def test_unevenLoadDistribution(self):
+ """
+ Subprocess sockets should be selected for subsequent socket sends by
+ ascending status. Status should sum sent and successfully subsumed
+ sockets.
+ """
+ builder = LimiterBuilder(self)
+ # Give one simulated worker a higher acknowledged load than the other.
+ builder.fillUp(True, 1)
+ # There should still be plenty of spare capacity.
+ self.assertEquals(builder.port.reading, True)
+ # Then slam it with a bunch of incoming requests.
+ builder.fillUp(False, builder.limiter.maxRequests - 1)
+ # Now capacity is full.
+ self.assertEquals(builder.port.reading, False)
+ # And everyone should have an even amount of work.
+ self.assertEquals(builder.highestLoad(), builder.requestsPerSocket)
+
+
def test_processStopsReadingEvenWhenConnectionsAreNotAcknowledged(self):
"""
L{ConnectionLimiter.statusesChanged} determines whether the current
@@ -266,15 +285,18 @@
return serverServiceMaker
- def fillUp(self, acknowledged=True):
+ def fillUp(self, acknowledged=True, count=0):
"""
Fill up all the slots on the connection limiter.
@param acknowledged: Should the virtual connections created by this
method send a message back to the dispatcher indicating that the
subprocess has acknowledged receipt of the file descriptor?
+
+ @param count: Amount of load to add; default to the maximum that the
+ limiter.
"""
- for x in range(self.limiter.maxRequests):
+ for x in range(count or self.limiter.maxRequests):
self.dispatcher.sendFileDescriptor(None, "SSL")
if acknowledged:
self.dispatcher.statusMessage(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130912/255a7a2e/attachment-0001.html>
More information about the calendarserver-changes
mailing list