Skip to content

Commit 5d2ac17

Browse files
committed
Running HeartBeat & Replication...Yayyyyygit status
1 parent f6fc2b3 commit 5d2ac17

23 files changed

+826
-7
lines changed
675 Bytes
Binary file not shown.
2.28 KB
Binary file not shown.
1.09 KB
Binary file not shown.
677 Bytes
Binary file not shown.
Binary file not shown.
1.09 KB
Binary file not shown.

Test Code/Storage-1/storage_replication.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import socket
22
import pickle
33
import os
4-
from transfer import _send_msg, _recv_msg
4+
from transfer import _send_msg, _recv_msg, _wait_recv_msg
55
from info import mds_ip, monitor_ip, storage_ip, num_objects_per_file, max_num_objects_per_pg, MSG_SIZE, HEADERSIZE
66

77

@@ -39,7 +39,8 @@ def replicate_pg(soc):
3939
print(f"Socket created to send request to SAVE data at OSD {osd_id}")
4040

4141
ip_add = storage_ip[osd_id]["ip"]
42-
port = storage_ip[osd_id]["port"]
42+
port = storage_ip[osd_id]["port"] + 10
43+
# Remember replication is on normal port + 10
4344

4445
try :
4546
new_soc.connect((ip_add, port))
@@ -72,13 +73,18 @@ def replicate_pg(soc):
7273
pg_id = msg["pg_id"]
7374
pg = msg["pg"]
7475

75-
file = open("./data/"+ pg_id, 'wb')
76+
try :
77+
file = open("./data/"+ pg_id, 'wb')
78+
print("Replicated data is saved")
7679

77-
pg_dump = pickle.dump(pg)
78-
file.write(pg_dump)
80+
pg_dump = pickle.dump(pg)
81+
file.write(pg_dump)
82+
83+
except Exception as e:
84+
print(e)
7985

8086
msg = {"type":"ACK"}
81-
_send_msg(msg)
87+
_send_msg(c, msg)
8288
print("Write successful..send back Ack to the master osd")
8389

8490

@@ -87,5 +93,5 @@ def replicate_pg(soc):
8793

8894
c.close()
8995

90-
print(f"Exiting from pid os.getpid() ..")
96+
print(f"Exiting from pid {os.getpid()} ..")
9197
os._exit(1)
677 Bytes
Binary file not shown.
Binary file not shown.
1.09 KB
Binary file not shown.

0 commit comments

Comments
 (0)