dbms: Server: queries with several replicas: development [#METR-14410]

This commit is contained in:
Alexey Arno 2015-01-15 18:05:03 +03:00
parent 63b254555a
commit 74db087fa6
4 changed files with 27 additions and 6 deletions

View File

@ -44,6 +44,10 @@ namespace DB
std::string dumpAddresses() const;
size_t size() const;
void sendExternalTablesData(std::vector<ExternalTablesData> & data);
private:
using ConnectionHash = std::unordered_map<int, ConnectionInfo>;

View File

@ -273,6 +273,7 @@ namespace ErrorCodes
CANNOT_COMPILE_CODE,
NO_AVAILABLE_REPLICA,
UNEXPECTED_REPLICA,
MISMATCH_REPLICAS_DATA_SOURCES,
POCO_EXCEPTION = 1000,
STD_EXCEPTION,

View File

@ -122,7 +122,7 @@ protected:
/// Отправить на удаленные сервера все временные таблицы
void sendExternalTables()
{
size_t count = use_many_replicas ? shard_replicas->size() : 1;
size_t count = use_many_replicas ? replicas_connections->size() : 1;
std::vector<ExternalTablesData> instances;
instances.reserve(count);
@ -145,12 +145,9 @@ protected:
}
if (use_many_replicas)
{
/// XXX Отправить res по всем соединениям.
//replicas_connections->sendExternalTablesData(res);
}
replicas_connections->sendExternalTablesData(instances);
else
connection->sendExternalTablesData(res);
connection->sendExternalTablesData(instances[0]);
}
Block readImpl() override

View File

@ -236,4 +236,23 @@ namespace DB
return os.str();
}
size_t ReplicasConnections::size() const
{
return connection_hash.size();
}
void ReplicasConnections::sendExternalTablesData(std::vector<ExternalTablesData> & data)
{
if (data.size() != connection_hash.size())
throw Exception("Mismatch between replicas and data sources", ErrorCodes::MISMATCH_REPLICAS_DATA_SOURCES);
auto it = data.begin();
for (auto & e : connection_hash)
{
Connection * connection = e.second.connection;
connection->sendExternalTablesData(*it);
++it;
}
}
}