def put(self, key, value): """ 1. Get the highest Rendezvous node for the given key. 2. Retrieve the DBClient instance reference by the node. 3. Save the value into DB via client's put(). :param key: a string key. :param value: a string key-value pair dictionary to be stored in DB. :return a PutResponse - [email protected] NOTE: Both key and value must be the string type. """ # TODO highest_node = self.get_node(key) server_channel = self.maps[str(highest_node)] stub = db_pb2.DBStub(channel=server_channel) _data = db_pb2.Data(entry=value) req = db_pb2.PutRequest(id=key, data=_data) return stub.put(req)
def put(self, key, dataMap): _data = db_pb2.Data(entry=dataMap) req = db_pb2.PutRequest(id=key, data=_data) return self.stub.put(req)
def put(self, kv): _data = db_pb2.Data(entry=kv) req = db_pb2.PutRequest(data=_data) return self.stub.put(req)