ClickHouse/src/Storages/MergeTree/ReplicatedFetchList.h

95 lines
2.4 KiB
C++
Raw Normal View History

2020-10-26 16:38:35 +00:00
#pragma once
#include <Common/CurrentMetrics.h>
#include <boost/noncopyable.hpp>
#include <Storages/MergeTree/BackgroundProcessList.h>
#include <Common/Stopwatch.h>
#include <Common/MemoryTracker.h>
2020-10-27 12:24:10 +00:00
#include <Poco/URI.h>
2020-10-26 16:38:35 +00:00
namespace CurrentMetrics
{
extern const Metric ReplicatedFetch;
}
namespace DB
{
struct ReplicatedFetchInfo
{
std::string database;
std::string table;
std::string partition_id;
std::string result_part_name;
std::string result_part_path;
std::string source_replica_path;
2020-10-27 12:24:10 +00:00
std::string source_replica_hostname;
UInt16 source_replica_port;
2020-10-26 16:38:35 +00:00
std::string interserver_scheme;
2020-10-27 12:24:10 +00:00
std::string uri;
2020-10-26 16:38:35 +00:00
UInt8 to_detached;
Float64 elapsed;
Float64 progress;
UInt64 total_size_bytes_compressed;
UInt64 bytes_read_compressed;
UInt64 thread_id;
};
struct ReplicatedFetchListElement : private boost::noncopyable
{
const std::string database;
const std::string table;
const std::string partition_id;
const std::string result_part_name;
const std::string result_part_path;
2020-10-27 12:57:55 +00:00
const std::string source_replica_path;
const std::string source_replica_hostname;
const UInt16 source_replica_port;
const std::string interserver_scheme;
const std::string uri;
2020-10-26 16:38:35 +00:00
const UInt8 to_detached;
Stopwatch watch;
std::atomic<Float64> progress{};
2020-10-27 12:57:55 +00:00
/// How many bytes already read
2020-10-26 16:38:35 +00:00
std::atomic<UInt64> bytes_read_compressed{};
2020-10-27 12:57:55 +00:00
/// Total bytes to read
const UInt64 total_size_bytes_compressed{};
2020-10-26 16:38:35 +00:00
2020-10-27 12:57:55 +00:00
const UInt64 thread_id;
2020-10-26 16:38:35 +00:00
ReplicatedFetchListElement(
const std::string & database_, const std::string & table_,
const std::string & partition_id_, const std::string & result_part_name_,
const std::string & result_part_path_, const std::string & source_replica_path_,
2020-10-27 12:24:10 +00:00
const Poco::URI & uri, UInt8 to_detached_, UInt64 total_size_bytes_compressed_);
2020-10-26 16:38:35 +00:00
ReplicatedFetchInfo getInfo() const;
};
using ReplicatedFetchListEntry = BackgroundProcessListEntry<ReplicatedFetchListElement, ReplicatedFetchInfo>;
2020-10-27 12:57:55 +00:00
/// List of currently processing replicated fetches
2020-10-26 16:38:35 +00:00
class ReplicatedFetchList final : public BackgroundProcessList<ReplicatedFetchListElement, ReplicatedFetchInfo>
{
private:
using Parent = BackgroundProcessList<ReplicatedFetchListElement, ReplicatedFetchInfo>;
public:
ReplicatedFetchList ()
: Parent(CurrentMetrics::ReplicatedFetch)
{}
};
}