From: Brian Warner Date: Mon, 1 Aug 2011 17:44:28 +0000 (-0700) Subject: replace IServer.name() with get_name(), and get_longname() X-Git-Url: https://git.rkrishnan.org/vdrive/%5B/%5D%20/uri/%3C?a=commitdiff_plain;h=0f11d35f855ed7c0e87432ffda508c0974452ee5;p=tahoe-lafs%2Ftahoe-lafs.git replace IServer.name() with get_name(), and get_longname() This patch was originally written by Brian, but was re-recorded by Zooko to use darcs replace instead of hunks for any file in which it would result in fewer total hunks. refs #1363 --- diff --git a/src/allmydata/control.py b/src/allmydata/control.py index a081e19e..f2f15505 100644 --- a/src/allmydata/control.py +++ b/src/allmydata/control.py @@ -100,7 +100,7 @@ class ControlServer(Referenceable, service.Service): if not everyone_left: return results server = everyone_left.pop(0) - server_name = server.longname() + server_name = server.get_longname() connection = server.get_rref() start = time.time() d = connection.callRemote("get_buckets", "\x00"*16) diff --git a/src/allmydata/immutable/checker.py b/src/allmydata/immutable/checker.py index 0268d8d1..2f6de07f 100644 --- a/src/allmydata/immutable/checker.py +++ b/src/allmydata/immutable/checker.py @@ -503,7 +503,7 @@ class Checker(log.PrefixingLogMixin): cancel_secret = self._get_cancel_secret(lease_seed) d2 = rref.callRemote("add_lease", storageindex, renew_secret, cancel_secret) - d2.addErrback(self._add_lease_failed, s.name(), storageindex) + d2.addErrback(self._add_lease_failed, s.get_name(), storageindex) d = rref.callRemote("get_buckets", storageindex) def _wrap_results(res): diff --git a/src/allmydata/immutable/downloader/finder.py b/src/allmydata/immutable/downloader/finder.py index 0103a589..2670a20b 100644 --- a/src/allmydata/immutable/downloader/finder.py +++ b/src/allmydata/immutable/downloader/finder.py @@ -87,7 +87,7 @@ class ShareFinder: # internal methods def loop(self): - pending_s = ",".join([rt.server.name() + pending_s = ",".join([rt.server.get_name() for rt in self.pending_requests]) # sort? self.log(format="ShareFinder loop: running=%(running)s" " hungry=%(hungry)s, pending=%(pending)s", @@ -132,7 +132,7 @@ class ShareFinder: def send_request(self, server): req = RequestToken(server) self.pending_requests.add(req) - lp = self.log(format="sending DYHB to [%(name)s]", name=server.name(), + lp = self.log(format="sending DYHB to [%(name)s]", name=server.get_name(), level=log.NOISY, umid="Io7pyg") time_sent = now() d_ev = self._download_status.add_dyhb_request(server.get_serverid(), @@ -168,12 +168,12 @@ class ShareFinder: d_ev.finished(shnums, time_received) dyhb_rtt = time_received - time_sent if not buckets: - self.log(format="no shares from [%(name)s]", name=server.name(), + self.log(format="no shares from [%(name)s]", name=server.get_name(), level=log.NOISY, parent=lp, umid="U7d4JA") return shnums_s = ",".join([str(shnum) for shnum in shnums]) self.log(format="got shnums [%(shnums)s] from [%(name)s]", - shnums=shnums_s, name=server.name(), + shnums=shnums_s, name=server.get_name(), level=log.NOISY, parent=lp, umid="0fcEZw") shares = [] for shnum, bucket in buckets.iteritems(): @@ -220,7 +220,7 @@ class ShareFinder: def _got_error(self, f, server, req, d_ev, lp): d_ev.error(now()) self.log(format="got error from [%(name)s]", - name=server.name(), failure=f, + name=server.get_name(), failure=f, level=log.UNUSUAL, parent=lp, umid="zUKdCw") diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py index 1918d902..4fc59035 100644 --- a/src/allmydata/immutable/downloader/share.py +++ b/src/allmydata/immutable/downloader/share.py @@ -94,7 +94,7 @@ class Share: self.had_corruption = False # for unit tests def __repr__(self): - return "Share(sh%d-on-%s)" % (self._shnum, self._server.name()) + return "Share(sh%d-on-%s)" % (self._shnum, self._server.get_name()) def is_alive(self): # XXX: reconsider. If the share sees a single error, should it remain @@ -797,7 +797,7 @@ class Share: log.msg(format="error requesting %(start)d+%(length)d" " from %(server)s for si %(si)s", start=start, length=length, - server=self._server.name(), si=self._si_prefix, + server=self._server.get_name(), si=self._si_prefix, failure=f, parent=lp, level=log.UNUSUAL, umid="BZgAJw") # retire our observers, assuming we won't be able to make any # further progress diff --git a/src/allmydata/immutable/offloaded.py b/src/allmydata/immutable/offloaded.py index 1f2cce99..94f5cdd0 100644 --- a/src/allmydata/immutable/offloaded.py +++ b/src/allmydata/immutable/offloaded.py @@ -64,7 +64,7 @@ class CHKCheckerAndUEBFetcher: # buckets is a dict: maps shum to an rref of the server who holds it shnums_s = ",".join([str(shnum) for shnum in buckets]) self.log("got_response: [%s] has %d shares (%s)" % - (server.name(), len(buckets), shnums_s), + (server.get_name(), len(buckets), shnums_s), level=log.NOISY) self._found_shares.update(buckets.keys()) for k in buckets: diff --git a/src/allmydata/immutable/upload.py b/src/allmydata/immutable/upload.py index 199dcb2e..24ea51dd 100644 --- a/src/allmydata/immutable/upload.py +++ b/src/allmydata/immutable/upload.py @@ -93,12 +93,12 @@ class ServerTracker: def __repr__(self): return ("" - % (self._server.name(), si_b2a(self.storage_index)[:5])) + % (self._server.get_name(), si_b2a(self.storage_index)[:5])) def get_serverid(self): return self._server.get_serverid() - def name(self): - return self._server.name() + def get_name(self): + return self._server.get_name() def query(self, sharenums): rref = self._server.get_rref() @@ -286,7 +286,7 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin): self.num_servers_contacted += 1 self.query_count += 1 self.log("asking server %s for any existing shares" % - (tracker.name(),), level=log.NOISY) + (tracker.get_name(),), level=log.NOISY) dl = defer.DeferredList(ds) dl.addCallback(lambda ign: self._loop()) return dl @@ -300,7 +300,7 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin): serverid = tracker.get_serverid() if isinstance(res, failure.Failure): self.log("%s got error during existing shares check: %s" - % (tracker.name(), res), level=log.UNUSUAL) + % (tracker.get_name(), res), level=log.UNUSUAL) self.error_count += 1 self.bad_query_count += 1 else: @@ -308,7 +308,7 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin): if buckets: self.serverids_with_shares.add(serverid) self.log("response to get_buckets() from server %s: alreadygot=%s" - % (tracker.name(), tuple(sorted(buckets))), + % (tracker.get_name(), tuple(sorted(buckets))), level=log.NOISY) for bucket in buckets: self.preexisting_shares.setdefault(bucket, set()).add(serverid) @@ -416,7 +416,7 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin): if self._status: self._status.set_status("Contacting Servers [%s] (first query)," " %d shares left.." - % (tracker.name(), + % (tracker.get_name(), len(self.homeless_shares))) d = tracker.query(shares_to_ask) d.addBoth(self._got_response, tracker, shares_to_ask, @@ -437,7 +437,7 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin): if self._status: self._status.set_status("Contacting Servers [%s] (second query)," " %d shares left.." - % (tracker.name(), + % (tracker.get_name(), len(self.homeless_shares))) d = tracker.query(shares_to_ask) d.addBoth(self._got_response, tracker, shares_to_ask, @@ -498,7 +498,7 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin): else: (alreadygot, allocated) = res self.log("response to allocate_buckets() from server %s: alreadygot=%s, allocated=%s" - % (tracker.name(), + % (tracker.get_name(), tuple(sorted(alreadygot)), tuple(sorted(allocated))), level=log.NOISY) progress = False diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index ff5f9016..187828d1 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -193,7 +193,7 @@ class NativeStorageServer: self._trigger_cb = None def __repr__(self): - return "" % self.name() + return "" % self.get_name() def get_serverid(self): return self._tubid def get_permutation_seed(self): @@ -202,9 +202,9 @@ class NativeStorageServer: if self.rref: return self.rref.version return None - def name(self): # keep methodname short + def get_name(self): # keep methodname short return self.serverid_s - def longname(self): + def get_longname(self): return idlib.nodeid_b2a(self._tubid) def get_lease_seed(self): return self._tubid @@ -231,7 +231,7 @@ class NativeStorageServer: def _got_connection(self, rref): lp = log.msg(format="got connection to %(name)s, getting versions", - name=self.name(), + name=self.get_name(), facility="tahoe.storage_broker", umid="coUECQ") if self._trigger_cb: eventually(self._trigger_cb) @@ -239,11 +239,11 @@ class NativeStorageServer: d = add_version_to_remote_reference(rref, default) d.addCallback(self._got_versioned_service, lp) d.addErrback(log.err, format="storageclient._got_connection", - name=self.name(), umid="Sdq3pg") + name=self.get_name(), umid="Sdq3pg") def _got_versioned_service(self, rref, lp): log.msg(format="%(name)s provided version info %(version)s", - name=self.name(), version=rref.version, + name=self.get_name(), version=rref.version, facility="tahoe.storage_broker", umid="SWmJYg", level=log.NOISY, parent=lp) @@ -256,7 +256,7 @@ class NativeStorageServer: return self.rref def _lost(self): - log.msg(format="lost connection to %(name)s", name=self.name(), + log.msg(format="lost connection to %(name)s", name=self.get_name(), facility="tahoe.storage_broker", umid="zbRllw") self.last_loss_time = time.time() self.rref = None diff --git a/src/allmydata/test/no_network.py b/src/allmydata/test/no_network.py index 42a90dd5..535cac1f 100644 --- a/src/allmydata/test/no_network.py +++ b/src/allmydata/test/no_network.py @@ -122,16 +122,16 @@ class NoNetworkServer: self.serverid = serverid self.rref = rref def __repr__(self): - return "" % self.name() + return "" % self.get_name() def get_serverid(self): return self.serverid def get_permutation_seed(self): return self.serverid def get_lease_seed(self): return self.serverid - def name(self): + def get_name(self): return idlib.shortnodeid_b2a(self.serverid) - def longname(self): + def get_longname(self): return idlib.nodeid_b2a(self.serverid) def get_nickname(self): return "nickname" diff --git a/src/allmydata/test/test_download.py b/src/allmydata/test/test_download.py index f6154cb5..e5357085 100644 --- a/src/allmydata/test/test_download.py +++ b/src/allmydata/test/test_download.py @@ -1284,7 +1284,7 @@ class MyShare: self._server = server self._dyhb_rtt = rtt def __repr__(self): - return "sh%d-on-%s" % (self._shnum, self._server.name()) + return "sh%d-on-%s" % (self._shnum, self._server.get_name()) class MySegmentFetcher(SegmentFetcher): def __init__(self, *args, **kwargs): @@ -1342,7 +1342,7 @@ class Selection(unittest.TestCase): def _check2(ign): self.failUnless(node.failed) self.failUnless(node.failed.check(NotEnoughSharesError)) - sname = serverA.name() + sname = serverA.get_name() self.failUnlessIn("complete= pending=sh0-on-%s overdue= unused=" % sname, str(node.failed)) d.addCallback(_check2) @@ -1564,7 +1564,7 @@ class Selection(unittest.TestCase): def _check4(ign): self.failUnless(node.failed) self.failUnless(node.failed.check(NotEnoughSharesError)) - sname = servers["peer-2"].name() + sname = servers["peer-2"].get_name() self.failUnlessIn("complete=sh0 pending= overdue=sh2-on-%s unused=" % sname, str(node.failed)) d.addCallback(_check4) diff --git a/src/allmydata/test/test_immutable.py b/src/allmydata/test/test_immutable.py index 94a88e91..beb62698 100644 --- a/src/allmydata/test/test_immutable.py +++ b/src/allmydata/test/test_immutable.py @@ -103,7 +103,7 @@ class TestShareFinder(unittest.TestCase): return self.serverid def get_rref(self): return self.rref - def name(self): + def get_name(self): return "name-%s" % self.serverid def get_version(self): return self.rref.version diff --git a/src/allmydata/web/check_results.py b/src/allmydata/web/check_results.py index 79857667..82c0a779 100644 --- a/src/allmydata/web/check_results.py +++ b/src/allmydata/web/check_results.py @@ -151,7 +151,7 @@ class ResultsBase: shareids.reverse() shareids_s = [ T.tt[shareid, " "] for shareid in sorted(shareids) ] servermap.append(T.tr[T.td[T.div(class_="nickname")[nickname], - T.div(class_="nodeid")[T.tt[s.name()]]], + T.div(class_="nodeid")[T.tt[s.get_name()]]], T.td[shareids_s], ]) num_shares_left -= len(shareids) diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 9d19894f..1bef5832 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -261,7 +261,7 @@ class Root(rend.Page): def render_service_row(self, ctx, server): nodeid = server.get_serverid() - ctx.fillSlots("peerid", server.longname()) + ctx.fillSlots("peerid", server.get_longname()) ctx.fillSlots("nickname", server.get_nickname()) rhost = server.get_remote_host() if rhost: