2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/ReadBuffer.h>
|
|
|
|
#include <IO/ReadBufferFromString.h>
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <IO/WriteBufferFromString.h>
|
|
|
|
#include <IO/Operators.h>
|
2015-10-02 18:33:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/// Lets you know where to send requests to get to the replica.
|
2015-10-02 18:33:46 +00:00
|
|
|
|
|
|
|
struct ReplicatedMergeTreeAddress
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
String host;
|
|
|
|
UInt16 replication_port;
|
|
|
|
UInt16 queries_port;
|
|
|
|
String database;
|
|
|
|
String table;
|
2015-10-02 18:33:46 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ReplicatedMergeTreeAddress() {}
|
|
|
|
ReplicatedMergeTreeAddress(const String & str)
|
|
|
|
{
|
|
|
|
fromString(str);
|
|
|
|
}
|
2015-10-02 18:33:46 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void writeText(WriteBuffer & out) const
|
|
|
|
{
|
|
|
|
out
|
|
|
|
<< "host: " << escape << host << '\n'
|
|
|
|
<< "port: " << replication_port << '\n'
|
|
|
|
<< "tcp_port: " << queries_port << '\n'
|
|
|
|
<< "database: " << escape << database << '\n'
|
|
|
|
<< "table: " << escape << table << '\n';
|
|
|
|
}
|
2015-10-02 18:33:46 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void readText(ReadBuffer & in)
|
|
|
|
{
|
|
|
|
in
|
|
|
|
>> "host: " >> escape >> host >> "\n"
|
|
|
|
>> "port: " >> replication_port >> "\n"
|
|
|
|
>> "tcp_port: " >> queries_port >> "\n"
|
|
|
|
>> "database: " >> escape >> database >> "\n"
|
|
|
|
>> "table: " >> escape >> table >> "\n";
|
|
|
|
}
|
2015-10-02 18:33:46 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String toString() const
|
|
|
|
{
|
2017-07-31 21:39:24 +00:00
|
|
|
WriteBufferFromOwnString out;
|
|
|
|
writeText(out);
|
|
|
|
return out.str();
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2015-10-02 18:33:46 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void fromString(const String & str)
|
|
|
|
{
|
|
|
|
ReadBufferFromString in(str);
|
|
|
|
readText(in);
|
|
|
|
}
|
2015-10-02 18:33:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|