2016-04-09 04:22:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <thread>
|
2017-06-19 20:06:35 +00:00
|
|
|
#include <Common/ZooKeeper/Types.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#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:
|
2017-04-01 07:20:54 +00:00
|
|
|
ReplicatedMergeTreeAlterThread(StorageReplicatedMergeTree & storage_);
|
2016-04-09 04:22:11 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
~ReplicatedMergeTreeAlterThread()
|
|
|
|
{
|
|
|
|
need_stop = true;
|
|
|
|
wakeup_event->set();
|
|
|
|
if (thread.joinable())
|
|
|
|
thread.join();
|
|
|
|
}
|
2016-04-09 04:22:11 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
void run();
|
2016-04-09 04:22:11 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
StorageReplicatedMergeTree & storage;
|
|
|
|
Logger * log;
|
2016-04-09 04:22:11 +00:00
|
|
|
|
2017-04-01 07:20:54 +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
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::thread thread;
|
2016-04-09 04:22:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|