2022-04-17 12:11:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/Types.h>
|
2022-04-25 14:33:25 +00:00
|
|
|
#include <optional>
|
2022-04-17 12:11:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Keeps information about files contained in a backup.
|
|
|
|
class IBackupCoordination
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct FileInfo
|
|
|
|
{
|
|
|
|
String file_name;
|
|
|
|
|
|
|
|
UInt64 size = 0;
|
|
|
|
UInt128 checksum{0};
|
|
|
|
|
|
|
|
/// for incremental backups
|
|
|
|
UInt64 base_size = 0;
|
|
|
|
UInt128 base_checksum{0};
|
|
|
|
|
2022-04-19 09:02:34 +00:00
|
|
|
/// Name of the data file.
|
|
|
|
String data_file_name;
|
|
|
|
|
2022-04-17 12:11:43 +00:00
|
|
|
/// Suffix of an archive if the backup is stored as a series of archives.
|
|
|
|
String archive_suffix;
|
|
|
|
|
|
|
|
/// Position in the archive.
|
|
|
|
UInt64 pos_in_archive = static_cast<UInt64>(-1);
|
|
|
|
};
|
|
|
|
|
2022-04-19 18:15:27 +00:00
|
|
|
virtual ~IBackupCoordination() = default;
|
2022-04-17 12:11:43 +00:00
|
|
|
|
|
|
|
/// Adds file information.
|
2022-04-19 09:02:34 +00:00
|
|
|
/// If specified checksum+size are new for this IBackupContentsInfo the function sets `is_data_file_required`.
|
|
|
|
virtual void addFileInfo(const FileInfo & file_info, bool & is_data_file_required) = 0;
|
2022-04-17 12:11:43 +00:00
|
|
|
|
|
|
|
void addFileInfo(const FileInfo & file_info)
|
|
|
|
{
|
2022-04-19 09:02:34 +00:00
|
|
|
bool is_data_file_required;
|
|
|
|
addFileInfo(file_info, is_data_file_required);
|
2022-04-17 12:11:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Updates some fields (currently only `archive_suffix`) of a stored file's information.
|
|
|
|
virtual void updateFileInfo(const FileInfo & file_info) = 0;
|
|
|
|
|
2022-04-19 18:15:27 +00:00
|
|
|
virtual std::vector<FileInfo> getAllFileInfos() const = 0;
|
|
|
|
virtual Strings listFiles(const String & prefix, const String & terminator) const = 0;
|
2022-04-17 12:11:43 +00:00
|
|
|
|
2022-04-19 09:02:34 +00:00
|
|
|
using SizeAndChecksum = std::pair<UInt64, UInt128>;
|
|
|
|
|
2022-04-19 18:15:27 +00:00
|
|
|
virtual std::optional<FileInfo> getFileInfo(const String & file_name) const = 0;
|
|
|
|
virtual std::optional<FileInfo> getFileInfo(const SizeAndChecksum & size_and_checksum) const = 0;
|
|
|
|
virtual std::optional<SizeAndChecksum> getFileSizeAndChecksum(const String & file_name) const = 0;
|
2022-04-17 12:11:43 +00:00
|
|
|
|
|
|
|
/// Generates a new archive suffix, e.g. "001", "002", "003", ...
|
|
|
|
virtual String getNextArchiveSuffix() = 0;
|
|
|
|
|
|
|
|
/// Returns the list of all the archive suffixes which were generated.
|
2022-04-19 18:15:27 +00:00
|
|
|
virtual Strings getAllArchiveSuffixes() const = 0;
|
2022-04-17 12:11:43 +00:00
|
|
|
|
|
|
|
/// Removes remotely stored information.
|
|
|
|
virtual void drop() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|