]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
client.py: add a 'debug_no_storage' option to throw out all share data
authorBrian Warner <warner@allmydata.com>
Tue, 17 Jul 2007 01:07:03 +0000 (18:07 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 17 Jul 2007 01:07:03 +0000 (18:07 -0700)
src/allmydata/client.py
src/allmydata/storage.py

index a4cace20bdbc5ba981cbdac0fcb40cf5a300932c..7c68ba94b7d679265ac5c4196391104c9631d2e8 100644 (file)
@@ -83,7 +83,9 @@ class Client(node.Node, Referenceable):
                               "G": 1000 * 1000 * 1000,
                               }[suffix]
                 sizelimit = int(number) * multiplier
-        self.add_service(StorageServer(storedir, sizelimit))
+        NOSTORAGE_FILE = os.path.join(self.basedir, "debug_no_storage")
+        no_storage = os.path.exists(NOSTORAGE_FILE)
+        self.add_service(StorageServer(storedir, sizelimit, no_storage))
 
     def _check_hotline(self, hotline_file):
         if os.path.exists(hotline_file):
index 4b0fccfab61de6eef942153c433703f9305df8da..8e42012d593ca3250f5e81c56e7815b392d0b36a 100644 (file)
@@ -31,6 +31,7 @@ class BucketWriter(Referenceable):
         self.finalhome = finalhome
         self._size = size
         self.closed = False
+        self.throw_out_all_data = False
         # touch the file, so later callers will see that we're working on it
         f = open(self.incominghome, 'ab')
         f.close()
@@ -42,6 +43,8 @@ class BucketWriter(Referenceable):
         precondition(not self.closed)
         precondition(offset >= 0)
         precondition(offset+len(data) <= self._size)
+        if self.throw_out_all_data:
+            return
         f = open(self.incominghome, 'ab')
         f.seek(offset)
         f.write(data)
@@ -70,11 +73,12 @@ class StorageServer(service.MultiService, Referenceable):
     implements(RIStorageServer)
     name = 'storageserver'
 
-    def __init__(self, storedir, sizelimit=None):
+    def __init__(self, storedir, sizelimit=None, no_storage=False):
         service.MultiService.__init__(self)
         fileutil.make_dirs(storedir)
         self.storedir = storedir
         self.sizelimit = sizelimit
+        self.no_storage = no_storage
         self.incomingdir = os.path.join(storedir, 'incoming')
         self._clean_incomplete()
         fileutil.make_dirs(self.incomingdir)
@@ -113,6 +117,8 @@ class StorageServer(service.MultiService, Referenceable):
                 fileutil.make_dirs(os.path.join(self.incomingdir, si_s))
                 bw = BucketWriter(self, incominghome, finalhome,
                                   space_per_bucket)
+                if self.no_storage:
+                    bw.throw_out_all_data = True
                 bucketwriters[shnum] = bw
                 self._active_writers[bw] = 1
                 if yes_limits: