Merge branch 'develop' into mon_script_test

This commit is contained in:
Markus Makela
2015-05-05 18:30:08 +03:00
14 changed files with 248 additions and 178 deletions

View File

@ -2225,15 +2225,11 @@ int main(int argc, char** argv)
}
printf("Log files written to: %s\n",home?home:"/tpm");
int argc_ = 11;
int argc_ = 2;
char* argv_[] =
{
"log_manager",
"-j",home?home:"/tmp",
"-a","ruleparser_debug",
"-c","ruleparser_trace",
"-e","ruleparser_message",
"-g","ruleparser_error",
"-o",
NULL
};

View File

@ -32,7 +32,8 @@
* 24/06/14 Massimiliano Pinto Added depth level 0 for each node
* 30/10/14 Massimiliano Pinto Added disableMasterFailback feature
* 10/11/14 Massimiliano Pinto Added setNetworkTimeout for connect,read,write
* 20/05/15 Guillaume Lefranc Added availableWhenDonor feature
* 20/04/15 Guillaume Lefranc Added availableWhenDonor feature
* 22/04/15 Martin Brampton Addition of disableMasterRoleSetting
*
* @endverbatim
*/
@ -160,6 +161,7 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
handle->interval = MONITOR_INTERVAL;
handle->disableMasterFailback = 0;
handle->availableWhenDonor = 0;
handle->disableMasterRoleSetting = 0;
handle->master = NULL;
handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT;
handle->read_timeout=DEFAULT_READ_TIMEOUT;
@ -172,8 +174,10 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
{
if(!strcmp(params->name,"disable_master_failback"))
handle->disableMasterFailback = config_truth_value(params->value);
if(!strcmp(params->name,"available_when_donor"))
else if(!strcmp(params->name,"available_when_donor"))
handle->availableWhenDonor = config_truth_value(params->value);
else if(!strcmp(params->name,"disable_master_role_setting"))
handle->disableMasterRoleSetting = config_truth_value(params->value);
params = params->next;
}
@ -294,6 +298,7 @@ char *sep;
dcb_printf(dcb,"\tSampling interval:\t%lu milliseconds\n", handle->interval);
dcb_printf(dcb,"\tMaster Failback:\t%s\n", (handle->disableMasterFailback == 1) ? "off" : "on");
dcb_printf(dcb,"\tAvailable when Donor:\t%s\n", (handle->availableWhenDonor == 1) ? "on" : "off");
dcb_printf(dcb,"\tMaster Role Setting Disabled:\t%s\n", (handle->disableMasterRoleSetting == 1) ? "on" : "off");
dcb_printf(dcb,"\tConnect Timeout:\t%i seconds\n", handle->connect_timeout);
dcb_printf(dcb,"\tRead Timeout:\t\t%i seconds\n", handle->read_timeout);
dcb_printf(dcb,"\tWrite Timeout:\t\t%i seconds\n", handle->write_timeout);
@ -596,40 +601,47 @@ int log_no_members = 1;
* Decision depends on master_stickiness value set in configuration
*/
/* get the candidate master, followinf MIN(node_id) rule */
/* get the candidate master, following MIN(node_id) rule */
candidate_master = get_candidate_master(handle->databases);
/* Select the master, based on master_stickiness */
handle->master = set_cluster_master(handle->master, candidate_master, master_stickiness);
if (1 == handle->disableMasterRoleSetting) {
handle->master = NULL;
}
else {
handle->master = set_cluster_master(handle->master, candidate_master, master_stickiness);
}
ptr = handle->databases;
while (ptr && handle->master) {
while (ptr) {
if (!SERVER_IS_JOINED(ptr->server) || SERVER_IN_MAINT(ptr->server)) {
ptr = ptr->next;
continue;
}
if (ptr != handle->master) {
if (handle->master) {
if (ptr != handle->master) {
/* set the Slave role */
server_set_status(ptr->server, SERVER_SLAVE);
server_clear_status(ptr->server, SERVER_MASTER);
/* clear master stickyness */
/* clear master stickiness */
server_clear_status(ptr->server, SERVER_MASTER_STICKINESS);
} else {
} else {
/* set the Master role */
server_set_status(handle->master->server, SERVER_MASTER);
server_clear_status(handle->master->server, SERVER_SLAVE);
if (candidate_master && handle->master->server->node_id != candidate_master->server->node_id) {
/* set master stickyness */
/* set master stickiness */
server_set_status(handle->master->server, SERVER_MASTER_STICKINESS);
} else {
/* clear master stickyness */
/* clear master stickiness */
server_clear_status(ptr->server, SERVER_MASTER_STICKINESS);
}
}
}
}
is_cluster++;

View File

@ -35,7 +35,8 @@
* 28/08/14 Massimiliano Pinto Addition of detectStaleMaster
* 30/10/14 Massimiliano Pinto Addition of disableMasterFailback
* 07/11/14 Massimiliano Pinto Addition of NetworkTimeout: connect, read, write
* 20/05/15 Guillaume Lefranc Addition of availableWhenDonor
* 20/04/15 Guillaume Lefranc Addition of availableWhenDonor
* 22/04/15 Martin Brampton Addition of disableMasterRoleSetting
*
* @endverbatim
*/
@ -70,6 +71,7 @@ typedef struct {
int detectStaleMaster; /**< Monitor flag for MySQL replication Stale Master detection */
int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */

View File

@ -238,24 +238,23 @@ static int hashcmpfun(
/**
* Convert a length encoded string into a C string.
* @param data Pointer to the first byte of the string
* @param len Pointer to an integer where the length of the string will be stored. On errors this will be set to -1.
* @return Pointer to the newly allocated string or NULL if the value is NULL or an error occurred
*/
char* get_lenenc_str(void* data, int* len)
char* get_lenenc_str(void* data)
{
unsigned char* ptr = (unsigned char*)data;
char* rval;
unsigned long size, offset;
uintptr_t size;
long offset;
if(data == NULL || len == NULL)
if(data == NULL)
{
*len = -1;
return NULL;
}
if(*ptr < 251)
{
size = *ptr;
size = (uintptr_t)*ptr;
offset = 1;
}
else
@ -263,7 +262,6 @@ char* get_lenenc_str(void* data, int* len)
switch(*(ptr))
{
case 0xfb:
*len = 1;
return NULL;
case 0xfc:
size = *(ptr + 1) + (*(ptr + 2) << 8);
@ -274,14 +272,9 @@ char* get_lenenc_str(void* data, int* len)
offset = 3;
break;
case 0xfe:
size = *ptr +
((*(ptr + 2) << 8)) +
(*(ptr + 3) << 16) +
(*(ptr + 4) << 24) +
((unsigned long)*(ptr + 5) << 32) +
((unsigned long)*(ptr + 6) << 40) +
((unsigned long)*(ptr + 7) << 48) +
((unsigned long)*(ptr + 8) << 56);
size = *ptr + ((*(ptr + 2) << 8)) + (*(ptr + 3) << 16) +
(*(ptr + 4) << 24) + ((uintptr_t)*(ptr + 5) << 32) + ((uintptr_t)*(ptr + 6) << 40) +
((uintptr_t)*(ptr + 7) << 48) + ((uintptr_t)*(ptr + 8) << 56);
offset = 8;
break;
default:
@ -297,7 +290,6 @@ char* get_lenenc_str(void* data, int* len)
memset(rval + size,0,1);
}
*len = size + offset;
return rval;
}
@ -360,8 +352,7 @@ bool parse_showdb_response(ROUTER_CLIENT_SES* rses, backend_ref_t* bref, GWBUF**
{
int payloadlen = gw_mysql_get_byte3(ptr);
int packetlen = payloadlen + 4;
int len = 0;
char* data = get_lenenc_str(ptr+4,&len);
char* data = get_lenenc_str(ptr+4);
if(data)
{

View File

@ -246,25 +246,23 @@ hashcmpfun(
/**
* Convert a length encoded string into a C string.
* @param data Pointer to the first byte of the string
* @param len Pointer to an integer where the length of the string will be stored. On errors this will be set to -1.
* @return Pointer to the newly allocated string or NULL if the value is NULL or an error occurred
*/
char* get_lenenc_str(void* data, int* len)
char* get_lenenc_str(void* data)
{
unsigned char* ptr = (unsigned char*)data;
char* rval;
long size, offset;
uintptr_t size;
long offset;
if(data == NULL || len == NULL)
if(data == NULL)
{
if(len)
*len = -1;
return NULL;
}
if(*ptr < 251)
{
size = *ptr;
size = (uintptr_t)*ptr;
offset = 1;
}
else
@ -272,7 +270,6 @@ char* get_lenenc_str(void* data, int* len)
switch(*(ptr))
{
case 0xfb:
*len = 1;
return NULL;
case 0xfc:
size = *(ptr + 1) + (*(ptr + 2) << 8);
@ -284,8 +281,8 @@ char* get_lenenc_str(void* data, int* len)
break;
case 0xfe:
size = *ptr + ((*(ptr + 2) << 8)) + (*(ptr + 3) << 16) +
(*(ptr + 4) << 24) + ((long)*(ptr + 5) << 32) + ((long)*(ptr + 6) << 40) +
((long)*(ptr + 7) << 48) + ((long)*(ptr + 8) << 56);
(*(ptr + 4) << 24) + ((uintptr_t)*(ptr + 5) << 32) + ((uintptr_t)*(ptr + 6) << 40) +
((uintptr_t)*(ptr + 7) << 48) + ((uintptr_t)*(ptr + 8) << 56);
offset = 8;
break;
default:
@ -301,7 +298,6 @@ char* get_lenenc_str(void* data, int* len)
memset(rval + size,0,1);
}
*len = size + offset;
return rval;
}
@ -344,8 +340,7 @@ parse_mapping_response(ROUTER_CLIENT_SES* rses, char* target, GWBUF* buf)
{
int payloadlen = gw_mysql_get_byte3(ptr);
int packetlen = payloadlen + 4;
int len = 0;
char* data = get_lenenc_str(ptr+4,&len);
char* data = get_lenenc_str(ptr+4);
if(data)
{