Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created July 26, 2020 03:27
Show Gist options
  • Save chelseatroy/6042bdd28f4cead0e801e3ef52f7550d to your computer and use it in GitHub Desktop.
Save chelseatroy/6042bdd28f4cead0e801e3ef52f7550d to your computer and use it in GitHub Desktop.
Marking Follower Servers Updated
...
def mark_updated(self, server_name):
self.followers_with_update_status[server_name] = True
trues = len(list(filter(lambda x: x is True, self.followers_with_update_status.values())))
falses = len(list(filter(lambda x: x is False, self.followers_with_update_status.values())))
if trues >= falses:
print("Committing entry: " + self.current_operation)
self.current_operation_committed = True
self.key_value_store.write_to_state_machine(self.current_operation, term_absent=True, write=False)
broadcast(self, with_return_address(self, "commit_entries ['" + self.current_operation + "']"))
self.current_operation_committed = False
for server_name in other_server_names(self.name):
self.followers_with_update_status[server_name] = False
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment