logging.debug("acks received so far = %d" % (acks_received,)) if acks_received == K: logging.debug("%d acks received." % (K,)) lock_acquired = True lock_acquired_event.set() else: # Ignore pass msg = mp.receive() time.sleep(0.5) # Sleep for half-a-second if __name__ == '__main__': if len(sys.argv) == 3: config_filename = sys.argv[1] local_name = sys.argv[2] mp = MessagePasser(config_filename, local_name) mp.update_config() # Update K K = len(mp.mcast_group['members']) # Initialize the clock service here # Should be done AFTER update_config() on MessagePasser cs_factory = ClockServiceFactory() cs_factory.set_nodes(len(mp.nodes)) # No. of nodes in the system cs_factory.set_host_node_id(mp.nid) # ID for *this* process # Uncomment for Vector Clock cs = cs_factory.get_clock("VECTOR") # Inject Clock Service into MessagePasser mp.set_clockservice(cs)
import sys import threading from messagepasser import MessagePasser from message import TimeStampedMessage import ClockServiceFactory logger_messages = [] if __name__ == '__main__': if len(sys.argv) == 3: config_filename = sys.argv[1] local_name = sys.argv[2] mp = MessagePasser(config_filename, local_name) mp.update_config() # Initialize the clock service here # Should be done AFTER update_config() on MessagePasser cs_factory = ClockServiceFactory() cs_factory.set_nodes(len(mp.nodes)) # No. of nodes in the system cs_factory.set_host_node_id(mp.nid) # ID for *this* process # Logical Clock # cs = cs_factory.get_clock("LOGICAL") # Uncomment for Vector Clock cs = cs_factory.get_clock("VECTOR") # Inject Clock Service into MessagePasser mp.set_clockservice(cs) # Start server thread listening to messages listen_thread = threading.Thread(name="listen_thread", target=mp.receive_message)
import sys import threading from messagepasser import MessagePasser from message import Message, TimeStampedMessage from clockservice import ClockServiceFactory if __name__ == "__main__": if len(sys.argv) == 3: config_filename = sys.argv[1] local_name = sys.argv[2] mp = MessagePasser(config_filename, local_name) mp.update_config() # Initialize the clock service here # Should be done AFTER update_config() on MessagePasser cs_factory = ClockServiceFactory() cs_factory.set_nodes(len(mp.nodes)) # No. of nodes in the system cs_factory.set_host_node_id(mp.nid) # ID for *this* process # Logical Clock cs = cs_factory.get_clock("LOGICAL") # Uncomment for Vector Clock # cs = cs_factory.get_clock("VECTOR") # Inject Clock Service into MessagePasser mp.set_clockservice(cs) # Start server thread listening to messages listen_thread = threading.Thread(name="listen_thread", target=mp.receive_message) listen_thread.start()