From: Brian Warner Date: Tue, 17 Jul 2007 01:07:03 +0000 (-0700) Subject: client.py: add a 'debug_no_storage' option to throw out all share data X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags/index.php?a=commitdiff_plain;h=1aa22b9abd6e699c721b130330fcdab30ffaf302;p=tahoe-lafs%2Ftahoe-lafs.git client.py: add a 'debug_no_storage' option to throw out all share data --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index a4cace20..7c68ba94 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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): diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py index 4b0fccfa..8e42012d 100644 --- a/src/allmydata/storage.py +++ b/src/allmydata/storage.py @@ -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: