Esempio n. 1
0
 def rpc_init(self, name_and_port):
     (name, port) = name_and_port
     # Setup RPC connection
     self.transport = common.get_transport(name, port, framed=True)
     self.protocol = common.get_protocol(self.transport, "binary")
     return paxos.Paxos.Client(self.protocol)
Esempio n. 2
0
import sys
sys.path.append('../../py_common/')

import common
from protocol import Distributed

WINDOW_SIZE = 5

IP = sys.argv[1] if len(sys.argv) > 1 else 'localhost'
PORT = int(sys.argv[2]) if len(sys.argv) > 2 else 38003
NUM_REQUESTS = int(sys.argv[3]) if len(sys.argv) > 3 else 10000

transport = common.get_transport(IP, PORT, framed = True)
protocol = common.get_protocol(transport, 'binary')
client = Distributed.Client(protocol)

i = 0 
while i < NUM_REQUESTS:
    # send all requests in the window
    for w in xrange(0, WINDOW_SIZE):
        client.send_msg(str(i + w))

    # now block and process them
    for w in xrange(0, WINDOW_SIZE):
        resp = client.recv_msg()
        # make sure we got back what we sent in
        assert resp == str(i + w)

    i += WINDOW_SIZE

print "finished %d requests" % NUM_REQUESTS
Esempio n. 3
0
import sys

sys.path.append("../../py_common/")

import common
from protocol import Null


transport = common.get_transport("localhost", 38003, framed=True)
protocol = common.get_protocol(transport, "fast")
client = Null.Client(protocol)

WINDOW_SIZE = 1
NUM_REQUESTS = int(sys.argv[1])

i = 0
while i < NUM_REQUESTS:
    for w in xrange(0, WINDOW_SIZE):
        client.send_identity(i + w)
    for w in xrange(0, WINDOW_SIZE):
        n = client.recv_identity()
        assert n == (i + w)
    i += WINDOW_SIZE

# print "finished %d requests" % NUM_REQUESTS

# Big messages
# buf = ' ' * 60000
# for i in xrange(0, NUM_REQUESTS):
#     client.a(buf)