From 81f75c8c4572556e7ac789bad08fcb06a55e6339 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Thu, 24 Sep 2015 18:20:18 +0200 Subject: Fix backup-quorum-size and use it. --- test/catlfish-test.cfg | 2 ++ tools/merge_sth.py | 13 ++++++++++--- 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", \ -- cgit v1.1