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-07-25 11:38:46 +00:00
|
|
|
|
MergeTreeData::DataPartPtr part = data.getPartIfExists(name);
|
|
|
|
|
if (part)
|
2014-04-03 11:48:28 +00:00
|
|
|
|
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-10-13 17:28:59 +00:00
|
|
|
|
/// Скачивает кусок в tmp_директорию. Если to_detached - скачивает в директорию detached.
|
2014-04-02 13:45:39 +00:00
|
|
|
|
MergeTreeData::MutableDataPartPtr fetchPart(
|
|
|
|
|
const String & part_name,
|
|
|
|
|
const String & replica_path,
|
|
|
|
|
const String & host,
|
2014-10-13 17:28:59 +00:00
|
|
|
|
int port,
|
|
|
|
|
bool to_detached = false);
|
2014-04-02 13:45:39 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
MergeTreeData & data;
|
|
|
|
|
|
|
|
|
|
Logger * log;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|