Beispiel #1
0
 def connect(self):
     '''
     '''
     resp = self.stub.startReplication(datastore_pb2.Request())
     for data in resp:
         print(data.key, data.value)
         self.db.put(data.key, data.value)
Beispiel #2
0
 def replicator_put(self, requests, context):
     for request in requests:
         print("put (streaming): " + request.data)
         key = uuid.uuid4().hex
         self.db.put(bytes(key, encoding="UTF-8"), bytes(request.data, encoding="UTF-8"))
         master_already_stored_requests.append(datastore_pb2.Request(data=bytes(key, encoding="UTF-8")))
         yield datastore_pb2.Response(data=key)
Beispiel #3
0
 def replicator(self):
     responses = self.stub.replicator(datastore_pb2.Request())
     i = 0
     for response in responses:
         print("{%s : %s} has been stored in the follower's DB." % (response.data, current_values[i]))
         self.db.put(bytes(response.data, encoding="UTF-8"), bytes(current_values[i], encoding="UTF-8"))
         i += 1
     current_values.clear();
Beispiel #4
0
 def put(self, bid, uname, phno, cindate, days, rtype, price, rno, oprtyp):
     return self.stub.put(
         datastore_pb2.Request(bookingid=bid,
                               username=uname,
                               phoneno=phno,
                               checkindate=cindate,
                               noofdays=days,
                               roomtype=rtype,
                               price=price,
                               roomno=rno,
                               oprtype=oprtyp))
Beispiel #5
0
def make_data(key, data):
    return datastore_pb2.Request(key=key, data=data)
 def put(self, key, value):
     return self.stub.put(datastore_pb2.Request(key=key, value=value))
Beispiel #7
0
 def Register(self):
     '''
     Client connects to the server indefinitely through this method
     '''
     return self.stub.Register(datastore_pb2.Request(key=1))
Beispiel #8
0
 def get(self, key):
     return self.stub.get(datastore_pb2.Request(data=key))
Beispiel #9
0
 def put(self, value):
     return self.stub.put(datastore_pb2.Request(data=value))
Beispiel #10
0
 def delete(self, key):
     return self.stub.delete(datastore_pb2.Request(data=key))
Beispiel #11
0
def create_request(value):
    return datastore_pb2.Request(data=value);
Beispiel #12
0
 def get(self, k):
     return self.stub.get(datastore_pb2.Request(k=k,val=val))
Beispiel #13
0
 def put(self, k, val):
     return self.stub.put(datastore_pb2.Request(k=k,val=val))
Beispiel #14
0
 def test(self, operation, key, value):
     print("key : " + key)
     return self.stub.update(
         datastore_pb2.Request(operation=operation, key=key, value=value))
Beispiel #15
0
 def masterUpdate(self):
     return self.stub.masterUpdate(datastore_pb2.Request()) 
 def put(self, key, data):
     return self.stub.put(datastore_pb2.Request(key=key, data=data))