96 if (
data_.empty())
return true;
99 assert(!
list.empty());
101 unsigned long sum = 0;
104 const unsigned long draw = (std::rand() * 1UL * sum) / RAND_MAX;
106 dns_entry_list_t::const_iterator iter =
list.cbegin();
107 while (iter->weight_sum() < draw) iter++;
108 assert(iter !=
list.end());
Definition: dns_srv_data.h:57
unsigned long weight_sum_
Definition: dns_srv_data.h:60
Dns_entry(const std::string &host, unsigned port, unsigned weight)
Definition: dns_srv_data.h:65
unsigned port() const
Definition: dns_srv_data.h:68
void add_weight_sum(unsigned long &weight_sum)
Definition: dns_srv_data.h:71
unsigned weight_
Definition: dns_srv_data.h:59
std::string host_
Definition: dns_srv_data.h:58
std::string host() const
Definition: dns_srv_data.h:69
unsigned port_
Definition: dns_srv_data.h:59
unsigned long weight_sum() const
Definition: dns_srv_data.h:70
A RFC2782 compliant SRV records storage.
Definition: dns_srv_data.h:56
std::list< Dns_entry > dns_entry_list_t
Definition: dns_srv_data.h:75
bool pop_next(std::string &host, unsigned &port)
Definition: dns_srv_data.h:95
void add(const std::string &host, unsigned port, unsigned priority, unsigned weight)
Definition: dns_srv_data.h:81
dns_entry_data_t data_
Definition: dns_srv_data.h:77
std::map< unsigned, Dns_srv_data::dns_entry_list_t > dns_entry_data_t
Definition: dns_srv_data.h:76
void clear()
Definition: dns_srv_data.h:80
const char * host
Definition: mysqladmin.cc:65
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
required uint64 weight
Definition: replication_asynchronous_connection_failover.proto:35
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
required uint32 priority
Definition: replication_group_member_actions.proto:35
static ORDER * elt(const SQL_I_List< ORDER > &list, uint i)
Return element with index i from list.
Definition: window.cc:231