ClickHouse/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreePartsExchange.h

57 lines
1.4 KiB
C
Raw Normal View History

2014-04-02 13:45:39 +00:00
#pragma once
#include <DB/Interpreters/InterserverIOHandler.h>
#include <DB/Storages/MergeTree/MergeTreeData.h>
#include <DB/IO/ReadBufferFromHTTP.h>
#include <DB/IO/HashingWriteBuffer.h>
#include <DB/IO/copyData.h>
namespace DB
{
2014-07-22 13:49:52 +00:00
class StorageReplicatedMergeTree;
2014-04-02 13:45:39 +00:00
class ReplicatedMergeTreePartsServer : public InterserverIOEndpoint
{
public:
2014-07-22 13:49:52 +00:00
ReplicatedMergeTreePartsServer(MergeTreeData & data_, StorageReplicatedMergeTree & storage_) : data(data_),
storage(storage_), log(&Logger::get(data.getLogName() + " (Replicated PartsServer)")) {}
2014-04-02 13:45:39 +00:00
2014-07-22 13:49:52 +00:00
void processQuery(const Poco::Net::HTMLForm & params, WriteBuffer & out) override;
2014-04-02 13:45:39 +00:00
private:
MergeTreeData & data;
2014-07-22 13:49:52 +00:00
StorageReplicatedMergeTree & storage;
2014-04-02 13:45:39 +00:00
Logger * log;
MergeTreeData::DataPartPtr findPart(const String & name)
{
2014-04-09 15:52:47 +00:00
MergeTreeData::DataPartPtr part = data.getContainingPart(name, true);
2014-04-03 11:48:28 +00:00
if (part && part->name == name)
return part;
2014-04-02 13:45:39 +00:00
throw Exception("No part " + name + " in table");
}
};
class ReplicatedMergeTreePartsFetcher
{
public:
ReplicatedMergeTreePartsFetcher(MergeTreeData & data_) : data(data_), log(&Logger::get("ReplicatedMergeTreePartsFetcher")) {}
2014-04-03 11:48:28 +00:00
/// Скачивает кусок в tmp_директорию.
2014-04-02 13:45:39 +00:00
MergeTreeData::MutableDataPartPtr fetchPart(
const String & part_name,
const String & replica_path,
const String & host,
2014-07-22 13:49:52 +00:00
int port);
2014-04-02 13:45:39 +00:00
private:
MergeTreeData & data;
Logger * log;
};
}