-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-dn_read.py
41 lines (37 loc) · 1.06 KB
/
test-dn_read.py
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
36
37
38
39
40
41
##################################
# This file tests data node rpc
###############################
import namenode_pb2
import json
from grpc.beta import implementations
import hashlib
import datanode_pb2
import sys
def main():
if len(sys.argv) ==1:
print("Please pass the proper parameters, include port number")
exit()
port = sys.argv[1]
print("Testing datanode...")
#port = 5000
ip = "127.0.0.1"
channel = implementations.insecure_channel(str(ip),int(port))
stub = datanode_pb2.beta_create_DataNode_stub(channel)
pfn = "./test.txt"
file_size = 1337
ts = "123121234"
f = open(pfn, 'r')
d = f.read()
f.close()
print(d)
req =datanode_pb2.ReadRequest(blockname=pfn,timestamp=ts)
response = stub.Read(req,10)
#req =namenode_pb2.StoreRequest(file_path=pfn,file_size=file_size,timestamp=ts)
#response = stub.Store(req,10)
if __name__ == '__main__':
try:
main()
print("Test is successful!")
except Exception as err:
print(err)
print("Test failed")