aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Storages/MergeTree/MovesList.h
blob: 42f0901b41dfd8322b3f497cecdf4ffb85c8f187 (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
#pragma once
#include <Storages/MergeTree/BackgroundProcessList.h>
#include <Interpreters/StorageID.h>
#include <Common/Stopwatch.h>
#include <Common/CurrentMetrics.h>
#include <Poco/URI.h>
#include <boost/noncopyable.hpp>

namespace CurrentMetrics
{
    extern const Metric Move;
}

namespace DB
{

struct MoveInfo
{
    std::string database;
    std::string table;
    std::string part_name;
    std::string target_disk_name;
    std::string target_disk_path;
    UInt64 part_size;

    Float64 elapsed;
    UInt64 thread_id;
};

struct MovesListElement : private boost::noncopyable
{
    const StorageID table_id;
    const std::string part_name;
    const std::string target_disk_name;
    const std::string target_disk_path;
    const UInt64 part_size;

    Stopwatch watch;
    const UInt64 thread_id;

    MovesListElement(
        const StorageID & table_id_,
        const std::string & part_name_,
        const std::string & target_disk_name_,
        const std::string & target_disk_path_,
        UInt64 part_size_);

    MoveInfo getInfo() const;
};


/// List of currently processing moves
class MovesList final : public BackgroundProcessList<MovesListElement, MoveInfo>
{
private:
    using Parent = BackgroundProcessList<MovesListElement, MoveInfo>;

public:
    MovesList()
        : Parent(CurrentMetrics::Move)
    {}
};

}