print -> log
This commit is contained in:
1 parent
6822da6e34
commit
3b5e358cf3
1 file changed
+9
-9
+9
-9
@@ -493,9 +493,9 @@ def worker_5():
|
|||||||
if cmd_0 == "list_mem":
|
if cmd_0 == "list_mem":
|
||||||
cmd_list_mem()
|
cmd_list_mem()
|
||||||
elif cmd_0 == "list_self":
|
elif cmd_0 == "list_self":
|
||||||
print(str(MY_ID))
|
log(str(MY_ID))
|
||||||
elif cmd_0 == "join":
|
elif cmd_0 == "join":
|
||||||
print("auto joins at start up")
|
log("auto joins at start up")
|
||||||
elif cmd_0 == "leave":
|
elif cmd_0 == "leave":
|
||||||
log("Leaving")
|
log("Leaving")
|
||||||
stop_threads.set()
|
stop_threads.set()
|
||||||
@@ -505,15 +505,15 @@ def worker_5():
|
|||||||
if len(cmd) >= 2:
|
if len(cmd) >= 2:
|
||||||
global_switcher("switch", cmd[1])
|
global_switcher("switch", cmd[1])
|
||||||
else:
|
else:
|
||||||
print("Usage: switch suspect|nosuspect")
|
log("Usage: switch suspect|nosuspect")
|
||||||
elif cmd_0 == "display_protocol":
|
elif cmd_0 == "display_protocol":
|
||||||
with cluster_state_lock:
|
with cluster_state_lock:
|
||||||
print(f"Mode: {cluster_state['mode']}, drop rate: {cluster_state['drop_rate']}")
|
log(f"Mode: {cluster_state['mode']}, drop rate: {cluster_state['drop_rate']}")
|
||||||
elif cmd_0 == "set_drop_rate":
|
elif cmd_0 == "set_drop_rate":
|
||||||
if len(cmd) >= 2:
|
if len(cmd) >= 2:
|
||||||
global_switcher("drop_rate", cmd[1])
|
global_switcher("drop_rate", cmd[1])
|
||||||
else:
|
else:
|
||||||
print("Usage: set_drop_rate <number>")
|
log("Usage: set_drop_rate <number>")
|
||||||
else:
|
else:
|
||||||
log(f"Unknown command: {cmd_0}")
|
log(f"Unknown command: {cmd_0}")
|
||||||
|
|
||||||
@@ -523,16 +523,16 @@ def cmd_list_mem():
|
|||||||
for member_id, member_data in members_list.items():
|
for member_id, member_data in members_list.items():
|
||||||
if member_data["state"] == "failed":
|
if member_data["state"] == "failed":
|
||||||
continue
|
continue
|
||||||
print(f"{member_id} state = {member_data['state']}, heartbeat = {member_data['heart_beat']}, incarnation = {member_data['incarnation_counter']}")
|
log(f"{member_id} state = {member_data['state']}, heartbeat = {member_data['heart_beat']}, incarnation = {member_data['incarnation_counter']}")
|
||||||
|
|
||||||
def cmd_display_suspects():
|
def cmd_display_suspects():
|
||||||
with suspect_history_lock:
|
with suspect_history_lock:
|
||||||
if not suspect_history:
|
if not suspect_history:
|
||||||
print("No suspects recorded.")
|
log("No suspects recorded.")
|
||||||
else:
|
else:
|
||||||
print("Suspect history:")
|
log("Suspect history:")
|
||||||
for member_id, timestamp in suspect_history:
|
for member_id, timestamp in suspect_history:
|
||||||
print(f"{member_id} suspected at {timestamp}")
|
log(f"{member_id} suspected at {timestamp}")
|
||||||
|
|
||||||
|
|
||||||
# THREAD 6 - Display membership list in a pretty format
|
# THREAD 6 - Display membership list in a pretty format
|
||||||
|
|||||||
Reference in new issue
Block a user