2021-12-09 10:39:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <Storages/MergeTree/RequestResponse.h>
|
|
|
|
|
2022-11-14 05:09:03 +00:00
|
|
|
|
2021-12-09 10:39:28 +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
|
2021-12-09 10:39:28 +00:00
|
|
|
class ParallelReplicasReadingCoordinator
|
|
|
|
{
|
|
|
|
public:
|
2023-02-03 13:34:18 +00:00
|
|
|
class ImplInterface;
|
|
|
|
|
|
|
|
explicit ParallelReplicasReadingCoordinator(size_t replicas_count_);
|
2021-12-09 10:39:28 +00:00
|
|
|
~ParallelReplicasReadingCoordinator();
|
2023-02-03 13:34:18 +00:00
|
|
|
|
|
|
|
void setMode(CoordinationMode mode);
|
|
|
|
void handleInitialAllRangesAnnouncement(InitialAllRangesAnnouncement);
|
|
|
|
ParallelReadResponse handleRequest(ParallelReadRequest request);
|
|
|
|
|
2021-12-09 10:39:28 +00:00
|
|
|
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;
|
2021-12-09 10:39:28 +00:00
|
|
|
};
|
|
|
|
|
2022-06-02 09:46:33 +00:00
|
|
|
using ParallelReplicasReadingCoordinatorPtr = std::shared_ptr<ParallelReplicasReadingCoordinator>;
|
|
|
|
|
2021-12-09 10:39:28 +00:00
|
|
|
}
|