]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Teach uploader to keep object stats not file stats 158/head 160/head
authorDavid Stainton <dstainton415@gmail.com>
Fri, 17 Apr 2015 22:30:27 +0000 (23:30 +0100)
committerDavid Stainton <dstainton415@gmail.com>
Fri, 17 Apr 2015 22:30:27 +0000 (23:30 +0100)
- we keep track of objects instead of files so that we are not
forced to determine the object type (file, directory, symlink, special file etc.)

src/allmydata/frontends/drop_upload.py
src/allmydata/test/test_drop_upload.py

index 57ff6705edab69e12e6b776b0edbd196b19e6601..de193d3a219feb621a1f8613547ac9e489a2bee8 100644 (file)
@@ -148,7 +148,7 @@ class DropUploader(service.MultiService):
 
     def _notify(self, opaque, path, events_mask):
         self._log("inotify event %r, %r, %r\n" % (opaque, path, ', '.join(self._inotify.humanReadableMask(events_mask))))
-        self._stats_provider.count('drop_upload.files_queued', 1)
+        self._stats_provider.count('drop_upload.objects_queued', 1)
         if path not in self._pending:
             self._append_to_deque(path)
 
@@ -168,18 +168,18 @@ class DropUploader(service.MultiService):
         d.addCallback(_add_file)
 
         def _succeeded(ign):
-            self._stats_provider.count('drop_upload.files_queued', -1)
-            self._stats_provider.count('drop_upload.files_uploaded', 1)
+            self._stats_provider.count('drop_upload.objects_queued', -1)
+            self._stats_provider.count('drop_upload.objects_uploaded', 1)
         def _failed(f):
-            self._stats_provider.count('drop_upload.files_queued', -1)
+            self._stats_provider.count('drop_upload.objects_queued', -1)
             if path.exists():
                 self._log("drop-upload: %r failed to upload due to %r" % (path.path, f))
-                self._stats_provider.count('drop_upload.files_failed', 1)
+                self._stats_provider.count('drop_upload.objects_failed', 1)
                 return f
             else:
-                self._log("drop-upload: notified file %r disappeared "
-                          "(this is normal for temporary files): %r" % (path.path, f))
-                self._stats_provider.count('drop_upload.files_disappeared', 1)
+                self._log("drop-upload: notified object %r disappeared "
+                          "(this is normal for temporary objects): %r" % (path.path, f))
+                self._stats_provider.count('drop_upload.objects_disappeared', 1)
                 return None
         d.addCallbacks(_succeeded, _failed)
         d.addBoth(self._uploaded_callback)
index 85900aeaf3ff57e5bebea456aad6aed8dbc520f3..b09d4f91364838e7eec14b69c2d76d93f0b64c1b 100644 (file)
@@ -118,8 +118,8 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         return d
 
     def _test_file(self, name_u, data, temporary=False):
-        previously_uploaded = self._get_count('drop_upload.files_uploaded')
-        previously_disappeared = self._get_count('drop_upload.files_disappeared')
+        previously_uploaded = self._get_count('drop_upload.objects_uploaded')
+        previously_disappeared = self._get_count('drop_upload.objects_disappeared')
 
         d = defer.Deferred()
 
@@ -150,16 +150,16 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         if temporary:
             d.addCallback(lambda ign: self.shouldFail(NoSuchChildError, 'temp file not uploaded', None,
                                                       self.upload_dirnode.get, name_u))
-            d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.files_disappeared'),
+            d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_disappeared'),
                                                                  previously_disappeared + 1))
         else:
             d.addCallback(lambda ign: self.upload_dirnode.get(name_u))
             d.addCallback(download_to_data)
             d.addCallback(lambda actual_data: self.failUnlessReallyEqual(actual_data, data))
-            d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.files_uploaded'),
+            d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'),
                                                                  previously_uploaded + 1))
 
-        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.files_queued'), 0))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
         return d