2016-01-28 01:00:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#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:
|
2017-04-01 07:20:54 +00:00
|
|
|
Service(const Context & context_);
|
|
|
|
Service(const Service &) = delete;
|
|
|
|
Service & operator=(const Service &) = delete;
|
|
|
|
std::string getId(const std::string & node_id) const override;
|
2017-04-06 13:03:23 +00:00
|
|
|
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:
|
2017-04-01 07:20:54 +00:00
|
|
|
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:
|
2017-04-01 07:20:54 +00:00
|
|
|
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:
|
2017-04-01 07:20:54 +00:00
|
|
|
std::atomic<bool> is_cancelled{false};
|
2016-01-28 01:00:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|