]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable stats: track mutable bytes published too
authorBrian Warner <warner@allmydata.com>
Wed, 30 Apr 2008 01:20:05 +0000 (18:20 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 30 Apr 2008 01:20:05 +0000 (18:20 -0700)
src/allmydata/client.py
src/allmydata/mutable/node.py
src/allmydata/web/status.py

index 87f77f48e40514cb369fdc553660eb829feaca10..cb96b4958ee28599194474d428420bc09483c212 100644 (file)
@@ -307,8 +307,9 @@ class Client(node.Node, testutil.PollMixin):
         assert IMutableFileURI.providedBy(u), u
         return MutableFileNode(self).init_from_uri(u)
 
-    def notify_publish(self, publish_status):
-        self.getServiceNamed("mutable-watcher").notify_publish(publish_status)
+    def notify_publish(self, publish_status, size):
+        self.getServiceNamed("mutable-watcher").notify_publish(publish_status,
+                                                               size)
     def notify_retrieve(self, retrieve_status):
         self.getServiceNamed("mutable-watcher").notify_retrieve(retrieve_status)
     def notify_mapupdate(self, update_status):
index 275ed377402866b2ac1192461dcc08f8345dc47f..b54bddb413075af976b7385a65779b6dab3a3a95 100644 (file)
@@ -381,7 +381,7 @@ class MutableFileNode:
     def _upload(self, new_contents, servermap):
         assert self._pubkey, "update_servermap must be called before publish"
         p = Publish(self, servermap)
-        self._client.notify_publish(p.get_status())
+        self._client.notify_publish(p.get_status(), len(new_contents))
         return p.publish(new_contents)
 
 
@@ -410,16 +410,16 @@ class MutableWatcher(service.MultiService):
         while len(self._recent_mapupdate_status) > self.MAX_MAPUPDATE_STATUSES:
             self._recent_mapupdate_status.pop(0)
 
-    def notify_publish(self, p):
+    def notify_publish(self, p, size):
         self._all_publish_status[p] = None
         self._recent_publish_status.append(p)
         if self.stats_provider:
             self.stats_provider.count('mutable.files_published', 1)
-            # bytes_published can't be handled here, because the
+            # We must be told bytes_published as an argument, since the
             # publish_status does not yet know how much data it will be asked
-            # to send. TODO: figure out a clean way to do this that doesn't
-            # make MDMF harder.
-            #self.stats_provider.count('mutable.bytes_published', p.get_size())
+            # to send. When we move to MDMF we'll need to find a better way
+            # to handle this.
+            self.stats_provider.count('mutable.bytes_published', size)
         while len(self._recent_publish_status) > self.MAX_PUBLISH_STATUSES:
             self._recent_publish_status.pop(0)
 
index e5903c9e6d57a3fa5a1624425811cf6cb879ebca..e3761e96f1c983b541e90a33c05ef72046b91916 100644 (file)
@@ -947,24 +947,28 @@ class Statistics(rend.Page):
         return str(data["stats"].get("load_monitor.max_load"))
 
     def render_uploads(self, ctx, data):
-        files = data["counters"].get("uploader.files_uploaded")
-        bytes = data["counters"].get("uploader.bytes_uploaded")
+        files = data["counters"].get("uploader.files_uploaded", 0)
+        bytes = data["counters"].get("uploader.bytes_uploaded", 0)
         return ("%s files / %s bytes (%s)" %
                 (files, bytes, abbreviate_size(bytes)))
 
     def render_downloads(self, ctx, data):
-        files = data["counters"].get("downloader.files_downloaded")
-        bytes = data["counters"].get("downloader.bytes_downloaded")
+        files = data["counters"].get("downloader.files_downloaded", 0)
+        bytes = data["counters"].get("downloader.bytes_downloaded", 0)
         return ("%s files / %s bytes (%s)" %
                 (files, bytes, abbreviate_size(bytes)))
 
     def render_publishes(self, ctx, data):
         files = data["counters"].get("mutable.files_published")
-        return "%s files" % (files,)
+        bytes = data["counters"].get("mutable.bytes_published", 0)
+        return "%s files / %s bytes (%s)" % (files, bytes,
+                                             abbreviate_size(bytes))
 
     def render_retrieves(self, ctx, data):
         files = data["counters"].get("mutable.files_retrieved")
-        return "%s files" % (files,)
+        bytes = data["counters"].get("mutable.bytes_retrieved", 0)
+        return "%s files / %s bytes (%s)" % (files, bytes,
+                                             abbreviate_size(bytes))
 
     def render_raw(self, ctx, data):
         raw = pprint.pformat(data)