• R/O
  • SSH
  • HTTPS

o2on: Commit


Commit MetaInfo

Revision177 (tree)
Zeit2009-11-07 16:04:58
Autornawota

Log Message

DatDB の再構築を起動後に行なうように。

Ändern Zusammenfassung

Diff

--- trunk/opy2on/lib/o2on_dat.py (revision 176)
+++ trunk/opy2on/lib/o2on_dat.py (revision 177)
@@ -162,15 +162,23 @@
162162 self.hashmap = {}
163163 self.boardmap = {}
164164 self.publishmap = {}
165+ self.need_rebuild = False
165166 self.load()
166167 if len(self.hashmap) == 0:
167- g.logger.log("DATDB", "Generating DatDB")
168- self.generate()
169- self.save()
170- g.logger.log("DATDB","Generated DatDB")
168+ self.need_rebuild = True
171169 def __len__(self):
172170 with self.lock:
173171 return len(self.hashmap)
172+ def checkrebuild(self):
173+ with self.lock:
174+ tmp = self.need_rebuild
175+ if tmp:
176+ self.glob.logger.log("DATDB", "Generating DatDB")
177+ self.generate()
178+ self.save()
179+ self.glob.logger.log("DATDB","Generated DatDB")
180+ with self.lock:
181+ self.need_rebuild = False
174182 def getRandomInBoard(self,board):
175183 if board in self.boardmap:
176184 h = random.choice(self.boardmap[board])
--- trunk/opy2on/lib/o2on_job.py (revision 176)
+++ trunk/opy2on/lib/o2on_job.py (revision 177)
@@ -404,6 +404,13 @@
404404 nodedb.save()
405405 self.glob.keyquery.save()
406406
407+class RebuildDatDBThread(JobThread):
408+ def __init__(self, g):
409+ JobThread.__init__(self,"rebuild dat DB",60,g)
410+ def dojob(self, nodes, logger, prof, datdb, datq):
411+ datdb.checkrebuild()
412+ self.finish = True
413+
407414 # Server thread
408415
409416 class ProxyServerThread(JobThread):
--- trunk/opy2on/opy2on.py (revision 176)
+++ trunk/opy2on/opy2on.py (revision 177)
@@ -151,6 +151,7 @@
151151 o2on_job.SearchThread(glob),
152152 o2on_job.DatQueryThread(glob),
153153 o2on_job.P2PServerThread(glob),
154+ o2on_job.RebuildDatDBThread(glob),
154155 )
155156
156157 for j in jobs: j.start()
Show on old repository browser