forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathStorageObjectStorageStableTaskDistributor.h
More file actions
65 lines (48 loc) · 2.05 KB
/
StorageObjectStorageStableTaskDistributor.h
File metadata and controls
65 lines (48 loc) · 2.05 KB
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
#pragma once
#include <Client/Connection.h>
#include <Common/Logger.h>
#include <Interpreters/Cluster.h>
#include <Storages/ObjectStorage/StorageObjectStorageSource.h>
#include <Storages/ObjectStorageQueue/ObjectStorageQueueSource.h>
#include <Poco/Timestamp.h>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <vector>
#include <mutex>
#include <memory>
namespace DB
{
class StorageObjectStorageStableTaskDistributor
{
public:
StorageObjectStorageStableTaskDistributor(
std::shared_ptr<IObjectIterator> iterator_,
std::vector<std::string> && ids_of_nodes_,
bool send_over_whole_archive_,
uint64_t lock_object_storage_task_distribution_ms_,
bool iceberg_read_optimization_enabled_);
ObjectInfoPtr getNextTask(size_t number_of_current_replica);
/// Insert objects back to unprocessed files
void rescheduleTasksFromReplica(size_t number_of_current_replica);
private:
size_t getReplicaForFile(const String & file_path);
ObjectInfoPtr getPreQueuedFile(size_t number_of_current_replica);
ObjectInfoPtr getMatchingFileFromIterator(size_t number_of_current_replica);
ObjectInfoPtr getAnyUnprocessedFile(size_t number_of_current_replica);
void saveLastNodeActivity(size_t number_of_current_replica);
String getFileIdentifier(ObjectInfoPtr file_object, bool write_to_log = false) const;
const std::shared_ptr<IObjectIterator> iterator;
const bool send_over_whole_archive;
std::vector<std::vector<ObjectInfoPtr>> connection_to_files;
std::unordered_map<std::string, std::pair<ObjectInfoPtr, size_t>> unprocessed_files;
std::vector<std::string> ids_of_nodes;
std::unordered_map<size_t, Poco::Timestamp> last_node_activity;
Poco::Timestamp::TimeDiff lock_object_storage_task_distribution_us;
std::unordered_map<size_t, std::list<ObjectInfoPtr>> replica_to_files_to_be_processed;
std::mutex mutex;
bool iterator_exhausted = false;
bool iceberg_read_optimization_enabled = false;
LoggerPtr log = getLogger("StorageClusterTaskDistributor");
};
}