#pragma once #include #include namespace DB { class ObjectStorageQueueMetadataFactory final : private boost::noncopyable { public: using FilesMetadataPtr = std::shared_ptr; static ObjectStorageQueueMetadataFactory & instance(); FilesMetadataPtr getOrCreate( const std::string & zookeeper_path, ObjectStorageQueueMetadataPtr metadata); void remove(const std::string & zookeeper_path); std::unordered_map getAll(); private: struct Metadata { explicit Metadata(std::shared_ptr metadata_) : metadata(metadata_), ref_count(1) {} std::shared_ptr metadata; /// TODO: the ref count should be kept in keeper, because of the case with distributed processing. size_t ref_count = 0; }; using MetadataByPath = std::unordered_map; MetadataByPath metadata_by_path; std::mutex mutex; }; }