[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Pinger runs for an hour without crashing



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv6915/lib/mixminion/server

Modified Files:
	Pinger.py 
Log Message:
Pinger runs for an hour without crashing

Index: Pinger.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/Pinger.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Pinger.py	28 Jul 2004 00:04:06 -0000	1.4
+++ Pinger.py	28 Jul 2004 06:07:33 -0000	1.5
@@ -124,11 +124,11 @@
                     LOG.debug("Removing expired events file %s", fn)
                     bad.append(os.path.join(self.location, fn))
                 elif tp == "pend":
-                    if self.lastPending:
+                    if lastPending:
                         LOG.debug("Removing old pending-pings file %s",
                                   lastPending)
                         bad.append(os.path.join(self.location,lastPending))
-                        self.lastPending = fn
+                        lastPending = fn
             if deleteFn:
                 deleteFn(bad)
             else:
@@ -189,7 +189,7 @@
         return fns
 
     def processPing(self, packet):#instanceof DeliveryPacket with type==ping
-        assert packet.getExitType() != mixminion.Packet.PING_TYPE
+        assert packet.getExitType() == mixminion.Packet.PING_TYPE
         addr = packet.getAddress()
         if len(addr) != mixminion.Crypto.DIGEST_LEN:
             LOG.warn("Ignoring malformed ping packet (exitInfo length %s)",
@@ -341,7 +341,7 @@
         stats = [ pr for _,pr in stats ]
         self.lock.acquire()
         try:
-            stats.append(self.pingStatus.checkPointResults())
+            stats.append(self.pingStatus.checkpointResults())
         finally:
             self.lock.release()
 
@@ -418,6 +418,7 @@
             self.start = lastResults.start
             self.liveness = lastResults.liveness
             self.serverUptime = lastResults.serverUptime
+            self.serverDowntime = lastResults.serverDowntime
             self.pings = lastResults.pings
             self.pendingPings = lastResults.pendingPings
         else:
@@ -475,7 +476,7 @@
         elif eType == 'GOT_PING':
             h = event[1]
             try:
-                tSent, path = self.pendingPing[h]
+                tSent, path = self.pendingPings[h]
             except KeyError:
                 # we didn't send it, or can't remember sending it.
                 LOG.warn("Received a ping I don't remember sending (%s)",
@@ -559,7 +560,7 @@
         self.days = days # list of OneDayPingResults
         self.summary = summary
 
-GRACE_PERIOD = ONE_DAY
+GRACE_PERIOD = 2*60*60
 WEIGHT_AGE = [ 5, 10, 10, 10, 10, 9, 8, 5, 3, 2, 2, 1, 0, 0, 0, 0, 0 ]
 
 def calculatePingResults(periods, endAt):
@@ -582,13 +583,14 @@
                 day = floorDiv(send-startAt, ONE_DAY)
                 if day<0: continue
                 pingsByDay[day].setdefault(path,[]).append((send,recv))
-    for send,path in periods[-1].values():
-        if send+GRACE_PERIOD > endAt:
-            continue
-        day = floorDiv(send-startAt, ONE_DAY)
-        if day<0: continue
-        pingsByDay[day].setdefault(path,[]).append((send,None))
-        allPaths[path]=1
+    if len(periods):
+        for send,path in periods[-1].pendingPings.values():
+            if send+GRACE_PERIOD > endAt:
+                continue
+            day = floorDiv(send-startAt, ONE_DAY)
+            if day<0: continue
+            pingsByDay[day].setdefault(path,[]).append((send,None))
+            allPaths[path]=1
 
     maxDelay = {}
     delays = {}
@@ -599,8 +601,8 @@
         delays[path] = []
         summary.nSent[path]=0
         summary.nRcvd[path]=0
-    for idx in xrange(KEEP_HISTORY_DAYS+1):
-        for path, pings in pingsByDay[idx].keys():
+    for idx in xrange(USE_HISTORY_DAYS+1):
+        for path, pings in pingsByDay[idx].items():
             nRcvd = 0
             nLost = 0
             totalDelay = 0.0
@@ -616,7 +618,10 @@
                         maxDelay[path]=delay
                     delays[path].append(delay)
             results[idx].reliability[path] = float(nRcvd)/(nRcvd+nLost)
-            results[idx].latency[path] = totalDelay/nRcvd
+            if nRcvd > 0:
+                results[idx].latency[path] = totalDelay/nRcvd
+            else:
+                results[idx].latency[path] = None
             summary.nSent[path] += len(pings)
             summary.nRcvd[path] += nRcvd
 
@@ -629,7 +634,7 @@
 
     for idx in xrange(USE_HISTORY_DAYS+1):
         weightAge = WEIGHT_AGE[idx]
-        for path, pings in pingsByDay[-idx].keys():
+        for path, pings in pingsByDay[-idx].items():
             if not delays[path]:
                 continue
             d = delays[path]
@@ -672,7 +677,7 @@
         if upTotal+downTotal < 60*60: continue
         summary.uptime[s] = float(upTotal)/(upTotal+downTotal)
 
-    return PingResults(results, s)
+    return PingResults(results, summary)
 
 class PingGenerator:
     """DOCDOC"""
@@ -872,6 +877,7 @@
         for n1, n2 in pingable:
             self._sendOnePing([n1,n2], [myDescriptor])
             self._schedulePing((n1,n2), now+60)
+            #XXXX008 we need to reschedule pings when a new directory arrives
 
 #class GeometricLinkPaddingGenerator