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

[minion-cvs] Tie pinging back into main server code; appease pycheck...



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

Modified Files:
	Pinger.py ServerMain.py ServerQueue.py 
Log Message:
Tie pinging back into main server code; appease pychecker.

Index: Pinger.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/Pinger.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Pinger.py	12 Dec 2004 02:48:16 -0000	1.13
+++ Pinger.py	12 Dec 2004 22:28:40 -0000	1.14
@@ -1041,6 +1041,6 @@
     log = PingLog(db)
 
     if db.LOCKING_IS_COARSE and databaseThread is not None:
-        log = BackgroundingDecorator(databaseThread, log)
+        log = mixminion.ThreadUtils.BackgroundingDecorator(databaseThread, log)
 
     return log

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -d -r1.138 -r1.139
--- ServerMain.py	12 Dec 2004 02:48:16 -0000	1.138
+++ ServerMain.py	12 Dec 2004 22:28:40 -0000	1.139
@@ -717,6 +717,7 @@
     # cleaningThread: Thread used to remove packets in the background
     # processingThread: Thread to handle CPU-intensive activity without
     #    slowing down network interactivity.
+    # databaseThread: DOCDOC
     # lockFile: An instance of Lockfile to prevent multiple servers from
     #    running in the same directory.  The filename for this lock is
     #    stored in self.pidFile.
@@ -836,19 +837,21 @@
         pingerEnabled = config['Pinging'].get("Enabled")
         if pingerEnabled and mixminion.server.Pinger.canRunPinger():
             #FFFF Later, enable this stuff anyway, to make R-G-B mixing work.
+            LOG.debug("Initializing database thread for pinger")
+            self.databaseThread = ProcessingThread("database thread")
+
             LOG.debug("Initializing ping log")
-            pingerDir = os.path.join(config.getWorkDir(), "pinger")
-            pingerLogDir = os.path.join(pingerDir, "log")
-            self.pingLog = mixminion.server.Pinger.openPingLog(config)
+            self.pingLog = mixminion.server.Pinger.openPingLog(
+                config, databaseThread=self.databaseThread)
 
             LOG.debug("Initializing ping generator")
-
             self.pingGenerator=mixminion.server.Pinger.getPingGenerator(config)
         else:
             if pingerEnabled:
                 LOG.warn("Running a pinger requires Python 2.2 or later, and the pysqlite module")
             self.pingLog = None
             self.pingGenerator = None
+            self.databaseThread = None
 
         self.cleaningThread = CleaningThread()
         self.processingThread = ProcessingThread()
@@ -874,6 +877,8 @@
                                        keyring=self.keyring)
             self.pingGenerator.scheduleAllPings(time.time())
 
+        if self.databaseThread is not None:
+            self.databaseThread.start()
         if self.pingLog is not None:
             self.incomingQueue.setPingLog(self.pingLog)
             self.mmtpServer.connectPingLog(self.pingLog)
@@ -996,11 +1001,14 @@
                 now+self.pingLog.HEARTBEAT_INTERVAL,
                 self.pingLog.heartbeat,
                 self.pingLog.HEARTBEAT_INTERVAL))
-            self.scheduleEvent(RecurringBackgroundEvent(
+            # FFFF if we aren't using a LOCKING_IS_COURSE database, we will
+            # FFFF still want this to happen in another thread.
+            #XXXX008 use symbolic constants here
+            self.scheduleEvent(RecurringEvent(
                 now+3*60,
-                self.processingThread.addJob,
-                self.pingLog.calculateStatistics,
-                27*60*60))
+                lambda self=self: self.pingLog.calculateAll(
+                 os.path.join(self.config.getWorkingDir(), "pinger", "status")),
+                1*60*60))
 
         # Makes next update get scheduled.
         nextUpdate = self.updateDirectoryClient()
@@ -1113,7 +1121,7 @@
         self.outgoingQueue.cleanQueue(df)
         self.moduleManager.cleanQueues(df)
         if self.pingLog:
-            self.pingLog.clean()
+            self.pingLog.rotate()
 
     def close(self):
         """Release all resources; close all files."""
@@ -1122,14 +1130,21 @@
         self.cleaningThread.shutdown()
         self.processingThread.shutdown()
         self.moduleManager.shutdown()
+        if self.databaseThread: self.databaseThread.shutdown()
 
         self.cleaningThread.join()
         self.processingThread.join()
         self.moduleManager.join()
+        if self.databaseThread: self.databaseThread.join()
 
         self.packetHandler.close()
         self.moduleManager.close()
         self.outgoingQueue.close()
+        if self.pingLog:
+            if hasattr(self.pingLog, '_baseObject'):
+                self.pingLog._baseObject.close()
+            else:
+                self.pingLog.close()
 
         EventStats.log.save()
 

Index: ServerQueue.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerQueue.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- ServerQueue.py	27 Jul 2004 03:20:31 -0000	1.43
+++ ServerQueue.py	12 Dec 2004 22:28:40 -0000	1.44
@@ -630,10 +630,6 @@
         finally:
             self._lock.release()
 
-    def _repOK(self):
-        #XXXX008
-        pass
-
     def removeExpiredMessages(self, now=None):
         """DOCDOC"""
         assert self.retrySchedule is not None
@@ -705,9 +701,6 @@
         self.sync()
         self.store.cleanQueue(secureDeleteFn)
 
-    def sync(self):
-        self.addressStateDB.sync()
-
     def close(self):
         self.addressStateDB.close()