ClickHouse/dbms/src/Storages/MergeTree/ReplicatedMergeTreeAlterThread.h

46 lines
927 B
C++
Raw Normal View History

2016-04-09 04:22:11 +00:00
#pragma once
#include <thread>
#include <Common/ZooKeeper/Types.h>
#include <Core/Types.h>
2016-04-09 04:22:11 +00:00
#include <common/logger_useful.h>
namespace DB
{
class StorageReplicatedMergeTree;
2017-04-16 15:00:33 +00:00
/** Keeps track of changing the table structure in ZooKeeper and performs the necessary conversions.
2016-04-09 04:22:11 +00:00
*
2017-04-16 15:00:33 +00:00
* NOTE This has nothing to do with manipulating partitions,
* which are processed through the replication queue.
2016-04-09 04:22:11 +00:00
*/
class ReplicatedMergeTreeAlterThread
{
public:
ReplicatedMergeTreeAlterThread(StorageReplicatedMergeTree & storage_);
2016-04-09 04:22:11 +00:00
~ReplicatedMergeTreeAlterThread()
{
need_stop = true;
wakeup_event->set();
if (thread.joinable())
thread.join();
}
2016-04-09 04:22:11 +00:00
private:
void run();
2016-04-09 04:22:11 +00:00
StorageReplicatedMergeTree & storage;
Logger * log;
2016-04-09 04:22:11 +00:00
zkutil::EventPtr wakeup_event { std::make_shared<Poco::Event>() };
std::atomic<bool> need_stop { false };
2016-04-09 04:22:11 +00:00
std::thread thread;
2016-04-09 04:22:11 +00:00
};
}