]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Teach uploader to keep object stats not file stats
authorDavid Stainton <dstainton415@gmail.com>
Fri, 17 Apr 2015 22:30:27 +0000 (23:30 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 18:39:38 +0000 (19:39 +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 b2f1a5d592d9bd7930d04f993b77b23146210141..1b3d52a62caebaab2f8989cc585b4a5e79179efe 100644 (file)
@@ -154,7 +154,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)
 
@@ -174,18 +174,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 23039f620e3aea4fa27e9c04485919e331487f17..c2536cb67c3f4d4bbd7ad4d6556d7f46a9304965 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