]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Yank homeless shares setup into a separate method. ticket1382
authorKevan <kevan@isnotajoke.com>
Mon, 16 Jan 2012 18:38:29 +0000 (10:38 -0800)
committerDaira Hopwood <david-sarah@jacaranda.org>
Thu, 25 Apr 2013 16:49:30 +0000 (17:49 +0100)
src/allmydata/immutable/upload.py

index 434aad5415b2ae6caea7ead7d67121521f0f5464..cbb4ff9ba43b9b0580ad31bff2522d3fc7e8084f 100644 (file)
@@ -238,11 +238,6 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin):
         self.servers_of_happiness = servers_of_happiness
         self.needed_shares = needed_shares
 
-        self.homeless_shares = set(range(total_shares))
-        self.use_trackers = set() # ServerTrackers that have shares assigned
-                                  # to them
-        self.preexisting_shares = {} # shareid => set(serverids) holding shareid
-
         # These servers have shares -- any shares -- for our SI. We keep
         # track of these to write an error message with them later.
         self.serverids_with_shares = set()
@@ -298,21 +293,8 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin):
                 trackers.append(st)
             return trackers
 
-        # We assign each servers/trackers into one three lists. They all
-        # start in the "first pass" list. During the first pass, as we ask
-        # each one to hold a share, we move their tracker to the "second
-        # pass" list, until the first-pass list is empty. Then during the
-        # second pass, as we ask each to hold more shares, we move their
-        # tracker to the "next pass" list, until the second-pass list is
-        # empty. Then we move everybody from the next-pass list back to the
-        # second-pass list and repeat the "second" pass (really the third,
-        # fourth, etc pass), until all shares are assigned, or we've run out
-        # of potential servers.
-        self.first_pass_trackers = _make_trackers(writeable_servers)
-        self.second_pass_trackers = [] # servers worth asking again
-        self.next_pass_trackers = [] # servers that we have asked again
-        self._started_second_pass = False
-
+        self._setup_server_tracking()
+        self._record_writeable_servers(_make_trackers(writeable_servers))
         # We don't try to allocate shares to these servers, since they've
         # said that they're incapable of storing shares of the size that we'd
         # want to store. We ask them about existing shares for this storage
@@ -335,6 +317,31 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin):
         dl.addCallback(lambda ign: self._loop())
         return dl
 
+    def _setup_server_tracking(self):
+        self.homeless_shares = set(range(self.total_shares))
+        self.use_trackers = set() # ServerTrackers that have shares assigned
+                                  # to them
+        self.preexisting_shares = {} # shareid => set(serverids) holding shareid
+
+        # We assign each servers/trackers into one three lists. They all
+        # start in the "first pass" list. During the first pass, as we ask
+        # each one to hold a share, we move their tracker to the "second
+        # pass" list, until the first-pass list is empty. Then during the
+        # second pass, as we ask each to hold more shares, we move their
+        # tracker to the "next pass" list, until the second-pass list is
+        # empty. Then we move everybody from the next-pass list back to the
+        # second-pass list and repeat the "second" pass (really the third,
+        # fourth, etc pass), until all shares are assigned, or we've run out
+        # of potential servers.
+        self.first_pass_trackers = [] # servers that we haven't asked yet
+        self.second_pass_trackers = [] # servers worth asking again
+        self.next_pass_trackers = [] # servers that we have asked again
+        self._started_second_pass = False
+
+
+    def _record_writeable_servers(self, trackers):
+        self.first_pass_trackers = trackers
+
 
     def _do_inquiry(self, tracker):
         """