diff --git a/kafka_server/broker/file/indexer.py b/kafka_server/broker/file/indexer.py index 9147b36..69dcaaa 100644 --- a/kafka_server/broker/file/indexer.py +++ b/kafka_server/broker/file/indexer.py @@ -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')