ClickHouse/dbms/include/DB/Storages/MergeTree/RemoteDiskSpaceMonitor.h

48 lines
1.1 KiB
C
Raw Normal View History

2016-01-28 01:00:27 +00:00
#pragma once
#include <DB/Core/Types.h>
#include <DB/Interpreters/InterserverIOHandler.h>
#include <DB/IO/WriteBuffer.h>
namespace DB
{
2016-01-28 01:00:42 +00:00
class Context;
2016-01-28 01:00:27 +00:00
namespace RemoteDiskSpaceMonitor
{
/** Сервис для получения информации о свободном месте на диске.
*/
class Service final : public InterserverIOEndpoint
{
public:
2016-01-28 01:00:42 +00:00
Service(const Context & context_);
2016-01-28 01:00:27 +00:00
Service(const Service &) = delete;
Service & operator=(const Service &) = delete;
std::string getId(const std::string & node_id) const override;
void processQuery(const Poco::Net::HTMLForm & params, WriteBuffer & out) override;
private:
2016-01-28 01:00:42 +00:00
const Context & context;
2016-01-28 01:00:27 +00:00
};
/** Клиент для получения информации о свободном месте на удалённом диске.
*/
class Client final
{
public:
Client() = default;
Client(const Client &) = delete;
Client & operator=(const Client &) = delete;
2016-01-28 01:00:42 +00:00
size_t getFreeSpace(const InterserverIOEndpointLocation & location) const;
2016-01-28 01:00:27 +00:00
void cancel() { is_cancelled = true; }
private:
std::atomic<bool> is_cancelled{false};
};
}
}