self.log("hotline file missing, shutting down")
reactor.stop()
- def get_all_serverids(self):
- return self.storage_broker.get_all_serverids()
- def get_nickname_for_serverid(self, serverid):
- return self.storage_broker.get_nickname_for_serverid(serverid)
-
def get_encoding_parameters(self):
return self.DEFAULT_ENCODING_PARAMETERS
temporary test network and need to know when it is safe to proceed
with an upload or download."""
def _check():
- current_clients = list(self.get_all_serverids())
+ current_clients = list(self.storage_broker.get_all_serverids())
return len(current_clients) >= num_clients
d = self.poll(_check, 0.5)
d.addCallback(lambda res: None)
def get_servers(self, key):
return sorted(self.client._servers,
key=lambda x: sha.new(key+x[0]).digest())
+ def get_nickname_for_serverid(self, serverid):
+ return None
class NoNetworkClient(Client):
def get_servers(self, service_name):
return self._servers
- def get_nickname_for_serverid(self, serverid):
- return None
-
class SimpleStats:
def __init__(self):
self.counters = {}
from common_web import WebRenderingMixin
class FakeClient:
- def get_nickname_for_serverid(self, serverid):
- return self.storage_broker.get_nickname_for_serverid(serverid)
def get_storage_broker(self):
return self.storage_broker
fss = FakeStorageServer(peerid, self._storage)
self.storage_broker.add_server(peerid, fss)
- def get_all_serverids(self):
- return self.storage_broker.get_all_serverids()
def get_storage_broker(self):
return self.storage_broker
def debug_break_connection(self, peerid):
def _created(n):
self.failUnless(isinstance(n, FastMutableFileNode))
self.failUnlessEqual(n.get_storage_index(), n._storage_index)
- peer0 = sorted(self.client.get_all_serverids())[0]
+ sb = self.client.get_storage_broker()
+ peer0 = sorted(sb.get_all_serverids())[0]
shnums = self.client._storage._peers[peer0].keys()
self.failUnlessEqual(len(shnums), 1)
d.addCallback(_created)
places = [2, 2, 3, 2, 1, 1, 1, 2]
sharemap = {}
+ sb = self._client.get_storage_broker()
- for i,peerid in enumerate(self._client.get_all_serverids()):
+ for i,peerid in enumerate(sb.get_all_serverids()):
peerid_s = shortnodeid_b2a(peerid)
for shnum in self._shares1.get(peerid, {}):
if shnum < len(places):
# not prevent an update from succeeding either.
basedir = os.path.join("mutable/CollidingWrites/test_bad_server")
self.client = LessFakeClient(basedir, 10)
+ sb = self.client.get_storage_broker()
- peerids = list(self.client.get_all_serverids())
+ peerids = list(sb.get_all_serverids())
self.client.debug_break_connection(peerids[0])
d = self.client.create_mutable_file("contents 1")
# Break all servers: the publish should fail
basedir = os.path.join("mutable/CollidingWrites/publish_all_servers_bad")
self.client = LessFakeClient(basedir, 20)
- for peerid in self.client.get_all_serverids():
+ sb = self.client.get_storage_broker()
+ for peerid in sb.get_all_serverids():
self.client.debug_break_connection(peerid)
d = self.shouldFail(NotEnoughServersError,
"test_publish_all_servers_bad",
def _check(extra_node):
self.extra_node = extra_node
for c in self.clients:
- all_peerids = list(c.get_all_serverids())
+ all_peerids = list(c.get_storage_broker().get_all_serverids())
self.failUnlessEqual(len(all_peerids), self.numclients+1)
sb = c.storage_broker
permuted_peers = list(sb.get_servers("a"))
d = self.set_up_nodes()
def _check_connections(res):
for c in self.clients:
- all_peerids = list(c.get_all_serverids())
+ all_peerids = list(c.get_storage_broker().get_all_serverids())
self.failUnlessEqual(len(all_peerids), self.numclients)
sb = c.storage_broker
permuted_peers = list(sb.get_servers("a"))
def connected_to_introducer(self):
return False
- def get_nickname_for_serverid(self, serverid):
- return u"John Doe"
-
storage_broker = StorageFarmBroker()
def get_storage_broker(self):
return self.storage_broker
def _render_results(self, ctx, cr):
assert ICheckResults(cr)
c = self.client
+ sb = c.get_storage_broker()
data = cr.get_data()
r = []
def add(name, value):
if data["list-corrupt-shares"]:
badsharemap = []
for (serverid, si, shnum) in data["list-corrupt-shares"]:
- nickname = c.get_nickname_for_serverid(serverid)
+ nickname = sb.get_nickname_for_serverid(serverid)
badsharemap.append(T.tr[T.td["sh#%d" % shnum],
T.td[T.div(class_="nickname")[nickname],
T.div(class_="nodeid")[T.tt[base32.b2a(serverid)]]],
shareid_s = ""
if i == 0:
shareid_s = shareid
- nickname = c.get_nickname_for_serverid(serverid)
+ nickname = sb.get_nickname_for_serverid(serverid)
sharemap.append(T.tr[T.td[shareid_s],
T.td[T.div(class_="nickname")[nickname],
T.div(class_="nodeid")[T.tt[base32.b2a(serverid)]]]
num_shares_left = sum([len(shares) for shares in servers.values()])
servermap = []
for serverid in permuted_peer_ids:
- nickname = c.get_nickname_for_serverid(serverid)
+ nickname = sb.get_nickname_for_serverid(serverid)
shareids = servers.get(serverid, [])
shareids.reverse()
shareids_s = [ T.tt[shareid, " "] for shareid in sorted(shareids) ]
def render_server_problem(self, ctx, data):
serverid = data
data = [idlib.shortnodeid_b2a(serverid)]
- nickname = self.client.get_nickname_for_serverid(serverid)
+ sb = self.client.get_storage_broker()
+ nickname = sb.get_nickname_for_serverid(serverid)
if nickname:
data.append(" (%s)" % self._html(nickname))
return ctx.tag[data]
return self.monitor.get_status().get_corrupt_shares()
def render_share_problem(self, ctx, data):
serverid, storage_index, sharenum = data
- nickname = self.client.get_nickname_for_serverid(serverid)
+ sb = self.client.get_storage_broker()
+ nickname = sb.get_nickname_for_serverid(serverid)
ctx.fillSlots("serverid", idlib.shortnodeid_b2a(serverid))
if nickname:
ctx.fillSlots("nickname", self._html(nickname))