ClickHouse/src/Storages/MergeTree/ParallelReplicasReadingCoordinator.h

37 lines
982 B
C++
Raw Normal View History

#pragma once
#include <memory>
#include <Storages/MergeTree/RequestResponse.h>
2022-11-14 05:09:03 +00:00
namespace DB
{
2023-02-03 13:34:18 +00:00
/// The main class to spread mark ranges across replicas dynamically
/// The reason why it uses pimpl - this header file is included in
/// multiple other files like Context or RemoteQueryExecutor
class ParallelReplicasReadingCoordinator
{
public:
2023-02-03 13:34:18 +00:00
class ImplInterface;
explicit ParallelReplicasReadingCoordinator(size_t replicas_count_);
~ParallelReplicasReadingCoordinator();
2023-02-03 13:34:18 +00:00
void setMode(CoordinationMode mode);
void handleInitialAllRangesAnnouncement(InitialAllRangesAnnouncement);
ParallelReadResponse handleRequest(ParallelReadRequest request);
private:
2023-02-03 13:34:18 +00:00
void initialize();
CoordinationMode mode{CoordinationMode::Default};
size_t replicas_count{0};
std::atomic<bool> initialized{false};
std::unique_ptr<ImplInterface> pimpl;
};
using ParallelReplicasReadingCoordinatorPtr = std::shared_ptr<ParallelReplicasReadingCoordinator>;
}