MXS-1777: Add an EMAverage to the server struct, and a new slave selection criteria.
This is to support calculating the average from a session, and the slave selection criteria to be able to route based on averages. This commit, like the next one, have TODOs which you should feel free to comment on. Undecided things.
This commit is contained in:
@ -3608,6 +3608,11 @@ int create_new_server(CONFIG_CONTEXT *obj)
|
||||
}
|
||||
}
|
||||
|
||||
// nantti, TODO. Decide whether to expose some of this in config, or if the values
|
||||
// can be calculated at runtime. The "500" or sample_max affects how often a
|
||||
// session should updates this stat. sample_max should be slightly lower than max sample
|
||||
// rate (which is less than qps due to the noise filter).
|
||||
server->response_time = new (std::nothrow) maxbase::EMAverage(0.04, 0.35, 500);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4615,7 +4620,7 @@ bool get_suffixed_size(const char* value, uint64_t* dest)
|
||||
}
|
||||
|
||||
bool config_parse_disk_space_threshold(MxsDiskSpaceThreshold* pDisk_space_threshold,
|
||||
const char* zDisk_space_threshold)
|
||||
const char* zDisk_space_threshold)
|
||||
{
|
||||
mxb_assert(pDisk_space_threshold);
|
||||
mxb_assert(zDisk_space_threshold);
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
|
||||
#include <maxbase/stopwatch.hh>
|
||||
|
||||
#include <maxscale/config.h>
|
||||
#include <maxscale/service.h>
|
||||
@ -228,6 +231,7 @@ void server_free(Server* server)
|
||||
}
|
||||
|
||||
delete server->disk_space_threshold;
|
||||
delete server->response_time;
|
||||
delete server;
|
||||
}
|
||||
|
||||
@ -551,6 +555,18 @@ dprintServer(DCB *dcb, const SERVER *server)
|
||||
dcb_printf(dcb, "\tCurrent no. of conns: %d\n", server->stats.n_current);
|
||||
dcb_printf(dcb, "\tCurrent no. of operations: %d\n", server->stats.n_current_ops);
|
||||
dcb_printf(dcb, "\tNumber of routed packets: %lu\n", server->stats.packets);
|
||||
std::ostringstream ave_os;
|
||||
if (server->response_time->num_samples())
|
||||
{
|
||||
maxbase::Duration dur(server->response_time->average());
|
||||
ave_os << dur;
|
||||
}
|
||||
else
|
||||
{
|
||||
ave_os << "not available";
|
||||
}
|
||||
dcb_printf(dcb, "\tAverage response time: %s\n", ave_os.str().c_str());
|
||||
|
||||
if (server->persistpoolmax)
|
||||
{
|
||||
dcb_printf(dcb, "\tPersistent pool size: %d\n", server->stats.n_persistent);
|
||||
@ -1491,3 +1507,10 @@ bool server_set_disk_space_threshold(SERVER *server, const char *disk_space_thre
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void server_add_response_average(SERVER *server, double ave, int num_samples)
|
||||
{
|
||||
spinlock_acquire(&server->lock);
|
||||
server->response_time->add(ave, num_samples);
|
||||
spinlock_release(&server->lock);
|
||||
}
|
||||
|
Reference in New Issue
Block a user