std::vector ClusterTopologyMonitor::ForceRefresh()

in src/failover/cluster_topology_monitor.cc [79:103]


std::vector<HostInfo> ClusterTopologyMonitor::ForceRefresh(const bool verify_writer, const uint32_t timeout_ms) {
    std::chrono::steady_clock::time_point now =
        std::chrono::steady_clock::time_point(std::chrono::high_resolution_clock::now().time_since_epoch());
    std::chrono::steady_clock::time_point epoch = std::chrono::steady_clock::time_point{};
    std::chrono::steady_clock::time_point ignore_topology = ignore_topology_request_end_ms_.load();
    if (ignore_topology != epoch && now > ignore_topology) {
        // Previous failover has just completed. We can use results of it without triggering a new topology update.
        std::vector<HostInfo> hosts = topology_map_->Get(cluster_id_);
        if (!hosts.empty()) {
            return hosts;
        }
    }

    if (verify_writer) {
        std::lock_guard hdbc_lock(hdbc_mutex_);
        dbc_clean_up(main_hdbc_);
        is_writer_connection_.store(false);
    }

    std::vector<HostInfo> hosts = WaitForTopologyUpdate(timeout_ms);
    if (!hosts.empty()) {
        topology_map_->Put(cluster_id_, hosts);
    }
    return hosts;
}