summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2015-09-24 18:20:18 +0200
committerLinus Nordberg <linus@nordu.net>2015-09-27 13:38:30 +0200
commit81f75c8c4572556e7ac789bad08fcb06a55e6339 (patch)
tree1488462211581632105ecda5d3e927e479212120
parent1f997c076b6d0ed66e6817935d29920e0cac0af3 (diff)
Fix backup-quorum-size and use it.
-rw-r--r--test/catlfish-test.cfg2
-rwxr-xr-xtools/merge_sth.py13
2 files changed, 12 insertions, 3 deletions
diff --git a/test/catlfish-test.cfg b/test/catlfish-test.cfg
index 77539b6..39288c7 100644
--- a/test/catlfish-test.cfg
+++ b/test/catlfish-test.cfg
@@ -21,6 +21,8 @@ mergenodes:
primarymergenode: merge-1
+backup-quorum-size: 1
+
storage-quorum-size: 1
mmd: 86400
diff --git a/tools/merge_sth.py b/tools/merge_sth.py
index 68b52a0..bd49c9f 100755
--- a/tools/merge_sth.py
+++ b/tools/merge_sth.py
@@ -8,7 +8,7 @@ import sys
import json
import urllib2
import time
-from base64 import b64encode, b64decode
+from base64 import b64encode
from mergetools import parse_args, get_nfetched, hexencode, hexdecode, \
get_logorder, get_sth
from certtools import create_ssl_context, get_public_key_from_file, \
@@ -26,13 +26,15 @@ def merge_sth(args, config, localconfig):
mergedb = paths["mergedb"]
sthfile = mergedb + "/sth"
logorderfile = mergedb + "/logorder"
+ currentsizefile = mergedb + "/fetched"
logpublickey = get_public_key_from_file(paths["logpublickey"])
- backupquorum = localconfig.get("backupquorum", 0)
+ backupquorum = config.get("backup-quorum-size", 0)
assert backupquorum <= len(mergenodes) - 1
create_ssl_context(cafile=paths["https_cacertfile"])
timing = timing_point()
- trees = [{'tree_size': 0, 'sha256_root_hash': ''}]
+ trees = [{'tree_size': get_nfetched(currentsizefile, logorderfile),
+ 'sha256_root_hash': ''}]
for mergenode in mergenodes:
if mergenode["name"] == config["primarymergenode"]:
continue
@@ -44,6 +46,11 @@ def merge_sth(args, config, localconfig):
trees.append(tree)
trees.sort(key=lambda e: e['tree_size'], reverse=True)
print >>sys.stderr, "DEBUG: trees:", trees
+
+ if backupquorum > len(trees) - 1:
+ print >>sys.stderr, "backup quorum > number of secondaries:", \
+ backupquorum, ">", len(trees) - 1
+ return
tree_size = trees[backupquorum]['tree_size']
root_hash = hexdecode(trees[backupquorum]['sha256_root_hash'])
print >>sys.stderr, "DEBUG: tree size candidate at backupquorum", \