-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
35 lines (30 loc) · 1.01 KB
/
client.py
File metadata and controls
35 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Pyro4
import time
def main():
ns = Pyro4.locateNS()
uri1 = ns.lookup('replica1')
uri2 = ns.lookup('replica2')
replica1 = Pyro4.Proxy(uri1)
replica2 = Pyro4.Proxy(uri2)
# Write a value
print("Client: Sending 'write' request for key 'key1' to Replica1.")
replica1.write('key1', 'value1')
time.sleep(1)
print("Client: Sending 'write' request for key 'key2' to Replica2.")
replica2.write('key2', 'value2')
time.sleep(1)
# Read a value
print("Client: Sending 'read' request for key 'key2' to Replica1.")
print(replica1.read('key2'))
time.sleep(1)
print("Client: Sending 'read' request for key 'key1' to Replica2.")
print(replica2.read('key1'))
time.sleep(1)
# Delete a value
print("Client: Sending 'delete' request for key 'key1' to Replica1.")
replica1.delete('key1')
time.sleep(1)
print("Client: Sending 'read' request for key 'key1' to Replica2.")
print(replica2.read('key1'))
if __name__=="__main__":
main()