MXS-2363 Implement /v1/maxscale/query_classifier/cache
That URL will now return information about the statements in the query classifier cache. The information is collected using the same map in a serial manner from all routing workers (that each have their own cache). Since all caches will contains the same statements, collecting the information in a serial manner means that the overall memory consumption will be lower than what it would be if the information was collected in parallel.
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <maxbase/jansson.h>
|
||||
#include <maxscale/buffer.hh>
|
||||
@ -172,6 +173,17 @@ struct QC_STMT_INFO
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* QC_STMT_RESULT contains limited information about a particular
|
||||
* statement.
|
||||
*/
|
||||
struct QC_STMT_RESULT
|
||||
{
|
||||
qc_parse_result_t status;
|
||||
uint32_t type_mask;
|
||||
qc_query_op_t op;
|
||||
};
|
||||
|
||||
/**
|
||||
* QUERY_CLASSIFIER defines the object a query classifier plugin must
|
||||
* implement and return.
|
||||
@ -439,6 +451,15 @@ struct QUERY_CLASSIFIER
|
||||
* @param info The info to be closed.
|
||||
*/
|
||||
void (* qc_info_close)(QC_STMT_INFO* info);
|
||||
|
||||
/**
|
||||
* Get result from info.
|
||||
*
|
||||
* @param The info whose result should be returned.
|
||||
*
|
||||
* @return The result of the provided info.
|
||||
*/
|
||||
QC_STMT_RESULT (*qc_get_result_from_info)(const QC_STMT_INFO* info);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -949,3 +970,23 @@ json_t* qc_get_cache_stats_as_json();
|
||||
* @return The corresponding string.
|
||||
*/
|
||||
const char* qc_result_to_string(qc_parse_result_t result);
|
||||
|
||||
/**
|
||||
* Public interface to query classifier cache state.
|
||||
*/
|
||||
struct QC_CACHE_ENTRY
|
||||
{
|
||||
int64_t hits;
|
||||
QC_STMT_RESULT result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Obtain query classifier cache information for the @b calling thread.
|
||||
*
|
||||
* @param state Map where information is added.
|
||||
*
|
||||
* @note Calling with a non-empty @c state means that a cumulative result
|
||||
* will be obtained, that is, the hits of a particular key will
|
||||
* be added the hits of that key if it already is in the map.
|
||||
*/
|
||||
void qc_get_cache_state(std::map<std::string, QC_CACHE_ENTRY>& state);
|
||||
|
||||
Reference in New Issue
Block a user