blob: 0ab631e53b463bffcf88732c3b364fbec12f13d6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#pragma once
#include <Common/CurrentMetrics.h>
#include <boost/noncopyable.hpp>
#include <Storages/MergeTree/BackgroundProcessList.h>
#include <Common/Stopwatch.h>
#include <Poco/URI.h>
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;
std::string source_replica_hostname;
UInt16 source_replica_port;
std::string interserver_scheme;
std::string uri;
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;
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;
const UInt8 to_detached;
Stopwatch watch;
std::atomic<Float64> progress{};
/// How many bytes already read
std::atomic<UInt64> bytes_read_compressed{};
/// Total bytes to read
/// NOTE: can be zero if we fetching data from old server.
/// In this case progress is not tracked.
const UInt64 total_size_bytes_compressed{};
const UInt64 thread_id;
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_,
const Poco::URI & uri, UInt8 to_detached_, UInt64 total_size_bytes_compressed_);
ReplicatedFetchInfo getInfo() const;
};
using ReplicatedFetchListEntry = BackgroundProcessListEntry<ReplicatedFetchListElement, ReplicatedFetchInfo>;
/// List of currently processing replicated fetches
class ReplicatedFetchList final : public BackgroundProcessList<ReplicatedFetchListElement, ReplicatedFetchInfo>
{
private:
using Parent = BackgroundProcessList<ReplicatedFetchListElement, ReplicatedFetchInfo>;
public:
ReplicatedFetchList ()
: Parent(CurrentMetrics::ReplicatedFetch)
{}
};
}
|