ClickHouse/dbms/src/Storages/MergeTree/ShardedPartitionUploader.h

69 lines
1.8 KiB
C++
Raw Normal View History

2016-01-28 01:00:27 +00:00
#pragma once
#include <Interpreters/InterserverIOHandler.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <IO/WriteBuffer.h>
2016-01-28 01:00:42 +00:00
#include <common/logger_useful.h>
2016-03-01 17:47:53 +00:00
#include <functional>
2016-01-28 01:00:27 +00:00
namespace DB
{
class StorageReplicatedMergeTree;
2016-03-01 17:47:53 +00:00
namespace ShardedPartitionUploader
2016-01-28 01:00:27 +00:00
{
2017-04-16 15:00:33 +00:00
/** Service for retrieving parts from the partitions of the *MergeTree table.
2016-01-28 01:00:27 +00:00
*/
class Service final : public InterserverIOEndpoint
{
public:
Service(StoragePtr & storage_);
Service(const Service &) = delete;
Service & operator=(const Service &) = delete;
std::string getId(const std::string & node_id) const override;
void processQuery(const Poco::Net::HTMLForm & params, ReadBuffer & body, WriteBuffer & out, Poco::Net::HTTPServerResponse & response) override;
2016-01-28 01:00:27 +00:00
private:
StoragePtr owned_storage;
MergeTreeData & data;
Logger * log = &Logger::get("ShardedPartitionUploader::Service");
2016-01-28 01:00:27 +00:00
};
2017-04-16 15:00:33 +00:00
/** Client for sending parts from the partition of the *MergeTree table.
2016-01-28 01:00:27 +00:00
*/
class Client final
{
public:
using CancellationHook = std::function<void()>;
2016-03-01 17:47:53 +00:00
public:
Client(StorageReplicatedMergeTree & storage_);
2016-03-01 17:47:53 +00:00
Client(const Client &) = delete;
Client & operator=(const Client &) = delete;
2016-03-01 17:47:53 +00:00
void setCancellationHook(CancellationHook cancellation_hook_);
2016-03-01 17:47:53 +00:00
bool send(const std::string & part_name, size_t shard_no,
const InterserverIOEndpointLocation & to_location);
2016-03-01 17:47:53 +00:00
void cancel() { is_cancelled = true; }
2016-01-28 01:00:27 +00:00
private:
MergeTreeData::DataPartPtr findShardedPart(const std::string & name, size_t shard_no);
void abortIfRequested();
2016-03-01 17:47:53 +00:00
private:
StorageReplicatedMergeTree & storage;
MergeTreeData & data;
CancellationHook cancellation_hook;
std::atomic<bool> is_cancelled{false};
Logger * log = &Logger::get("ShardedPartitionUploader::Client");
2016-01-28 01:00:27 +00:00
};
}
}