mutable: fix use of storage API

This commit is contained in:
Brian Warner 2007-11-06 18:53:34 -07:00
parent c4f7412f1c
commit 7e43c7b5f9
3 changed files with 17 additions and 12 deletions

View 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

View 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:

View 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)