MXS-1777: Initial version of routing based on query response time.

The main piece of code, slave selection (backend_cmp_response_time), uses the available
method of pair-wise comparison of slaves. This will be changed to selection using all
available slaves, along with removal of hard coded values.
This commit is contained in:
Niclas Antti
2018-07-27 13:07:18 +03:00
parent 1e6509423a
commit 6351ab9c73
10 changed files with 250 additions and 10 deletions

View File

@ -29,6 +29,7 @@
#include <list>
#include <mutex>
#include <sstream>
#include <mutex>
#include <maxbase/stopwatch.hh>
@ -1508,9 +1509,15 @@ bool server_set_disk_space_threshold(SERVER *server, const char *disk_space_thre
return rv;
}
namespace
{
// Only need to prevent multiple writes, as long as only the average is read where
// needed (and not in combination with num_samples), which is by design.
std::mutex add_response_mutex;
}
void server_add_response_average(SERVER *server, double ave, int num_samples)
{
spinlock_acquire(&server->lock);
std::lock_guard<std::mutex> lock(add_response_mutex);
server->response_time->add(ave, num_samples);
spinlock_release(&server->lock);
}