Skip to content

Commit

Permalink
fix none replica.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoseinaghaei committed Feb 15, 2024
1 parent d1ca202 commit 74646af
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions kafka_server/broker/file/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ class Indexer:

def __new__(cls, partition: str, replica: str = None):
with cls._lock:
if partition not in cls._instances:
cls._instances[partition] = super().__new__(cls)
cls._instances[partition].partition = partition
cls._instances[partition].replica = replica
cls._instances[partition].load()
path = cls._instances[partition].__dir_path()
if f"{partition}-{replica}" not in cls._instances:
cls._instances[f"{partition}-{replica}"] = super().__new__(cls)
cls._instances[f"{partition}-{replica}"].partition = partition
cls._instances[f"{partition}-{replica}"].replica = replica
cls._instances[f"{partition}-{replica}"].load()
path = cls._instances[f"{partition}-{replica}"].__dir_path()
os.makedirs(path, exist_ok=True)
return cls._instances[partition]

return cls._instances[f"{partition}-{replica}"]

def load(self):
self._write = self._load_variable('write')
Expand Down

0 comments on commit 74646af

Please sign in to comment.