2014-08-15 09:50:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2014-08-20 02:20:07 +00:00
|
|
|
#include <DB/Storages/StorageDistributed.h>
|
2015-04-16 07:22:29 +00:00
|
|
|
|
2014-08-19 08:04:13 +00:00
|
|
|
#include <thread>
|
|
|
|
#include <mutex>
|
2015-04-16 07:22:29 +00:00
|
|
|
#include <condition_variable>
|
|
|
|
|
2014-08-15 09:50:05 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-12-12 03:33:34 +00:00
|
|
|
/** Details of StorageDistributed.
|
|
|
|
* This type is not designed for standalone use.
|
|
|
|
*/
|
|
|
|
class StorageDistributedDirectoryMonitor
|
2014-08-15 09:50:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-12-12 03:33:34 +00:00
|
|
|
StorageDistributedDirectoryMonitor(StorageDistributed & storage, const std::string & name);
|
|
|
|
~StorageDistributedDirectoryMonitor();
|
2014-08-19 08:04:13 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-12 03:33:34 +00:00
|
|
|
void run();
|
|
|
|
ConnectionPoolPtr createPool(const std::string & name);
|
|
|
|
bool findFiles();
|
|
|
|
void processFile(const std::string & file_path);
|
|
|
|
std::string getLoggerName() const;
|
2014-08-15 09:50:05 +00:00
|
|
|
|
|
|
|
StorageDistributed & storage;
|
|
|
|
ConnectionPoolPtr pool;
|
|
|
|
std::string path;
|
2016-12-12 03:33:34 +00:00
|
|
|
size_t error_count{};
|
2014-12-25 20:53:18 +00:00
|
|
|
std::chrono::milliseconds default_sleep_time;
|
2014-08-15 09:50:05 +00:00
|
|
|
std::chrono::milliseconds sleep_time;
|
2016-12-12 03:33:34 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> last_decrease_time {std::chrono::system_clock::now()};
|
|
|
|
bool quit {false};
|
2014-08-19 08:04:13 +00:00
|
|
|
std::mutex mutex;
|
|
|
|
std::condition_variable cond;
|
2014-08-15 09:50:05 +00:00
|
|
|
Logger * log;
|
2016-12-12 03:33:34 +00:00
|
|
|
std::thread thread {&StorageDistributedDirectoryMonitor::run, this};
|
2014-08-15 09:50:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|