]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
remove logpublisher, use the Foolscap version now that this functionality has been...
authorBrian Warner <warner@lothar.com>
Thu, 13 Dec 2007 03:31:01 +0000 (20:31 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 13 Dec 2007 03:31:01 +0000 (20:31 -0700)
src/allmydata/logpublisher.py [deleted file]
src/allmydata/node.py
src/allmydata/test/test_node.py
src/allmydata/test/test_util.py

diff --git a/src/allmydata/logpublisher.py b/src/allmydata/logpublisher.py
deleted file mode 100644 (file)
index 0718dcf..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-
-import os.path
-from zope.interface import implements
-from twisted.application import service
-from twisted.python import log
-from foolscap import Referenceable, RemoteInterface
-from foolscap.schema import DictOf, Any
-from allmydata import get_package_versions
-
-class RILogObserver(RemoteInterface):
-    def msg(logmsg=DictOf(str, Any())):
-        return None
-class RISubscription(RemoteInterface):
-    pass
-
-class RILogPublisher(RemoteInterface):
-    def get_versions():
-        return DictOf(str, str)
-    def subscribe_to_all(observer=RILogObserver):
-        return RISubscription
-    def unsubscribe(subscription=Any()):
-        # I don't know how to get the constraint right: unsubscribe() should
-        # accept return value of subscribe_to_all()
-        return None
-
-class RILogGatherer(RemoteInterface):
-    def logport(nodeid=str, logport=RILogPublisher):
-        return None
-
-class Subscription(Referenceable):
-    implements(RISubscription)
-
-class LogPublisher(Referenceable, service.MultiService):
-    implements(RILogPublisher)
-    name = "log_publisher"
-
-    def __init__(self):
-        service.MultiService.__init__(self)
-        self._subscribers = {}
-        self._notifyOnDisconnectors = {}
-
-    def startService(self):
-        service.MultiService.startService(self)
-        furlfile = os.path.join(self.parent.basedir, "logport.furl")
-        self.parent.tub.registerReference(self, furlFile=furlfile)
-        os.chmod(furlfile, 0600)
-
-        log.addObserver(self._twisted_log_observer)
-
-    def stopService(self):
-        log.removeObserver(self._twisted_log_observer)
-        return service.MultiService.stopService(self)
-
-    def _twisted_log_observer(self, d):
-        # Twisted will remove this for us if it fails.
-
-        # keys:
-        #  ['message']: *args
-        #  ['time']: float
-        #  ['isError']: bool, usually False
-        #  ['system']: string
-
-        for o in self._subscribers.values():
-            o.callRemoteOnly("msg", d)
-
-        #f = open("/tmp/f.out", "a")
-        #print >>f, d['message']
-        #f.close()
-
-    def remote_get_versions(self):
-        # Convert all the version instances to strings.
-        return dict([(k,str(v))
-                     for k,v in get_package_versions().iteritems()])
-
-    def remote_subscribe_to_all(self, observer):
-        s = Subscription()
-        self._subscribers[s] = observer
-        c = observer.notifyOnDisconnect(self.remote_unsubscribe, s)
-        self._notifyOnDisconnectors[s] = c
-        return s
-
-    def remote_unsubscribe(self, s):
-        observer = self._subscribers.pop(s)
-        c = self._notifyOnDisconnectors.pop(s)
-        observer.dontNotifyOnDisconnect(c)
-
index 53281229eb0be5120b67d7422f08e04ddbb8c14c..e955849c452900f48109c22d7a65fb19b9054f81 100644 (file)
@@ -10,7 +10,18 @@ from allmydata import get_package_versions_string
 from allmydata.util import log as tahoe_log
 from allmydata.util import iputil, observer, humanreadable
 from allmydata.util.assertutil import precondition
-from allmydata.logpublisher import LogPublisher
+
+# Just to get their versions:
+import allmydata, pycryptopp, zfec
+
+from foolscap.logging.publish import LogPublisher
+# Add our application versions to the data that Foolscap's
+# LogPublisher reports. Our __version__ attributes are actually
+# instances of allmydata.util.version_class.Version, so convert them
+# into strings first.
+LogPublisher.versions['allmydata'] = str(allmydata.__version__)
+LogPublisher.versions['zfec'] = str(zfec.__version__)
+LogPublisher.versions['pycryptopp'] = str(pycryptopp.__version__)
 
 # group 1 will be addr (dotted quad string), group 3 if any will be portnum (string)
 ADDR_RE=re.compile("^([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*)(:([1-9][0-9]*))?$")
@@ -177,6 +188,11 @@ class Node(service.MultiService):
                     ob.formatTime = newmeth
         # TODO: twisted >2.5.0 offers maxRotatedFiles=50
 
+        self.tub.setOption("logport-furlfile",
+                           os.path.join(self.basedir, "logport.furl"))
+        self.tub.setOption("log-gatherer-furlfile",
+                           os.path.join(self.basedir, "log_gatherer.furl"))
+
     def log(self, msg, src="", args=(), **kw):
         if src:
             logsrc = src
@@ -222,17 +238,7 @@ class Node(service.MultiService):
 
     def tub_ready(self):
         # called when the Tub is available for registerReference
-        self.setup_log_publisher()
-
-    def setup_log_publisher(self):
-        self.add_service(LogPublisher())
-        log_gatherer_furl = self.get_config("log_gatherer.furl")
-        if log_gatherer_furl:
-            self.tub.connectTo(log_gatherer_furl, self._log_gatherer_connected)
-
-    def _log_gatherer_connected(self, rref):
-        rref.callRemote("logport",
-                        self.nodeid, self.getServiceNamed("log_publisher"))
+        pass
 
     def when_tub_ready(self):
         return self._tub_ready_observerlist.when_fired()
index dc354cf2db97a3eddb7552e644fe5fd346eccf11..352ae6ba6491c7a0750266f3a782b18738c1f8b1 100644 (file)
@@ -1,17 +1,13 @@
 
 import os, time
-from zope.interface import implements
 from twisted.trial import unittest
 from twisted.internet import defer
 from twisted.python import log
 
-from foolscap import Tub, Referenceable
-from foolscap.eventual import fireEventually, flushEventualQueue
+from foolscap.eventual import flushEventualQueue
 from twisted.application import service
-import allmydata
 from allmydata.node import Node, formatTimeTahoeStyle
 from allmydata.util import testutil, fileutil
-from allmydata import logpublisher
 
 class LoggingMultiService(service.MultiService):
     def log(self, msg, **kw):
@@ -59,16 +55,3 @@ class TestCase(unittest.TestCase, testutil.SignalMixin):
         self.failUnless("Z" in t)
         t2 = formatTimeTahoeStyle("ignored", int(time.time()))
         self.failUnless("Z" in t2)
-
-class Gatherer(Referenceable):
-    implements(logpublisher.RILogGatherer)
-    def remote_logport(self, nodeid, logport):
-        d = logport.callRemote("get_versions")
-        d.addCallback(self.d.callback)
-
-class LogObserver(Referenceable):
-    implements(logpublisher.RILogObserver)
-    def __init__(self):
-        self.messages = []
-    def remote_msg(self, d):
-        self.messages.append(d)
index ac51e0231eb5efd06e606add4d2d4ecb27c8a5d7..284bf5e5f82384743d8fc3258678d45424786a7f 100644 (file)
@@ -4,10 +4,8 @@ def foo(): pass # keep the line number constant
 import os
 from twisted.trial import unittest
 
-from twisted.python import failure
-from twisted.python import log as twisted_log
 from allmydata.util import bencode, idlib, humanreadable, mathutil
-from allmydata.util import assertutil, fileutil, testutil, log
+from allmydata.util import assertutil, fileutil, testutil
 
 
 class IDLib(unittest.TestCase):