def main(): global incoming, incoming_lock, N, pid, port, root_port, send # Read global state. pid = int(sys.argv[1]) N = int(sys.argv[2]) port = int(sys.argv[3]) # Start and configure debugger LOG.basicConfig(filename='LOG/%d.log' % pid, level=LOG.DEBUG) # Create the necessary classes. mhandler = MasterHandler(pid, address, port) handler = WorkerThread(address, root_port + pid) communicator = Communicator(incoming, incoming_lock, pid, send, mhandler) #LOG.debug('Handlers initiated') acceptors = [(i, 'acceptor') for i in xrange(N)] leaders = [(i, 'leader') for i in xrange(N)] replicas = [(i, 'replica') for i in xrange(N)] acceptor = Acceptor(communicator) my_dict = dict() replica = Replica(leaders, my_dict, communicator) leader = Leader(acceptors, replicas, communicator) acceptor.start() handler.start() mhandler.start() while not os.path.isfile('LOG/%d.log' % (N - 1)): time.sleep(0.1) leader.start() replica.start() LOG.debug('main() ends IDENTITY pid: %d, port: %d ' % (pid, port))
import sys from replica import Replica replica = Replica(sys.argv[1], sys.argv[2]) replica.start()