]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
replace IServer.name() with get_name(), and get_longname()
authorBrian Warner <warner@lothar.com>
Mon, 1 Aug 2011 17:44:28 +0000 (10:44 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 1 Aug 2011 17:44:28 +0000 (10:44 -0700)
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

12 files changed:
src/allmydata/control.py
src/allmydata/immutable/checker.py
src/allmydata/immutable/downloader/finder.py
src/allmydata/immutable/downloader/share.py
src/allmydata/immutable/offloaded.py
src/allmydata/immutable/upload.py
src/allmydata/storage_client.py
src/allmydata/test/no_network.py
src/allmydata/test/test_download.py
src/allmydata/test/test_immutable.py
src/allmydata/web/check_results.py
src/allmydata/web/root.py

index a081e19e957eac492402aaa4362044cdeebbc57e..f2f155059d09e891a7cae2ce150108bfe3a8248a 100644 (file)
@@ -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)
index 0268d8d18b57f7dd4e2917dbe225c019db4ee74b..2f6de07f37038fbb00532d92e80ac19a6004088f 100644 (file)
@@ -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):
index 0103a589e6993bbd0f2e83bb80cecfb2e4f09d2e..2670a20be2a306e465db0ce838cc49cca4f5325c 100644 (file)
@@ -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")
 
 
index 1918d902538f33273b4a5c3e8141ec3ee37da013..4fc59035c5c370d981b717a31464fcaee5afb0e3 100644 (file)
@@ -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
index 1f2cce99af1c535c9b2fa8e673b9efbef7eb7494..94f5cdd0a0447373953f7fabd8e5faf4dd2ebb7a 100644 (file)
@@ -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:
index 199dcb2ea05bff2833da70b349ecf38724306503..24ea51ddd01a115e089b0892560291644928f657 100644 (file)
@@ -93,12 +93,12 @@ class ServerTracker:
 
     def __repr__(self):
         return ("<ServerTracker for server %s and SI %s>"
-                % (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
index ff5f901672b60a33034bd786cb123be1852c7b73..187828d1dd364f3299456b2c64c3b553d5024107 100644 (file)
@@ -193,7 +193,7 @@ class NativeStorageServer:
         self._trigger_cb = None
 
     def __repr__(self):
-        return "<NativeStorageServer for %s>" % self.name()
+        return "<NativeStorageServer for %s>" % 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
index 42a90dd5db18f7c6c5c70b45d5754ada3a4f90c5..535cac1f187e21b5ef0c4ba396fd86137f055a3d 100644 (file)
@@ -122,16 +122,16 @@ class NoNetworkServer:
         self.serverid = serverid
         self.rref = rref
     def __repr__(self):
-        return "<NoNetworkServer for %s>" % self.name()
+        return "<NoNetworkServer for %s>" % 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"
index f6154cb500371ce697f83216a181b4ed0d017d24..e5357085224fab998f861bdf3a394264d5424857 100644 (file)
@@ -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)
index 94a88e918c269bdbd80b40713ae4b6dcdfc63d73..beb626982542217efbbb4121d73c041b7998183a 100644 (file)
@@ -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
index 79857667a9a41a0c3fcc3a2d7c70f78664541c8e..82c0a779cb2cfd755bac3880de59722fc90466d5 100644 (file)
@@ -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)
index 9d19894f66f9a631c8dfc6c2900aeadd02edd9cd..1bef583284d54c2bf35e7cd3e6d1b07c9581b247 100644 (file)
@@ -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: