mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
a25dd1d348
Server settings: - max_local_read_bandwidth_for_server - max_local_write_bandwidth_for_server Query settings: - max_local_read_bandwidth - max_local_write_bandwidth This is the preparation for adding ability to throttle BACKUPs Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <IO/WriteBufferFromFileBase.h>
|
|
#include <Common/Throttler_fwd.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Use ready file descriptor. Does not open or close a file.
|
|
*/
|
|
class WriteBufferFromFileDescriptor : public WriteBufferFromFileBase
|
|
{
|
|
public:
|
|
explicit WriteBufferFromFileDescriptor(
|
|
int fd_ = -1,
|
|
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
|
char * existing_memory = nullptr,
|
|
ThrottlerPtr throttler_ = {},
|
|
size_t alignment = 0,
|
|
std::string file_name_ = "");
|
|
|
|
/** Could be used before initialization if needed 'fd' was not passed to constructor.
|
|
* It's not possible to change 'fd' during work.
|
|
*/
|
|
void setFD(int fd_)
|
|
{
|
|
fd = fd_;
|
|
}
|
|
|
|
~WriteBufferFromFileDescriptor() override;
|
|
|
|
int getFD() const
|
|
{
|
|
return fd;
|
|
}
|
|
|
|
void sync() override;
|
|
|
|
/// clang-tidy wants these methods to be const, but
|
|
/// they are not const semantically
|
|
off_t seek(off_t offset, int whence); // NOLINT
|
|
void truncate(off_t length); // NOLINT
|
|
|
|
/// Name or some description of file.
|
|
std::string getFileName() const override;
|
|
|
|
off_t size() const;
|
|
|
|
protected:
|
|
void nextImpl() override;
|
|
|
|
int fd;
|
|
ThrottlerPtr throttler;
|
|
|
|
/// If file has name contains filename, otherwise contains string "(fd=...)"
|
|
std::string file_name;
|
|
|
|
void finalizeImpl() override;
|
|
};
|
|
|
|
}
|