void ClusterTopologyMonitor::init_node_monitors()

in src/failover/cluster_topology_monitor.cc [365:393]


void ClusterTopologyMonitor::init_node_monitors() {
    node_threads_stop_.store(false);
    {
        std::lock_guard<std::mutex> writer_hdbc_lock(node_threads_writer_hdbc_mutex_);
        dbc_clean_up(node_threads_writer_hdbc_);
    }
    {
        std::lock_guard<std::mutex> reader_hdbc_lock(node_threads_reader_hdbc_mutex_);
        dbc_clean_up(node_threads_reader_hdbc_);
    }
    node_threads_writer_host_info_ = nullptr;
    node_threads_latest_topology_ = nullptr;

    std::vector<HostInfo> hosts = topology_map_->Get(cluster_id_);
    if (hosts.empty()) {
        hosts = open_any_conn_get_hosts();
    }

    if (!hosts.empty() && !is_writer_connection_.load()) {
        auto end = node_monitoring_threads_.end();
        for (const HostInfo& hi : hosts) {
            std::string host_id = hi.GetHost();
            if (node_monitoring_threads_.find(host_id) == end) {
                node_monitoring_threads_[host_id] =
                    std::make_shared<NodeMonitoringThread>(this, std::make_shared<HostInfo>(hi), main_writer_host_info_);
            }
        }
    }
}