#pragma once #include "config.h" #include #include #include #include #if USE_AWS_S3 #include #include #endif namespace DB { #if USE_AWS_S3 class KeeperSnapshotManagerS3 { public: KeeperSnapshotManagerS3(); /// 'macros' are used to substitute macros in endpoint of disks void updateS3Configuration(const Poco::Util::AbstractConfiguration & config, const MultiVersion::Version & macros); void uploadSnapshot(const SnapshotFileInfoPtr & file_info, bool async_upload = true); /// 'macros' are used to substitute macros in endpoint of disks void startup(const Poco::Util::AbstractConfiguration & config, const MultiVersion::Version & macros); void shutdown(); private: using SnapshotS3Queue = ConcurrentBoundedQueue; SnapshotS3Queue snapshots_s3_queue; /// Upload new snapshots to S3 ThreadFromGlobalPool snapshot_s3_thread; struct S3Configuration; mutable std::mutex snapshot_s3_client_mutex; std::shared_ptr snapshot_s3_client; std::atomic shutdown_called{false}; LoggerPtr log; UUID uuid; std::shared_ptr getSnapshotS3Client() const; void uploadSnapshotImpl(const SnapshotFileInfo & snapshot_file_info); /// Thread upload snapshots to S3 in the background void snapshotS3Thread(); }; #else class KeeperSnapshotManagerS3 { public: KeeperSnapshotManagerS3() = default; void updateS3Configuration(const Poco::Util::AbstractConfiguration &, const MultiVersion::Version &) {} void uploadSnapshot(const SnapshotFileInfoPtr &, [[maybe_unused]] bool async_upload = true) {} void startup(const Poco::Util::AbstractConfiguration &, const MultiVersion::Version &) {} void shutdown() {} }; #endif }