MXS-1777 Refactor selection.

This commit refactors slave selection. The compare is still pair-wise but isolated into a small run_comparison() function. The function get_slave_candidate() is used when new connections are created, which I both moved and modified (had to move due to scoping), so diff is off.
The slave selection for routing:  get_slave_backend() now has the filtering logic from old get_slave_backend() and compare_backends(), the latter of which is removed.

Backend functions mostly take shared_ptr<SRWBackend> in various forms (as is, const ref, in a container). Ideally the shared_ptr would be used only to where it is really needed, and either naked ptrs or references to RWBackend would be used. This refactor does not address that issue, but compounds it by using even deeper shared_ptr structures. Fixing that in a future commit.
This commit is contained in:
Niclas Antti
2018-07-30 18:12:56 +03:00
parent d52885d68d
commit de6ad542c4
6 changed files with 306 additions and 243 deletions

View File

@ -49,7 +49,7 @@ void ResponseStat::query_ended()
if (++m_sample_count == m_num_filter_samples)
{
std::sort(begin(m_samples), end(m_samples));
std::sort(m_samples.begin(), m_samples.end());
maxbase::Duration new_sample = m_samples[m_num_filter_samples / 2];
m_average.add(std::chrono::duration<double>(new_sample).count());
m_sample_count = 0;