From 60a51b3d73765ab63b49a9cdaed03cf25467e5b8 Mon Sep 17 00:00:00 2001 From: iprunache Date: Fri, 19 Feb 2016 18:07:25 +0200 Subject: [PATCH] T87 added mock command --- include/proxysql_admin.h | 1 + lib/ProxySQL_Admin.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 178825046..925a246fc 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -115,6 +115,7 @@ class ProxySQL_Admin { void flush_mysql_query_rules__from_disk_to_memory(); void load_mysql_servers_to_runtime(); void save_mysql_servers_from_runtime(); + bool save_mysql_servers_to_cluster(); char * load_mysql_query_rules_to_runtime(); void save_mysql_query_rules_from_runtime(); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 6c21ba404..c5278dea6 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -787,6 +787,18 @@ bool admin_handler_command_load_or_save(char *query_no_space, unsigned int query SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL); return false; } + + if (query_no_space_length==strlen("SAVE MYSQL SERVERS TO CLUSTER") && !strncasecmp("SAVE MYSQL SERVERS TO CLUSTER", query_no_space, query_no_space_length)) { + proxy_info("Received %s command\n", query_no_space); + ProxySQL_Admin *SPA=(ProxySQL_Admin *)pa; + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Pushed mysql servers from RUNTIME to cluster\n"); + bool success = SPA->save_mysql_servers_to_cluster(); + if (success) { + SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL); + } else { + SPA->send_MySQL_ERR(&sess->client_myds->myprot, NULL); + } + } } // Will add a new command here to push mysql query rule runtime config to cluster. @@ -3265,6 +3277,14 @@ void ProxySQL_Admin::load_mysql_servers_to_runtime() { } +// Gets a copy of the runtime mysql servers config and passes is to an external script for distribution to other +// ProxySQL instances. +bool ProxySQL_Admin::save_mysql_servers_to_cluster() { + // TODO read runtime mysql servers config and pass it to external script for distribution + // TODO return an error message instead of bool + return true; +} + char * ProxySQL_Admin::load_mysql_query_rules_to_runtime() { char *error=NULL; int cols=0;