bool BlacklistPolicy::is_valid_host(const Host::Ptr& host) const { const std::string& host_address = host->address().to_string(false); for (ContactPointList::const_iterator it = hosts_.begin(), end = hosts_.end(); it != end; ++it) { if (host_address.compare(*it) == 0) { return false; } } return true; }
SharedRefPtr<Host> HostTargetingPolicy::HostTargetingQueryPlan::compute_next() { if (first_) { first_ = false; return preferred_host_; } else { Host::Ptr next = child_plan_->compute_next(); if (next && next->address() == preferred_host_->address()) { return child_plan_->compute_next(); } return next; } }
void Session::on_remove(Host::Ptr host) { host->set_down(); config().load_balancing_policy()->on_remove(host); { // Lock hosts ScopedMutex l(&hosts_mutex_); hosts_.erase(host->address()); } for (IOWorkerVec::iterator it = io_workers_.begin(), end = io_workers_.end(); it != end; ++it) { (*it)->remove_pool_async(host, true); } }
void Session::on_add(Host::Ptr host, bool is_initial_connection) { host->set_up(); // Set the host as up immediately (to avoid duplicate actions) #if UV_VERSION_MAJOR >= 1 if (config_.use_hostname_resolution() && host->hostname().empty()) { NameResolver::resolve(loop(), host->address(), ResolveNameData(this, host, is_initial_connection), on_add_resolve_name, config_.resolve_timeout_ms()); } else { #endif // There won't be any prepared statements on the initial connection if (is_initial_connection || !prepare_host(host, on_prepare_host_add)) { internal_on_add(host, is_initial_connection); } #if UV_VERSION_MAJOR >= 1 } #endif }