2022-04-25 14:33:25 +00:00
# pragma once
2022-04-17 12:11:43 +00:00
# include <Backups/IBackupCoordination.h>
2022-05-08 21:41:49 +00:00
# include <Backups/BackupCoordinationHelpers.h>
2022-04-17 12:11:43 +00:00
# include <map>
2022-04-25 14:33:25 +00:00
# include <mutex>
2022-04-17 12:11:43 +00:00
2022-05-08 21:41:49 +00:00
namespace Poco { class Logger ; }
2022-04-17 12:11:43 +00:00
namespace DB
{
/// Stores backup contents information in memory.
2022-04-19 18:15:27 +00:00
class BackupCoordinationLocal : public IBackupCoordination
2022-04-17 12:11:43 +00:00
{
public :
2022-04-19 18:15:27 +00:00
BackupCoordinationLocal ( ) ;
~ BackupCoordinationLocal ( ) override ;
2022-04-17 12:11:43 +00:00
2022-05-08 21:41:49 +00:00
void addReplicatedTableDataPath ( const String & table_zk_path , const String & table_data_path ) override ;
void addReplicatedTablePartNames (
const String & host_id ,
const DatabaseAndTableName & table_name ,
const String & table_zk_path ,
const std : : vector < PartNameAndChecksum > & part_names_and_checksums ) override ;
void finishPreparing ( const String & host_id , const String & error_message ) override ;
void waitForAllHostsPrepared ( const Strings & host_ids , std : : chrono : : seconds timeout ) const override ;
Strings getReplicatedTableDataPaths ( const String & table_zk_path ) const override ;
Strings getReplicatedTablePartNames ( const String & host_id , const DatabaseAndTableName & table_name , const String & table_zk_path ) const override ;
2022-04-19 09:02:34 +00:00
void addFileInfo ( const FileInfo & file_info , bool & is_data_file_required ) override ;
2022-04-17 12:11:43 +00:00
void updateFileInfo ( const FileInfo & file_info ) override ;
2022-04-19 18:15:27 +00:00
std : : vector < FileInfo > getAllFileInfos ( ) const override ;
Strings listFiles ( const String & prefix , const String & terminator ) const override ;
2022-04-19 09:02:34 +00:00
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 ;
2022-04-17 12:11:43 +00:00
String getNextArchiveSuffix ( ) override ;
2022-04-19 18:15:27 +00:00
Strings getAllArchiveSuffixes ( ) const override ;
2022-04-17 12:11:43 +00:00
private :
2022-04-19 18:15:27 +00:00
mutable std : : mutex mutex ;
2022-05-08 21:41:49 +00:00
BackupCoordinationReplicatedTablesInfo replicated_tables ;
2022-04-19 09:02:34 +00:00
std : : map < String /* file_name */ , SizeAndChecksum > file_names ; /// Should be ordered alphabetically, see listFiles(). For empty files we assume checksum = 0.
std : : map < SizeAndChecksum , FileInfo > file_infos ; /// Information about files. Without empty files.
2022-04-17 12:11:43 +00:00
Strings archive_suffixes ;
size_t current_archive_suffix = 0 ;
2022-05-08 21:41:49 +00:00
const Poco : : Logger * log ;
2022-04-17 12:11:43 +00:00
} ;
2022-05-08 21:41:49 +00:00
2022-04-17 12:11:43 +00:00
}