This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
> | |
<RadioGroup | |
android:id="@+id/radio_group" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<include android:id="@+id/appetite_decrease_severity_response" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
layout="@layout/severity_question"/> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
else: | |
if self.leader: | |
self.current_operation = string_operation | |
if self.current_operation.split(" ")[0] in ["set", "delete"]: | |
key_value_store.write_to_log(string_operation, term_absent=True) | |
broadcast(self, with_return_address(self, "append_entries ['" + self.current_operation + "']")) | |
while not self.current_operation_committed: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Server: | |
... | |
self.followers_with_update_status = {} | |
self.current_operation = '' | |
self.current_operation_committed = False | |
for server_name in other_server_names(name): | |
self.followers_with_update_status[server_name] = False | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
if string_operation.split(" ")[0] == "append_entries": | |
# followers do this to update their logs. | |
stringified_logs_to_append = string_operation.replace("append_entries ", "") | |
print("Preparing to append: " + stringified_logs_to_append) | |
logs_to_append = ast.literal_eval(stringified_logs_to_append) | |
[key_value_store.write_to_log(log, term_absent=True) for log in logs_to_append] | |
print("State machine after appending: " + str(key_value_store.data)) | |
response = "Append entries call successful!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
elif string_operation.split(" ")[0] == "commit_entries": | |
# followers do this to update their logs. | |
stringified_logs_to_append = string_operation.replace("commit_entries ", "") | |
print("Preparing to commit: " + stringified_logs_to_append) | |
logs_to_append = ast.literal_eval(stringified_logs_to_append) | |
[key_value_store.write_to_state_machine(command, term_absent=True) for command in logs_to_append] | |
response = "Commit entries call successful!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
elif string_operation == "Append entries call successful!": | |
if self.leader: | |
self.mark_updated(server_name) | |
send_pending = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
else: #if the request is to get, set, or delete | |
if self.leader: | |
self.current_operation = string_operation | |
key_value_store.write_to_log(string_operation, term_absent=True) | |
if self.current_operation.split(" ")[0] in ["set", "delete"]: | |
broadcast(self, with_return_address(self, "append_entries [" + self.current_operation + "]")) | |
send_pending = False |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.