[CalendarServer-changes] [11642] CalendarServer/branches/users/glyph/enforce-max-requests/twext/web2 /metafd.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 26 10:39:11 PDT 2013


Revision: 11642
          http://trac.calendarserver.org//changeset/11642
Author:   glyph at apple.com
Date:     2013-08-26 10:39:11 -0700 (Mon, 26 Aug 2013)
Log Message:
-----------
Fix for the test.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/enforce-max-requests/twext/web2/metafd.py

Modified: CalendarServer/branches/users/glyph/enforce-max-requests/twext/web2/metafd.py
===================================================================
--- CalendarServer/branches/users/glyph/enforce-max-requests/twext/web2/metafd.py	2013-08-26 17:39:06 UTC (rev 11641)
+++ CalendarServer/branches/users/glyph/enforce-max-requests/twext/web2/metafd.py	2013-08-26 17:39:11 UTC (rev 11642)
@@ -166,7 +166,8 @@
     The status of a worker process.
     """
 
-    def __init__(self, acknowledged=0, unacknowledged=0, started=0):
+    def __init__(self, acknowledged=0, unacknowledged=0, started=0,
+                 abandoned=0):
         """
         Create a L{ConnectionStatus} with a number of sent connections and a
         number of un-acknowledged connections.
@@ -179,23 +180,36 @@
             the subprocess which have never received a status response (a
             "C{+}" status message).
 
+        @param abandoned: The number of connections which have been sent to
+            this worker, but were not acknowledged at the moment that the
+            worker restarted.
+
         @param started: The number of times this worker has been started.
         """
         self.acknowledged = acknowledged
         self.unacknowledged = unacknowledged
         self.started = started
+        self.abandoned = abandoned
 
 
+    def effective(self):
+        """
+        The current effective load.
+        """
+        return self.acknowledged + self.unacknowledged
+
+
     def restarted(self):
         """
         The L{WorkerStatus} derived from the current status of a process and
         the fact that it just restarted.
         """
-        return self.__class__(0, self.unacknowledged, self.started + 1)
+        return self.__class__(0, 0, self.started + 1, self.unacknowledged)
 
 
     def _tuplify(self):
-        return (self.acknowledged, self.unacknowledged, self.started)
+        return (self.acknowledged, self.unacknowledged, self.started,
+                self.abandoned)
 
 
     def __lt__(self, other):
@@ -215,7 +229,8 @@
             return NotImplemented
         return self.__class__(self.acknowledged + other.acknowledged,
                               self.unacknowledged + other.unacknowledged,
-                              self.started + other.started)
+                              self.started + other.started,
+                              self.abandoned + other.abandoned)
 
 
     def __sub__(self, other):
@@ -223,7 +238,8 @@
             return NotImplemented
         return self + self.__class__(-other.acknowledged,
                                      -other.unacknowledged,
-                                     -other.started)
+                                     -other.started,
+                                     -other.abandoned)
 
 
 
@@ -320,7 +336,7 @@
         C{self.dispatcher.statuses} attribute, which is what
         C{self.outstandingRequests} uses to compute it.)
         """
-        current = sum(status.acknowledged
+        current = sum(status.effective()
                       for status in self.dispatcher.statuses)
         self._outstandingRequests = current # preserve for or= field in log
         maximum = self.maxRequests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130826/eac45d59/attachment.html>


More information about the calendarserver-changes mailing list