Skip to content

Commit

Permalink
log.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoseinaghaei committed Feb 15, 2024
1 parent 19e2ca0 commit 6f98d04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kafka_server/broker/file/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def get_write(self):
def inc_read(self):
with self._read_lock:
self._read += 1
print("save read index\n\n")
self._save_variable(self._read, 'read')
print("send read index\n\n")
self.send_to_replica()

def get_read(self):
Expand Down Expand Up @@ -102,11 +104,13 @@ def __dir_path(self) -> str:
)

def send_to_replica(self):
print("sending to replica started!!!\n\n\n\n")
if self.replica is None:
print("No replica found /n/n/n")
return

url = f'{self.replica}/replica/index'
data = {'partition': self.partition, 'read': self._read, 'sync': self._sync}
response = requests.post(url, json=data, timeout=2)
response = requests.post(url, json=data)
if response.status_code != 200:
raise Exception(f'indexed not yet updated {response}')
1 change: 1 addition & 0 deletions kafka_server/broker/file/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def approve_appending(self):
def approve_reading(self):
try:
with self._read_lock:
print("approve_reading \n\n")
self.indexer.inc_read()
except Exception as e:
print(f"Error inc read index: {e}")
Expand Down

0 comments on commit 6f98d04

Please sign in to comment.