mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
cluster discovery: versioning for format of data stored in zk
This commit is contained in:
parent
d3b1058c40
commit
4f8a9cc539
@ -385,9 +385,20 @@ bool ClusterDiscovery::NodeInfo::parse(const String & data, NodeInfo & result)
|
|||||||
Poco::JSON::Parser parser;
|
Poco::JSON::Parser parser;
|
||||||
auto json = parser.parse(data).extract<Poco::JSON::Object::Ptr>();
|
auto json = parser.parse(data).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
|
||||||
result.address = json->getValue<std::string>("address");
|
size_t ver = json->optValue<size_t>("version", data_ver);
|
||||||
result.secure = json->optValue<bool>("secure", false);
|
if (ver == data_ver)
|
||||||
result.shard_id = json->optValue<size_t>("shard_id", 0);
|
{
|
||||||
|
result.address = json->getValue<std::string>("address");
|
||||||
|
result.secure = json->optValue<bool>("secure", false);
|
||||||
|
result.shard_id = json->optValue<size_t>("shard_id", 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_ERROR(
|
||||||
|
&Poco::Logger::get("ClusterDiscovery"),
|
||||||
|
"Unsupported version '{}' of data in zk node '{}'",
|
||||||
|
ver, data.size() < 1024 ? data : "[data too long]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Poco::Exception & e)
|
catch (Poco::Exception & e)
|
||||||
{
|
{
|
||||||
@ -403,6 +414,7 @@ bool ClusterDiscovery::NodeInfo::parse(const String & data, NodeInfo & result)
|
|||||||
String ClusterDiscovery::NodeInfo::serialize() const
|
String ClusterDiscovery::NodeInfo::serialize() const
|
||||||
{
|
{
|
||||||
Poco::JSON::Object json;
|
Poco::JSON::Object json;
|
||||||
|
json.set("version", data_ver);
|
||||||
json.set("address", address);
|
json.set("address", address);
|
||||||
json.set("shard_id", shard_id);
|
json.set("shard_id", shard_id);
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
struct NodeInfo
|
struct NodeInfo
|
||||||
{
|
{
|
||||||
|
/// versioning for format of data stored in zk
|
||||||
|
static constexpr size_t data_ver = 1;
|
||||||
|
|
||||||
/// host:port
|
/// host:port
|
||||||
String address;
|
String address;
|
||||||
/// is secure tcp port user
|
/// is secure tcp port user
|
||||||
|
Loading…
Reference in New Issue
Block a user