Skip to content

Commit

Permalink
Cleanups and test-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Apr 25, 2017
1 parent 9a9a105 commit 30d68fb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
4 changes: 0 additions & 4 deletions docs/specifications/servers-of-happiness.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ We calculate share placement like so:
shares, where an edge exists between an arbitrary readonly server S and an
arbitrary share T if and only if S currently holds T.

^--- all passed in to the Happiness_Upload ctor

3. Calculate a maximum matching graph of G1 (a set of S->T edges that has or
is-tied-for the highest "happiness score"). There is a clever efficient
algorithm for this, named "Ford-Fulkerson". There may be more than one
Expand All @@ -130,8 +128,6 @@ We calculate share placement like so:
maps shares to servers, where each share appears at most once, and each
server appears at most once.

^-- is this the "readonly_mappings"

4. Construct a bipartite graph G2 of readwrite servers to pre-existing
shares. Then remove any edge (from G2) that uses a server or a share found
in M1. Let an edge exist between server S and share T if and only if S
Expand Down
16 changes: 10 additions & 6 deletions src/allmydata/immutable/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,16 @@ def _err(f):

def _check_server_shares(self, s):
"""Return a deferred which eventually fires with a tuple of
(set(sharenum), server, set(), set(), responded) showing all the
shares claimed to be served by this server. In case the server is
disconnected then it fires with (set(), server, set(), set(), False)
(a server disconnecting when we ask it for buckets is the same, for
our purposes, as a server that says it has none, except that we want
to track and report whether or not each server responded.)"""
(set(sharenum), server, set(corrupt), set(incompatible),
responded) showing all the shares claimed to be served by this
server. In case the server is disconnected then it fires with
(set(), server, set(), set(), False) (a server disconnecting
when we ask it for buckets is the same, for our purposes, as a
server that says it has none, except that we want to track and
report whether or not each server responded.)
see also _verify_server_shares()
"""
def _curry_empty_corrupted(res):
buckets, responded = res
return (set(buckets), s, set(), set(), responded)
Expand Down
7 changes: 0 additions & 7 deletions src/allmydata/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,13 +797,6 @@ def is_healthy():
reflect a healthy file, based on my internal definitions.
"""

def needs_recomputation():
"""
I return True if the share assignments I last returned may have
become stale. This is a hint to the caller that they should call
get_share_assignments again.
"""


class IWriteable(Interface):
"""
Expand Down
19 changes: 11 additions & 8 deletions src/allmydata/test/test_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def _pretty_shares_chart(self, uri):
shares_chart.setdefault(shnum, []).append(names[serverid])
return shares_chart

def _test_good_share_hosts(self):
def test_good_share_hosts(self):
self.basedir = "checker/BalancingAct/1115"
self.set_up_grid(num_servers=1)
c0 = self.g.clients[0]
Expand Down Expand Up @@ -388,11 +388,9 @@ def add_three(_, i):
d.addCallback(add_three, i)

def _check_and_repair(_):
print("check_and_repair")
return self.imm.check_and_repair(Monitor())
def _check_counts(crr, shares_good, good_share_hosts):
prr = crr.get_post_repair_results()
print self._pretty_shares_chart(self.uri)
self.failUnlessEqual(prr.get_share_counter_good(), shares_good)
self.failUnlessEqual(prr.get_host_counter_good_shares(),
good_share_hosts)
Expand All @@ -410,11 +408,16 @@ def _check_counts(crr, shares_good, good_share_hosts):
d.addCallback(_check_counts, 4, 5)
d.addCallback(lambda _: self.delete_shares_numbered(self.uri, [3]))
d.addCallback(_check_and_repair)
# XXX this isn't always true, "sometimes" the repairer happens
# to do better and place things so there are 5 happy
# servers. for example PYTHONHASHSEED=3 gets 5 happy whereas
# PYTHONHASHSEED=4 gets 4 happy
d.addCallback(_check_counts, 4, 4)

# it can happen that our uploader will choose, e.g., to upload
# to servers B, C, D, E .. which will mean that all 5 serves
# now contain our shares (and thus "respond").

def _check_happy(crr):
prr = crr.get_post_repair_results()
self.assertTrue(prr.get_host_counter_good_shares() >= 4)
return crr
d.addCallback(_check_happy)
d.addCallback(lambda _: all([self.g.break_server(sid)
for sid in self.g.get_all_serverids()]))
d.addCallback(_check_and_repair)
Expand Down

0 comments on commit 30d68fb

Please sign in to comment.