MXS-1992 RoutingWorker provides access to QC stats

This will be used in the context of MaxAdmin and MaxCtrl.
This commit is contained in:
Johan Wikman 2018-08-02 15:54:07 +03:00
parent c302268ca3
commit b76cdc944b
2 changed files with 38 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include <unordered_map>
#include <maxscale/query_classifier.h>
#include <maxscale/routingworker.h>
#include <maxscale/worker.hh>
@ -354,6 +355,13 @@ public:
}
}
/**
* Provides QC statistics of all workers
*
* @param all_stats Vector that on return will contain the statistics of all workers.
*/
static void get_all_qc_stats(std::vector<QC_CACHE_STATS>& all_stats);
private:
const int m_id; /*< The id of the worker. */
SessionsById m_sessions; /*< A mapping of session_id->MXS_SESSION. The map

View File

@ -868,6 +868,36 @@ int64_t RoutingWorker::get_one_statistic(POLL_STAT what)
return rv;
}
//static
void RoutingWorker::get_all_qc_stats(std::vector<QC_CACHE_STATS>& all_stats)
{
class Task : public mxs::Worker::Task
{
public:
Task(std::vector<QC_CACHE_STATS>* pAll_stats)
: m_all_stats(*pAll_stats)
{
m_all_stats.resize(config_threadcount());
}
void execute(mxs::Worker& worker)
{
int id = mxs::RoutingWorker::get_current_id();
ss_dassert(id >= 0);
QC_CACHE_STATS& stats = m_all_stats[id];
qc_get_cache_stats(&stats);
}
private:
std::vector<QC_CACHE_STATS>& m_all_stats;
};
Task task(&all_stats);
mxs::RoutingWorker::execute_concurrently(task);
}
}
size_t mxs_rworker_broadcast_message(uint32_t msg_id, intptr_t arg1, intptr_t arg2)