mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
dbms: added ability to set different kinds of timeouts [#METR-14236]
This commit is contained in:
parent
4315421722
commit
13249ff3c3
@ -12,6 +12,7 @@
|
||||
#include <Yandex/logger_useful.h>
|
||||
|
||||
#define DEFAULT_HTTP_READ_BUFFER_TIMEOUT 1800
|
||||
#define DEFAULT_HTTP_READ_BUFFER_CONNECTION_TIMEOUT 1
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -36,8 +37,10 @@ public:
|
||||
const std::string & host_,
|
||||
int port_,
|
||||
const Params & params,
|
||||
size_t timeout_ = 0,
|
||||
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE)
|
||||
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
const Poco::Timespan & connection_timeout = Poco::Timespan(DEFAULT_HTTP_READ_BUFFER_CONNECTION_TIMEOUT, 0),
|
||||
const Poco::Timespan & send_timeout = Poco::Timespan(DEFAULT_HTTP_READ_BUFFER_TIMEOUT, 0),
|
||||
const Poco::Timespan & receive_timeout = Poco::Timespan(DEFAULT_HTTP_READ_BUFFER_TIMEOUT, 0))
|
||||
: ReadBuffer(nullptr, 0), host(host_), port(port_)
|
||||
{
|
||||
std::stringstream uri;
|
||||
@ -59,7 +62,7 @@ public:
|
||||
session.setPort(port);
|
||||
|
||||
/// устанавливаем таймаут
|
||||
session.setTimeout(Poco::Timespan(timeout_ ? timeout_ : DEFAULT_HTTP_READ_BUFFER_TIMEOUT, 0));
|
||||
session.setTimeout(connection_timeout, send_timeout, receive_timeout);
|
||||
|
||||
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, uri.str());
|
||||
Poco::Net::HTTPResponse response;
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include <DB/IO/ReadBufferFromHTTP.h>
|
||||
#include "ReadHelpers.h"
|
||||
|
||||
#define DEFAULT_REMOTE_READ_BUFFER_CONNECTION_TIMEOUT 1
|
||||
#define DEFAULT_REMOTE_READ_BUFFER_RECEIVE_TIMEOUT 1800
|
||||
#define DEFAULT_REMOTE_READ_BUFFER_SEND_TIMEOUT 1800
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -20,8 +23,10 @@ public:
|
||||
int port,
|
||||
const std::string & path,
|
||||
bool compress = true,
|
||||
size_t timeout = 0,
|
||||
size_t buffer_size = DBMS_DEFAULT_BUFFER_SIZE)
|
||||
size_t buffer_size = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
const Poco::Timespan & connection_timeout = Poco::Timespan(DEFAULT_REMOTE_READ_BUFFER_CONNECTION_TIMEOUT, 0),
|
||||
const Poco::Timespan & send_timeout = Poco::Timespan(DEFAULT_REMOTE_READ_BUFFER_SEND_TIMEOUT, 0),
|
||||
const Poco::Timespan & receive_timeout = Poco::Timespan(DEFAULT_REMOTE_READ_BUFFER_RECEIVE_TIMEOUT, 0))
|
||||
: ReadBuffer(nullptr, 0)
|
||||
{
|
||||
ReadBufferFromHTTP::Params params = {
|
||||
@ -29,7 +34,7 @@ public:
|
||||
std::make_pair("path", path),
|
||||
std::make_pair("compress", (compress ? "true" : "false"))};
|
||||
|
||||
impl = new ReadBufferFromHTTP(host, port, params, timeout, buffer_size);
|
||||
impl = new ReadBufferFromHTTP(host, port, params, buffer_size, connection_timeout, send_timeout, receive_timeout);
|
||||
}
|
||||
|
||||
bool nextImpl()
|
||||
|
@ -13,7 +13,9 @@
|
||||
|
||||
#include <Yandex/logger_useful.h>
|
||||
|
||||
#define DEFAULT_REMOTE_WRITE_BUFFER_TIMEOUT 1800
|
||||
#define DEFAULT_REMOTE_WRITE_BUFFER_CONNECTION_TIMEOUT 1
|
||||
#define DEFAULT_REMOTE_WRITE_BUFFER_RECEIVE_TIMEOUT 1800
|
||||
#define DEFAULT_REMOTE_WRITE_BUFFER_SEND_TIMEOUT 1800
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -49,8 +51,12 @@ public:
|
||||
*/
|
||||
RemoteWriteBuffer(const std::string & host_, int port_, const std::string & path_,
|
||||
const std::string & tmp_path_ = "", const std::string & if_exists_ = "remove",
|
||||
bool decompress_ = false, size_t timeout_ = 0, unsigned connection_retries_ = 3,
|
||||
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE)
|
||||
bool decompress_ = false,
|
||||
unsigned connection_retries_ = 3,
|
||||
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
const Poco::Timespan & connection_timeout = Poco::Timespan(DEFAULT_REMOTE_WRITE_BUFFER_CONNECTION_TIMEOUT, 0),
|
||||
const Poco::Timespan & send_timeout = Poco::Timespan(DEFAULT_REMOTE_WRITE_BUFFER_SEND_TIMEOUT, 0),
|
||||
const Poco::Timespan & receive_timeout = Poco::Timespan(DEFAULT_REMOTE_WRITE_BUFFER_RECEIVE_TIMEOUT, 0))
|
||||
: WriteBuffer(nullptr, 0), host(host_), port(port_), path(path_),
|
||||
tmp_path(tmp_path_), if_exists(if_exists_),
|
||||
decompress(decompress_), connection_retries(connection_retries_), finalized(false)
|
||||
@ -72,7 +78,7 @@ public:
|
||||
session.setKeepAlive(true);
|
||||
|
||||
/// устанавливаем таймаут
|
||||
session.setTimeout(Poco::Timespan((timeout_ ? timeout_ : DEFAULT_REMOTE_WRITE_BUFFER_TIMEOUT), 0));
|
||||
session.setTimeout(connection_timeout, send_timeout, receive_timeout);
|
||||
|
||||
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, uri_str, Poco::Net::HTTPRequest::HTTP_1_1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user