]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
storage: clean up use of si_s vs si_dir, add test for BadWriterEnabler message, add...
authorBrian Warner <warner@allmydata.com>
Fri, 1 Feb 2008 00:48:48 +0000 (17:48 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 1 Feb 2008 00:48:48 +0000 (17:48 -0700)
src/allmydata/storage.py
src/allmydata/test/test_storage.py

index a89f05c5ef53ed3eb1b4dc024bbdb81bc3e0746c..b2ac17e8d194adac20c80b05c0fd95d3aa225675 100644 (file)
@@ -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
 
 
index ba50d315c102b87afd32eeac567abe2bfbbf4688..5b389e5af9edec856532f26ffc704c9daf6e0594 100644 (file)
@@ -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,