Enhance StopWatch

Clean up, comments and enhancements. StopWatch lap() didn't mean lap-time, but elapsed time. Changed meaning to lap-time and added split() for split-time.
This commit is contained in:
Niclas Antti
2018-09-26 16:24:45 +03:00
parent bb8245d2c1
commit c65edd1298
5 changed files with 104 additions and 35 deletions

View File

@ -84,14 +84,14 @@ int ThrottleSession::real_routeQuery(GWBUF* buffer, bool is_delayed)
}
else if (m_state == State::THROTTLING)
{
if (m_last_sample.lap() > m_filter.config().continuous_duration)
if (m_last_sample.split() > m_filter.config().continuous_duration)
{
m_state = State::MEASURING;
MXS_INFO("Query throttling stopped session %ld user %s",
m_pSession->ses_id,
m_pSession->client_dcb->user);
}
else if (m_first_sample.lap() > m_filter.config().throttling_duration)
else if (m_first_sample.split() > m_filter.config().throttling_duration)
{
MXS_NOTICE("Query throttling Session %ld user %s, throttling limit reached. Disconnect.",
m_pSession->ses_id,

View File

@ -195,7 +195,7 @@ bool MariaDBServer::execute_cmd_time_limit(const std::string& cmd, maxbase::Dura
cmd_success = execute_cmd_no_retry(cmd, &error_msg, &errornum);
// Check if there is time to retry.
Duration time_remaining = time_limit - timer.lap();
Duration time_remaining = time_limit - timer.split();
keep_trying = (mxs_mysql_is_net_error(errornum) && (time_remaining.secs() > 0));
if (!cmd_success)
{
@ -1442,12 +1442,12 @@ bool MariaDBServer::promote_v2(ClusterOperation* op)
// Helper function for stopping a slave connection and setting error.
auto stop_slave_helper = [this, &timer, &stop_slave_error, op, error_out](const string& conn_name) {
if (!stop_slave_conn(conn_name, StopMode::RESET_ALL, op->time_remaining, error_out))
{
stop_slave_error = true;
}
op->time_remaining -= timer.restart();
};
if (!stop_slave_conn(conn_name, StopMode::RESET_ALL, op->time_remaining, error_out))
{
stop_slave_error = true;
}
op->time_remaining -= timer.restart();
};
if (op->type == OperationType::SWITCHOVER)
{