ClickHouse/dbms/src/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 <Core/Types.h>
#include <Interpreters/InterserverIOHandler.h>
#include <IO/WriteBuffer.h>
2016-01-28 01:00:27 +00:00
namespace DB
{
2016-01-28 01:00:42 +00:00
class Context;
2016-01-28 01:00:27 +00:00
namespace RemoteDiskSpaceMonitor
{
2017-04-16 15:00:33 +00:00
/** Service to get information about free disk space.
2016-01-28 01:00:27 +00:00
*/
class Service final : public InterserverIOEndpoint
{
public:
Service(const Context & context_);
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, ReadBuffer & body, WriteBuffer & out, Poco::Net::HTTPServerResponse & response) override;
2016-01-28 01:00:27 +00:00
private:
const Context & context;
2016-01-28 01:00:27 +00:00
};
2017-04-16 15:00:33 +00:00
/** Client to get information about free space on a remote disk.
2016-01-28 01:00:27 +00:00
*/
class Client final
{
public:
Client() = default;
Client(const Client &) = delete;
Client & operator=(const Client &) = delete;
size_t getFreeSpace(const InterserverIOEndpointLocation & location) const;
void cancel() { is_cancelled = true; }
2016-01-28 01:00:27 +00:00
private:
std::atomic<bool> is_cancelled{false};
2016-01-28 01:00:27 +00:00
};
}
}