From: Brian Warner Date: Fri, 1 Feb 2008 00:48:48 +0000 (-0700) Subject: storage: clean up use of si_s vs si_dir, add test for BadWriterEnabler message, add... X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/status?a=commitdiff_plain;h=670933eceeba26a6e7ba3c12537cd72d82ca30c1;p=tahoe-lafs%2Ftahoe-lafs.git storage: clean up use of si_s vs si_dir, add test for BadWriterEnabler message, add some logging --- diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py index a89f05c5..b2ac17e8 100644 --- a/src/allmydata/storage.py +++ b/src/allmydata/storage.py @@ -729,7 +729,7 @@ class StorageServer(service.MultiService, Referenceable): # to a particular owner. alreadygot = set() bucketwriters = {} # k: shnum, v: BucketWriter - si_s = storage_index_to_dir(storage_index) + si_dir = storage_index_to_dir(storage_index) # in this implementation, the lease information (including secrets) # goes into the share files themselves. It could also be put into a @@ -755,8 +755,8 @@ class StorageServer(service.MultiService, Referenceable): sf.add_or_renew_lease(lease_info) for shnum in sharenums: - incominghome = os.path.join(self.incomingdir, si_s, "%d" % shnum) - finalhome = os.path.join(self.sharedir, si_s, "%d" % shnum) + incominghome = os.path.join(self.incomingdir, si_dir, "%d" % shnum) + finalhome = os.path.join(self.sharedir, si_dir, "%d" % shnum) if os.path.exists(incominghome) or os.path.exists(finalhome): # great! we already have it. easy. pass @@ -775,7 +775,7 @@ class StorageServer(service.MultiService, Referenceable): pass if bucketwriters: - fileutil.make_dirs(os.path.join(self.sharedir, si_s)) + fileutil.make_dirs(os.path.join(self.sharedir, si_dir)) return alreadygot, bucketwriters @@ -900,10 +900,11 @@ class StorageServer(service.MultiService, Referenceable): secrets, test_and_write_vectors, read_vector): - si_s = storage_index_to_dir(storage_index) + si_s = idlib.b2a(storage_index) + si_dir = storage_index_to_dir(storage_index) (write_enabler, renew_secret, cancel_secret) = secrets # shares exist if there is a file for them - bucketdir = os.path.join(self.sharedir, si_s) + bucketdir = os.path.join(self.sharedir, si_dir) shares = {} if os.path.isdir(bucketdir): for sharenum_s in os.listdir(bucketdir): @@ -977,9 +978,12 @@ class StorageServer(service.MultiService, Referenceable): return share def remote_slot_readv(self, storage_index, shares, readv): - si_s = storage_index_to_dir(storage_index) + si_s = idlib.b2a(storage_index) + lp = log.msg("storage: slot_readv %s %s" % (si_s, shares), + facility="tahoe.storage", level=log.OPERATIONAL) + si_dir = storage_index_to_dir(storage_index) # shares exist if there is a file for them - bucketdir = os.path.join(self.sharedir, si_s) + bucketdir = os.path.join(self.sharedir, si_dir) if not os.path.isdir(bucketdir): return {} datavs = {} @@ -992,6 +996,8 @@ class StorageServer(service.MultiService, Referenceable): filename = os.path.join(bucketdir, sharenum_s) msf = MutableShareFile(filename, self) datavs[sharenum] = msf.readv(readv) + log.msg("returning shares %s" % (datavs.keys(),), + facility="tahoe.storage", level=log.NOISY, parent=lp) return datavs diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index ba50d315..5b389e5a 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -554,9 +554,10 @@ class MutableServer(unittest.TestCase): #self.failUnlessEqual(s0.remote_get_length(), 100) bad_secrets = ("bad write enabler", secrets[1], secrets[2]) - self.failUnlessRaises(BadWriteEnablerError, - write, "si1", bad_secrets, - {}, []) + f = self.failUnlessRaises(BadWriteEnablerError, + write, "si1", bad_secrets, + {}, []) + self.failUnless("The write enabler was recorded by nodeid 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'." in f, f) # this testv should fail answer = write("si1", secrets,