Ejemplo n.º 1
0
def run(Addr):
    start = time.time()

    # TODO: Implement PUT and GET
    myKey = "1" * 1024
    myValue = "1" * 1024
    start = time.time()
    seq_num = 1

    for _ in range(100):
        try:
            while True:
                channel = grpc.insecure_channel(Addr)
                stub = server_pb2_grpc.ServerStub(channel)
                # print("Try to put")
                stub.put(server_pb2.PutRequest(key=myKey, value=myValue))
        except Exception as e:
            print(e)
        seq_num += 1

    print(time.time() - start)

    start = time.time()
    try:
        while True:
            channel = grpc.insecure_channel(Addr)
            stub = server_pb2_grpc.ServerStub(channel)
            print("Try to get")
            stub.get(server_pb2.GetRequest(key=myKey))
    except Exception as e:
        print(e)
    print(time.time() - start)
Ejemplo n.º 2
0
 def GetFromLocalCluster(self, from_timestamp, to_timestamp):
     req = server_pb2.Request(fromSender=self.host,
                              getRequest=server_pb2.GetRequest(
                                  metaData=server_pb2.MetaData(uuid=''),
                                  queryParams=server_pb2.QueryParams(
                                      from_utc=from_timestamp,
                                      to_utc=to_timestamp)))
     for stream in self.stub.GetFromLocalCluster(req):
         yield (stream)
Ejemplo n.º 3
0
 def getHandler(self, from_timestamp, to_timestamp):
     req = server_pb2.Request(
         fromSender='prof',
         toReceiver='some put receiver',
     getRequest=server_pb2.GetRequest(
       metaData=server_pb2.MetaData(uuid='14829'),
       queryParams=server_pb2.QueryParams(from_utc=from_timestamp,to_utc=to_timestamp))
     )
     for stream in self.stub.getHandler(req):
         yield(stream)
Ejemplo n.º 4
0
 def GetFromLocalCluster(self, from_timestamp, to_timestamp):
     req = server_pb2.Request(
         fromSender='some put sender',
         toReceiver='some put receiver',
     getRequest=server_pb2.GetRequest(
       metaData=server_pb2.MetaData(uuid='14829'),
       queryParams=server_pb2.QueryParams(from_utc=from_timestamp,to_utc=to_timestamp))
     )
     print("Client GetFromLocalCluster",req)
     for stream in self.stub.GetFromLocalCluster(req):
         yield(stream)
Ejemplo n.º 5
0
 def getHandler(self, from_timestamp, to_timestamp):
     #cache_key = str(from_timestamp).replace(" ","") + str(to_timestamp).replace(" ","")
     #if 10>11:
     #print("in cache"+cache_key)
     #value = mc.get(cache_key)
     #yield value.datFragment
     #else:
     req = server_pb2.Request(fromSender=self.host,
                              getRequest=server_pb2.GetRequest(
                                  metaData=server_pb2.MetaData(uuid=''),
                                  queryParams=server_pb2.QueryParams(
                                      from_utc=from_timestamp,
                                      to_utc=to_timestamp)))
     for stream in self.stub.getHandler(req):
         #mc.set(cache_key,stream)
         yield (stream)