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

@ -382,6 +382,25 @@ mxs::SRWBackend get_root_master(const mxs::SRWBackendList& backends);
*/
std::pair<int, int> get_slave_counts(mxs::SRWBackendList& backends, mxs::SRWBackend& master);
/* TODO, hopefully temporary */
using BackendSPtrVec = std::vector<mxs::SRWBackend*>;
/**
* Find the best backend based on categorizing the servers, and then applying
* selection criteria to the best category.
*
* @param backends: vector of SRWBackend
* @param sc: which select_criteria_t to use
* @param master_accept_reads: NOTE: even if this is false, in some cases a master can
* still be selected for reads.
*
* @return Valid iterator into argument backends, or end(backends) if empty
*/
BackendSPtrVec::const_iterator find_best_backend(const BackendSPtrVec& backends,
select_criteria_t sc,
bool masters_accept_reads);
/*
* The following are implemented in rwsplit_tmp_table_multi.c
*/