Add azure_enabled

pull/2185/head
Yiyao Jiang 7 years ago
parent a3b14fcb57
commit 63af8f3f52

@ -335,6 +335,7 @@ class MySQL_Threads_Handler
MySQL_Listeners_Manager *MLM;
public:
struct {
bool azure_enabled;
int monitor_history;
int monitor_connect_interval;
int monitor_connect_timeout;

@ -690,6 +690,9 @@ __thread int mysql_thread___eventslog_filesize;
__thread char * mysql_thread___auditlog_filename;
__thread int mysql_thread___auditlog_filesize;
/* variables used by the Azure MySQL Connection Control*/
__thread int mysql_thread___azure_enabled;
/* variables used by the monitoring module */
__thread int mysql_thread___monitor_enabled;
__thread int mysql_thread___monitor_history;
@ -819,6 +822,9 @@ extern __thread int mysql_thread___eventslog_filesize;
extern __thread char * mysql_thread___auditlog_filename;
extern __thread int mysql_thread___auditlog_filesize;
/* variables used by the Azure MySQL Connection Control*/
extern __thread int mysql_thread___azure_enabled;
/* variables used by the monitoring module */
extern __thread int mysql_thread___monitor_enabled;
extern __thread int mysql_thread___monitor_history;

@ -895,7 +895,9 @@ bool MySQL_Monitor_State_Data::create_new_connection() {
if (timeout==0) timeout=1;
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "program_name", "proxysql_monitor");
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
if (mysql_thread___azure_enabled) {
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
}
MYSQL *myrc=NULL;
if (port) {
myrc=mysql_real_connect(mysql, hostname, mysql_thread___monitor_username, mysql_thread___monitor_password, NULL, port, NULL, 0);

@ -91,7 +91,9 @@ void * kill_query_thread(void *arg) {
MySQL_Thread * thread = ka->mt;
mysql=mysql_init(NULL);
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "program_name", "proxysql_killer");
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_name", ka->hostname);
if (mysql_thread___azure_enabled) {
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", ka->hostname);
}
if (!mysql) {
goto __exit_kill_query_thread;
}

@ -231,6 +231,7 @@ static char * mysql_thread_variables_names[]= {
(char *)"have_compress",
(char *)"client_found_rows",
(char *)"interfaces",
(char *)"azure_enabled",
(char *)"monitor_enabled",
(char *)"monitor_history",
(char *)"monitor_connect_interval",
@ -363,6 +364,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
variables.connect_timeout_server_max=10000;
variables.free_connections_pct=10;
variables.connect_retries_delay=1;
variables.azure_enabled = false;
variables.monitor_enabled=true;
variables.monitor_history=600000;
variables.monitor_connect_interval=120000;
@ -689,6 +691,7 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) {
if (!strcmp(name,"monitor_history")) return (int)variables.monitor_history;
if (!strcmp(name,"monitor_slave_lag_when_null")) return (int)variables.monitor_slave_lag_when_null;
}
if (!strcmp(name, "azure_enabled")) return (int)variables.azure_enabled;
if (!strncmp(name,"c",1)) {
if (!strcmp(name,"connect_retries_on_failure")) return (int)variables.connect_retries_on_failure;
if (!strcmp(name,"connection_delay_multiplex_ms")) return (int)variables.connection_delay_multiplex_ms;
@ -862,6 +865,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f
sprintf(intbuf,"%d",variables.server_capabilities);
return strdup(intbuf);
}
if (!strcasecmp(name, "azure_enabled")) {
return strdup((variables.azure_enabled ? "true" : "false"));
}
// SSL variables
if (!strncasecmp(name,"ssl_",4)) {
if (!strcasecmp(name,"ssl_p2s_ca")) {
@ -1292,6 +1298,19 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t
if (!value) return false;
size_t vallen=strlen(value);
// Azure control
if (!strcasecmp(name, "azure_enabled")) {
if (strcasecmp(value, "true") == 0 || strcasecmp(value, "1") == 0) {
variables.azure_enabled = true;
return true;
}
if (strcasecmp(value, "false") == 0 || strcasecmp(value, "0") == 0) {
variables.azure_enabled = false;
return true;
}
return false;
}
// monitor variables
if (!strncasecmp(name,"monitor_",8)) {
if (!strcasecmp(name,"monitor_username")) {
@ -3819,6 +3838,9 @@ void MySQL_Thread::refresh_variables() {
if (mysql_thread___ssl_p2s_cipher) free(mysql_thread___ssl_p2s_cipher);
mysql_thread___ssl_p2s_cipher=GloMTH->get_variable_string((char *)"ssl_p2s_cipher");
mysql_thread___azure_enabled = (bool)GloMTH->get_variable_int((char*)"azure_enabled");
mysql_thread___monitor_wait_timeout=(bool)GloMTH->get_variable_int((char *)"monitor_wait_timeout");
mysql_thread___monitor_writer_is_also_reader=(bool)GloMTH->get_variable_int((char *)"monitor_writer_is_also_reader");
mysql_thread___monitor_enabled=(bool)GloMTH->get_variable_int((char *)"monitor_enabled");

@ -94,7 +94,9 @@ void * ProxySQL_Cluster_Monitor_thread(void *args) {
mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long);
mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout);
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", node->hostname);
if (mysql_thread___azure_enabled) {
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", node->hostname);
}
//rc_conn = mysql_real_connect(conn, node->hostname, username, password, NULL, node->port, NULL, CLIENT_COMPRESS); // FIXME: add optional support for compression
rc_conn = mysql_real_connect(conn, node->hostname, username, password, NULL, node->port, NULL, 0);
//char *query = query1;
@ -614,7 +616,9 @@ void ProxySQL_Cluster::pull_mysql_query_rules_from_peer() {
mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long);
mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout);
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
if (mysql_thread___azure_enabled) {
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
}
proxy_info("Cluster: Fetching MySQL Query Rules from peer %s:%d started\n", hostname, port);
rc_conn = mysql_real_connect(conn, hostname, username, password, NULL, port, NULL, 0);
if (rc_conn) {
@ -767,7 +771,9 @@ void ProxySQL_Cluster::pull_mysql_users_from_peer() {
mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long);
mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout);
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
if (mysql_thread___azure_enabled) {
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
}
proxy_info("Cluster: Fetching MySQL Users from peer %s:%d started\n", hostname, port);
rc_conn = mysql_real_connect(conn, hostname, username, password, NULL, port, NULL, 0);
if (rc_conn) {
@ -850,7 +856,9 @@ void ProxySQL_Cluster::pull_mysql_servers_from_peer() {
mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long);
mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout);
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
if (mysql_thread___azure_enabled) {
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
}
proxy_info("Cluster: Fetching MySQL Servers from peer %s:%d started. Expected checksum %s\n", hostname, port, peer_checksum);
rc_conn = mysql_real_connect(conn, hostname, username, password, NULL, port, NULL, 0);
if (rc_conn) {
@ -995,7 +1003,9 @@ void ProxySQL_Cluster::pull_proxysql_servers_from_peer() {
mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long);
mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout);
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
if (mysql_thread___azure_enabled) {
mysql_options4(conn, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname);
}
proxy_info("Cluster: Fetching ProxySQL Servers from peer %s:%d started\n", hostname, port);
rc_conn = mysql_real_connect(conn, hostname, username, password, NULL, port, NULL, 0);
if (rc_conn) {

@ -458,7 +458,9 @@ void MySQL_Connection::connect_start() {
assert(mysql);
mysql_options(mysql, MYSQL_OPT_NONBLOCK, 0);
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "program_name", "proxysql");
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", parent->address);
if (mysql_thread___azure_enabled) {
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", parent->address);
}
if (parent->use_ssl) {
mysql_ssl_set(mysql, mysql_thread___ssl_p2s_key, mysql_thread___ssl_p2s_cert, mysql_thread___ssl_p2s_ca, NULL, mysql_thread___ssl_p2s_cipher);
}

Loading…
Cancel
Save