]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable: fix use of storage API
authorBrian Warner <warner@allmydata.com>
Wed, 7 Nov 2007 01:53:34 +0000 (18:53 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 7 Nov 2007 01:53:34 +0000 (18:53 -0700)
src/allmydata/interfaces.py
src/allmydata/mutable.py
src/allmydata/test/test_mutable.py

index d4cf522f59a5d9fe330f3a1fb26d73575859bd87..171d2da44d714110f593e1fbad3112f985745ea3 100644 (file)
@@ -181,12 +181,15 @@ class RIStorageServer(RemoteInterface):
         Each share can have a separate test vector (i.e. a list of
         comparisons to perform). If all vectors for all shares pass, then all
         writes for all shares are recorded. Each comparison is a 4-tuple of
-        (offset, length, operator, specimen), which effectively does a
-        read(offset, length) and then compares the result against the
-        specimen using the given equality/inequality operator. Reads from the
-        end of the container are truncated, and missing shares behave like
-        empty ones, so to assert that a share doesn't exist (for use when
-        creating a new share), use (0, 1, 'eq', '').
+        (offset, length, operator, specimen), which effectively does a bool(
+        (read(offset, length)) OPERATOR specimen ) and only performs the
+        write if all these evaluate to True. Basic test-and-set uses 'eq'.
+        Write-if-newer uses a seqnum and (offset, length, 'lt', specimen).
+        Write-if-same-or-newer uses 'le'.
+
+        Reads from the end of the container are truncated, and missing shares
+        behave like empty ones, so to assert that a share doesn't exist (for
+        use when creating a new share), use (0, 1, 'eq', '').
 
         The write vector will be applied to the given share, expanding it if
         necessary. A write vector applied to a share number that did not
index e207de59fc303effad27993e88e2fa8b8f23a201..c7baca4eb8ae1dd4a8df32ff002394b8df4313cc 100644 (file)
@@ -272,7 +272,8 @@ class Retrieve:
                 peer_storage_servers[peerid] = ss
                 return ss
             d.addCallback(_got_storageserver)
-        d.addCallback(lambda ss: ss.callRemote("readv_slots", [(0, readsize)]))
+        d.addCallback(lambda ss: ss.callRemote("slot_readv", storage_index,
+                                               [], [(0, readsize)]))
         d.addCallback(self._got_results, peerid, readsize)
         d.addErrback(self._query_failed, peerid, (conn, storage_index,
                                                   peer_storage_servers))
@@ -676,7 +677,8 @@ class Publish:
         peer_storage_servers = {}
         dl = []
         for (permutedid, peerid, conn) in partial_peerlist:
-            d = self._do_query(conn, peerid, peer_storage_servers)
+            d = self._do_query(conn, peerid, peer_storage_servers,
+                               storage_index)
             d.addCallback(self._got_query_results,
                           peerid, permutedid,
                           reachable_peers, current_share_peers)
@@ -688,11 +690,11 @@ class Publish:
         # TODO: add an errback to, probably to ignore that peer
         return d
 
-    def _do_query(self, conn, peerid, peer_storage_servers):
+    def _do_query(self, conn, peerid, peer_storage_servers, storage_index):
         d = conn.callRemote("get_service", "storageserver")
         def _got_storageserver(ss):
             peer_storage_servers[peerid] = ss
-            return ss.callRemote("readv_slots", [(0, 2000)])
+            return ss.callRemote("slot_readv", storage_index, [], [(0, 2000)])
         d.addCallback(_got_storageserver)
         return d
 
@@ -770,7 +772,7 @@ class Publish:
 
         for shnum, peers in target_map.items():
             for (peerid, old_seqnum, old_root_hash) in peers:
-                testv = [(0, len(my_checkstring), "ge", my_checkstring)]
+                testv = [(0, len(my_checkstring), "le", my_checkstring)]
                 new_share = self._new_shares[shnum]
                 writev = [(0, new_share)]
                 if peerid not in peer_messages:
index d488448d34ca730c562c05817917235be29e300d..8665be8d1ca1825e89c7170684ce87539c71f81a 100644 (file)
@@ -64,7 +64,7 @@ class FakeFilenode(mutable.MutableFileNode):
         return "fake readonly"
 
 class FakePublish(mutable.Publish):
-    def _do_query(self, conn, peerid, peer_storage_servers):
+    def _do_query(self, conn, peerid, peer_storage_servers, storage_index):
         assert conn[0] == peerid
         shares = self._peers[peerid]
         return defer.succeed(shares)