ClickHouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.h
Azat Khuzhin 79b83c4fd2 Remove superfluous includes of logger_userful.h from headers
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-04-10 17:59:30 +02:00

54 lines
1.2 KiB
C++

#pragma once
#include <thread>
#include <Core/BackgroundSchedulePool.h>
#include <Common/ZooKeeper/ZooKeeper.h>
namespace DB
{
class StorageReplicatedMergeTree;
// Attach table to the existing data.
// Initialize the table by creating all the necessary nodes and do the required checks.
// Initialization is repeated if an operation fails because of a ZK request or connection loss.
class ReplicatedMergeTreeAttachThread
{
public:
explicit ReplicatedMergeTreeAttachThread(StorageReplicatedMergeTree & storage_);
~ReplicatedMergeTreeAttachThread();
void start() { task->activateAndSchedule(); }
void shutdown();
void waitFirstTry() { first_try_done.wait(false); }
void setSkipSanityChecks(bool skip_sanity_checks_);
static void checkHasReplicaMetadataInZooKeeper(const zkutil::ZooKeeperPtr & zookeeper, const String & replica_path);
private:
StorageReplicatedMergeTree & storage;
BackgroundSchedulePool::TaskHolder task;
std::string log_name;
Poco::Logger * log;
std::atomic<bool> first_try_done{false};
std::atomic<bool> shutdown_called{false};
UInt64 retry_period;
bool skip_sanity_checks{false};
void run();
void runImpl();
void finalizeInitialization();
};
}