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)
def create_streaming_request_for_local_put(self, data): req = server_pb2.Request( fromSender=self.host, putRequest=server_pb2.PutRequest( metaData=server_pb2.MetaData(uuid=''), datFragment=server_pb2.DatFragment(data=str(data).encode( encoding='utf_8')))) yield req
def create_streaming_request(self,putData): req = server_pb2.Request( fromSender='some put sender', toReceiver='some put receiver', putRequest=server_pb2.PutRequest( metaData=server_pb2.MetaData(uuid='14829'), datFragment=server_pb2.DatFragment(data= str(putData).encode(encoding='utf_8')) )) yield req
def create_streaming_request(self, file): for x in chunktest.process(None, request=False, name=file): req = server_pb2.Request( fromSender=self.host, putRequest=server_pb2.PutRequest( metaData=server_pb2.MetaData(uuid=''), datFragment=server_pb2.DatFragment( data=str("".join(x)).encode(encoding='utf_8')))) yield req