ClickHouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.h

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

55 lines
1.3 KiB
C++
Raw Normal View History

2022-08-12 09:32:13 +00:00
#pragma once
#include <thread>
#include <Core/BackgroundSchedulePool.h>
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Common/logger_useful.h>
namespace DB
{
class StorageReplicatedMergeTree;
2022-08-19 11:12:20 +00:00
// 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.
2022-08-12 09:32:13 +00:00
class ReplicatedMergeTreeAttachThread
{
public:
explicit ReplicatedMergeTreeAttachThread(StorageReplicatedMergeTree & storage_);
2022-08-17 08:28:53 +00:00
~ReplicatedMergeTreeAttachThread();
2022-08-12 09:32:13 +00:00
void start() { task->activateAndSchedule(); }
void shutdown();
void waitFirstTry() { first_try_done.wait(false); }
void setSkipSanityChecks(bool skip_sanity_checks_);
2022-08-25 20:08:48 +00:00
static void checkHasReplicaMetadataInZooKeeper(const zkutil::ZooKeeperPtr & zookeeper, const String & replica_path);
2022-08-12 09:32:13 +00:00
private:
StorageReplicatedMergeTree & storage;
BackgroundSchedulePool::TaskHolder task;
std::string log_name;
Poco::Logger * log;
std::atomic<bool> first_try_done{false};
2022-08-17 08:28:53 +00:00
std::atomic<bool> shutdown_called{false};
2022-08-12 09:32:13 +00:00
UInt64 retry_period;
2022-08-17 08:28:53 +00:00
bool skip_sanity_checks{false};
2022-08-12 09:32:13 +00:00
void run();
2022-08-19 08:17:02 +00:00
void runImpl();
2022-08-12 09:32:13 +00:00
2022-08-16 08:19:02 +00:00
void finalizeInitialization();
2022-08-12 09:32:13 +00:00
};
}