From: David Stainton Date: Fri, 17 Apr 2015 22:30:27 +0000 (+0100) Subject: Teach uploader to keep object stats not file stats X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=refs%2Fpull%2F158%2Fhead;p=tahoe-lafs%2Ftahoe-lafs.git Teach uploader to keep object stats not file stats - 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.) --- diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index 57ff6705..de193d3a 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -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) diff --git a/src/allmydata/test/test_drop_upload.py b/src/allmydata/test/test_drop_upload.py index 85900aea..b09d4f91 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -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