ClickHouse/src/Backups/BackupCoordinationRemote.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
3.6 KiB
C++
Raw Normal View History

2022-04-25 14:33:25 +00:00
#pragma once
#include <Backups/IBackupCoordination.h>
2022-07-06 09:09:31 +00:00
#include <Backups/BackupCoordinationReplicatedAccess.h>
#include <Backups/BackupCoordinationReplicatedTables.h>
#include <Backups/BackupCoordinationStageSync.h>
namespace DB
{
2022-07-06 09:09:31 +00:00
/// Implementation of the IBackupCoordination interface performing coordination via ZooKeeper. It's necessary for "BACKUP ON CLUSTER".
class BackupCoordinationRemote : public IBackupCoordination
{
public:
BackupCoordinationRemote(const String & zookeeper_path_, zkutil::GetZooKeeper get_zookeeper_, bool remove_zk_nodes_in_destructor_);
2022-07-06 09:09:31 +00:00
~BackupCoordinationRemote() override;
void setStage(const String & current_host, const String & new_stage, const String & message) override;
void setError(const String & current_host, const Exception & exception) override;
Strings waitForStage(const Strings & all_hosts, const String & stage_to_wait) override;
Strings waitForStage(const Strings & all_hosts, const String & stage_to_wait, std::chrono::milliseconds timeout) override;
2022-05-23 12:05:35 +00:00
void addReplicatedPartNames(
const String & table_shared_id,
const String & table_name_for_logs,
const String & replica_name,
const std::vector<PartNameAndChecksum> & part_names_and_checksums) override;
2022-05-23 12:05:35 +00:00
Strings getReplicatedPartNames(const String & table_shared_id, const String & replica_name) const override;
2022-05-23 12:05:35 +00:00
2022-07-05 07:39:52 +00:00
void addReplicatedMutations(
const String & table_shared_id,
const String & table_name_for_logs,
const String & replica_name,
const std::vector<MutationInfo> & mutations) override;
2022-07-06 10:03:10 +00:00
2022-07-05 07:39:52 +00:00
std::vector<MutationInfo> getReplicatedMutations(const String & table_shared_id, const String & replica_name) const override;
void addReplicatedDataPath(const String & table_shared_id, const String & data_path) override;
Strings getReplicatedDataPaths(const String & table_shared_id) const override;
void addReplicatedAccessFilePath(const String & access_zk_path, AccessEntityType access_entity_type, const String & host_id, const String & file_path) override;
Strings getReplicatedAccessFilePaths(const String & access_zk_path, AccessEntityType access_entity_type, const String & host_id) const override;
void addFileInfo(const FileInfo & file_info, bool & is_data_file_required) override;
void updateFileInfo(const FileInfo & file_info) override;
2022-04-19 18:15:27 +00:00
std::vector<FileInfo> getAllFileInfos() const override;
2022-06-19 13:48:52 +00:00
Strings listFiles(const String & directory, bool recursive) const override;
2022-06-06 09:50:20 +00:00
bool hasFiles(const String & directory) const override;
2022-04-19 18:15:27 +00:00
std::optional<FileInfo> getFileInfo(const String & file_name) const override;
std::optional<FileInfo> getFileInfo(const SizeAndChecksum & size_and_checksum) const override;
std::optional<SizeAndChecksum> getFileSizeAndChecksum(const String & file_name) const override;
String getNextArchiveSuffix() override;
2022-04-19 18:15:27 +00:00
Strings getAllArchiveSuffixes() const override;
private:
2022-07-26 11:15:34 +00:00
zkutil::ZooKeeperPtr getZooKeeper() const;
zkutil::ZooKeeperPtr getZooKeeperNoLock() const;
void createRootNodes();
void removeAllNodes();
2022-07-06 09:09:31 +00:00
void prepareReplicatedTables() const;
void prepareReplicatedAccess() const;
2022-04-19 18:15:27 +00:00
const String zookeeper_path;
const zkutil::GetZooKeeper get_zookeeper;
const bool remove_zk_nodes_in_destructor;
2022-07-26 11:15:34 +00:00
std::optional<BackupCoordinationStageSync> stage_sync;
mutable std::mutex mutex;
2022-07-26 11:15:34 +00:00
mutable zkutil::ZooKeeperPtr zookeeper;
2022-07-06 09:09:31 +00:00
mutable std::optional<BackupCoordinationReplicatedTables> replicated_tables;
mutable std::optional<BackupCoordinationReplicatedAccess> replicated_access;
};
}