Perform query classifier initialization implicitly
The setting up and the initialization of the query classifier has now been separated. The gateway explicitly sets up the query classifier (i.e. chooses which one to use and what arguments to provide), but the actual initialization is performed as part of the general module initialization.
This commit is contained in:
@ -976,26 +976,17 @@ void worker_thread_main(void* arg)
|
||||
{
|
||||
if (modules_thread_init())
|
||||
{
|
||||
if (qc_thread_init())
|
||||
/** Init mysql thread context for use with a mysql handle and a parser */
|
||||
if (mysql_thread_init() == 0)
|
||||
{
|
||||
/** Init mysql thread context for use with a mysql handle and a parser */
|
||||
if (mysql_thread_init() == 0)
|
||||
{
|
||||
poll_waitevents(arg);
|
||||
poll_waitevents(arg);
|
||||
|
||||
/** Release mysql thread context */
|
||||
mysql_thread_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Could not perform thread initialization for MySQL. Exiting thread.");
|
||||
}
|
||||
|
||||
qc_thread_end();
|
||||
/** Release mysql thread context */
|
||||
mysql_thread_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Could not perform thread initialization for query classifier. Exiting thread.");
|
||||
MXS_ERROR("Could not perform thread initialization for MySQL. Exiting thread.");
|
||||
}
|
||||
|
||||
modules_thread_finish();
|
||||
@ -1875,7 +1866,7 @@ int main(int argc, char **argv)
|
||||
cnf = config_get_global_options();
|
||||
ss_dassert(cnf);
|
||||
|
||||
if (!qc_init(cnf->qc_name, cnf->qc_args))
|
||||
if (!qc_setup(cnf->qc_name, cnf->qc_args))
|
||||
{
|
||||
const char* logerr = "Failed to initialise query classifier library.";
|
||||
print_log_n_stderr(true, true, logerr, logerr, eno);
|
||||
@ -2088,8 +2079,6 @@ int main(int argc, char **argv)
|
||||
/** Release mysql thread context*/
|
||||
mysql_thread_end();
|
||||
|
||||
qc_end();
|
||||
|
||||
utils_end();
|
||||
cleanup_process_datadir();
|
||||
MXS_NOTICE("MaxScale shutdown completed.");
|
||||
|
@ -38,7 +38,7 @@ static const char default_qc_name[] = "qc_sqlite";
|
||||
static QUERY_CLASSIFIER* classifier;
|
||||
|
||||
|
||||
bool qc_init(const char* plugin_name, const char* plugin_args)
|
||||
bool qc_setup(const char* plugin_name, const char* plugin_args)
|
||||
{
|
||||
QC_TRACE();
|
||||
ss_dassert(!classifier);
|
||||
@ -56,21 +56,30 @@ bool qc_init(const char* plugin_name, const char* plugin_args)
|
||||
{
|
||||
success = classifier->qc_setup(plugin_args);
|
||||
|
||||
if (success)
|
||||
if (!success)
|
||||
{
|
||||
success = classifier->qc_init();
|
||||
qc_unload(classifier);
|
||||
classifier = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void qc_end(void)
|
||||
bool qc_process_init(void)
|
||||
{
|
||||
QC_TRACE();
|
||||
ss_dassert(classifier);
|
||||
|
||||
classifier->qc_end();
|
||||
return classifier->qc_process_init() == 0;
|
||||
}
|
||||
|
||||
void qc_process_end(void)
|
||||
{
|
||||
QC_TRACE();
|
||||
ss_dassert(classifier);
|
||||
|
||||
classifier->qc_process_end();
|
||||
classifier = NULL;
|
||||
}
|
||||
|
||||
@ -101,7 +110,7 @@ bool qc_thread_init(void)
|
||||
QC_TRACE();
|
||||
ss_dassert(classifier);
|
||||
|
||||
return classifier->qc_thread_init();
|
||||
return classifier->qc_thread_init() == 0;
|
||||
}
|
||||
|
||||
void qc_thread_end(void)
|
||||
|
@ -127,7 +127,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
|
||||
{
|
||||
if (qc_init(NULL, NULL))
|
||||
if (qc_setup(NULL, NULL) && qc_process_init())
|
||||
{
|
||||
const char* zModule = argv[1];
|
||||
|
||||
@ -157,6 +157,8 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
cerr << "error: Could not initialize factory." << endl;
|
||||
}
|
||||
|
||||
qc_process_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -237,10 +237,12 @@ int main()
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
|
||||
{
|
||||
set_libdir(MXS_STRDUP_A("../../../../../query_classifier/qc_sqlite/"));
|
||||
if (qc_init("qc_sqlite", ""))
|
||||
if (qc_setup("qc_sqlite", "") && qc_process_init())
|
||||
{
|
||||
set_libdir(MXS_STRDUP_A("../"));
|
||||
rc = test();
|
||||
|
||||
qc_process_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ int TestStorage::run(int argc, char** argv)
|
||||
{
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
|
||||
{
|
||||
if (qc_init(NULL, NULL))
|
||||
if (qc_setup(NULL, NULL) && qc_process_init())
|
||||
{
|
||||
const char* zModule = NULL;
|
||||
size_t threads = m_threads;
|
||||
|
Reference in New Issue
Block a user