def main():
with open(sys.argv[1]) as configuration_file:
configuration = json.load(configuration_file)
if len(sys.argv) == 3:
test_daemon_client = xmlrpclib.ServerProxy("http://{}".format(sys.argv[2]))
callback = partial(onUpdateFunction, test_daemon_client)
else:
callback = partial(noop)
class ReplicatedValue(ExponentialBackoffResolutionStrategyMixin, SimpleSynchronizationStrategyMixin,
BaseReplicatedValue):
'''
Mixes just the resolution and synchronization strategies into the base class
'''
id = configuration["host"]["id"]
state_file = "./paxos_state_{}.json".format(id)
peers = {peer["id"]: (peer["address"], peer["port"]) for peer in configuration["peers"]}
peers[id] = (configuration["host"]["address"], configuration["host"]["port"])
r = ReplicatedValue(id, peers.keys(), state_file, callback)
m = Messenger(id, peers, r)
if len(sys.argv) == 3:
listener = TestDaemonListener(m)
reactor.run()
评论列表
文章目录