]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
stats gathering: fix storage server stats if not tracking consumed
authorrobk-tahoe <robk-tahoe@allmydata.com>
Thu, 10 Apr 2008 01:23:06 +0000 (18:23 -0700)
committerrobk-tahoe <robk-tahoe@allmydata.com>
Thu, 10 Apr 2008 01:23:06 +0000 (18:23 -0700)
the RIStatsProvider interface requires that counter and stat values be
ChoiceOf(float, int, long)  the recent changes to storage server to not
track 'consumed' led to returning None as the value of a counter.
this causes violations to be experienced by nodes whose stats are being
gathered.

this patch simply omits that stat if 'consumed' is not being tracked.

src/allmydata/storage.py

index acbe1b7214fb3485d5ec418ac830ec79cb9563ba..60c643beceb2a7f4cca08c6345dec0dd9426f64d 100644 (file)
@@ -728,9 +728,10 @@ class StorageServer(service.MultiService, Referenceable):
         fileutil.rm_dir(self.incomingdir)
 
     def get_stats(self):
-        return { 'storage_server.consumed': self.consumed,
-                 'storage_server.allocated': self.allocated_size(),
-               }
+        stats = { 'storage_server.allocated': self.allocated_size(), }
+        if self.consumed is not None:
+            stats['storage_server.consumed'] = self.consumed
+        return stats
 
     def allocated_size(self):
         space = self.consumed or 0