2014-03-21 13:42:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-05-20 17:04:36 +00:00
|
|
|
#include <memory>
|
2017-08-09 14:33:07 +00:00
|
|
|
#include <Poco/Logger.h>
|
|
|
|
#include <Poco/Net/HTTPRequestHandler.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/CurrentMetrics.h>
|
2014-03-21 13:42:14 +00:00
|
|
|
|
|
|
|
|
2016-10-24 04:06:27 +00:00
|
|
|
namespace CurrentMetrics
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
extern const Metric InterserverConnection;
|
2016-10-24 04:06:27 +00:00
|
|
|
}
|
|
|
|
|
2014-03-21 13:42:14 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-05-20 17:04:36 +00:00
|
|
|
class IServer;
|
|
|
|
class WriteBufferFromHTTPServerResponse;
|
|
|
|
|
2014-03-21 13:42:14 +00:00
|
|
|
class InterserverIOHTTPHandler : public Poco::Net::HTTPRequestHandler
|
|
|
|
{
|
|
|
|
public:
|
2017-09-07 21:04:48 +00:00
|
|
|
explicit InterserverIOHTTPHandler(IServer & server_)
|
2017-04-01 07:20:54 +00:00
|
|
|
: server(server_)
|
2017-08-09 14:33:07 +00:00
|
|
|
, log(&Poco::Logger::get("InterserverIOHTTPHandler"))
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
}
|
2014-03-21 13:42:14 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response) override;
|
2014-03-21 13:42:14 +00:00
|
|
|
|
|
|
|
private:
|
2019-05-20 17:04:36 +00:00
|
|
|
struct Output
|
|
|
|
{
|
|
|
|
std::shared_ptr<WriteBufferFromHTTPServerResponse> out;
|
|
|
|
};
|
|
|
|
|
2017-08-09 11:57:09 +00:00
|
|
|
IServer & server;
|
2017-08-09 14:33:07 +00:00
|
|
|
Poco::Logger * log;
|
2014-03-21 13:42:14 +00:00
|
|
|
|
2017-08-09 11:57:09 +00:00
|
|
|
CurrentMetrics::Increment metric_increment{CurrentMetrics::InterserverConnection};
|
|
|
|
|
2019-05-20 17:04:36 +00:00
|
|
|
void processQuery(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response, Output & used_output);
|
2018-07-26 15:10:57 +00:00
|
|
|
|
|
|
|
std::pair<String, bool> checkAuthentication(Poco::Net::HTTPServerRequest & request) const;
|
2014-03-21 13:42:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|