support passing fqdn to register cluster node in keeper

This commit is contained in:
LiuYangkuan 2023-05-20 12:41:48 +08:00
parent 4e3188126f
commit 6e80537ab6
2 changed files with 19 additions and 4 deletions

View File

@ -125,10 +125,12 @@ ClusterDiscovery::ClusterDiscovery(
ClusterInfo(
/* name_= */ key,
/* zk_root_= */ config.getString(prefix + ".path"),
/* host_name= */ config.getString(prefix + ".my_hostname", getFQDNOrHostName()),
/* port= */ context->getTCPPort(),
/* secure= */ config.getBool(prefix + ".secure", false),
/* shard_id= */ config.getUInt(prefix + ".shard", 0),
/* observer_mode= */ ConfigHelper::getBool(config, prefix + ".observer")
/* observer_mode= */ ConfigHelper::getBool(config, prefix + ".observer"),
/* invisible_mode= */ ConfigHelper::getBool(config, prefix + ".invisible")
)
);
}
@ -294,6 +296,12 @@ bool ClusterDiscovery::updateCluster(ClusterInfo & cluster_info)
return false;
}
if (cluster_info.current_cluster_is_invisible)
{
LOG_DEBUG(log, "cluster '{}' is invisible!", cluster_info.name);
return true;
}
if (!needUpdate(node_uuids, nodes_info))
{
LOG_DEBUG(log, "No update required for cluster '{}'", cluster_info.name);

View File

@ -3,7 +3,6 @@
#include <Common/ConcurrentBoundedQueue.h>
#include <Common/ThreadPool.h>
#include <Common/ZooKeeper/Common.h>
#include <base/getFQDNOrHostName.h>
#include <Interpreters/Cluster.h>
#include <Poco/Logger.h>
@ -78,16 +77,24 @@ private:
/// Current node may not belong to cluster, to be just an observer.
bool current_node_is_observer = false;
/// For internal management need.
/// Is it designed that when deploying multiple compute groups,
/// they are mutually invisible to each other.
bool current_cluster_is_invisible = false;
explicit ClusterInfo(const String & name_,
const String & zk_root_,
const String & host_name,
UInt16 port,
bool secure,
size_t shard_id,
bool observer_mode)
bool observer_mode,
bool invisible)
: name(name_)
, zk_root(zk_root_)
, current_node(getFQDNOrHostName() + ":" + toString(port), secure, shard_id)
, current_node(host_name + ":" + toString(port), secure, shard_id)
, current_node_is_observer(observer_mode)
, current_cluster_is_invisible(invisible)
{
}
};