import socket import pickle import time from paxos import Message s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) to = 'ec2-23-21-13-52.compute-1.amazonaws.com' for i in xrange(20): m = Message(Message.MSG_EXT_PROPOSE) m.value = i * 4 #m.value = operations[i] m.to = 'ec2-23-21-13-52.compute-1.amazonaws.com' bytes = pickle.dumps(m) #s.sendto('[%d] Hello server!' % i, (to, 8888)) #time.sleep(2) s.sendto(bytes, (m.to, 8888))
sender, status, op, txnID, opID = t else: pass table, column, key, value = None, None, None, None if op[:5] == 'write': __, table, column, key, value = op.split(',') elif op[:4] == 'read': __, table, column, key = op.split(',') sender = sender[2:] #print sender, status, op, '#', txnID m = Message(Message.MSG_EXT_PROPOSE) if group == 'x': m.to = 'ec2-23-21-13-52.compute-1.amazonaws.com' elif group == 'y': m.to = 'ec2-50-16-32-171.compute-1.amazonaws.com' m.value = {'sender': sender, 'status': status, 'op': op, 'txnID': txnID, 'opID': opID} bytes = pickle.dumps(m) client.sendto(bytes, (m.to, 8888)) #tpcSender.connect((d[sender], 7766)) while True: ack, __ = paxos_client.recvfrom(2048) m = pickle.loads(ack) if m.command == Message.MSG_CLIENT_ACK: