LOGIF removed from readconnroute.c

This commit is contained in:
Johan Wikman
2015-11-17 10:02:59 +02:00
parent 41d26b5b73
commit fb443a9f92
2 changed files with 63 additions and 80 deletions

View File

@ -93,6 +93,9 @@ extern __thread log_info_t tls_log_info;
#define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \ #define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
log_ses_count[id] > 0) ? true : false) log_ses_count[id] > 0) ? true : false)
// TODO: Add this at a later stage.
#define MXS_LOG_PRIORITY_IS_ENABLED(priority) false
/** /**
* Execute the given command if specified log is enabled in general or * Execute the given command if specified log is enabled in general or
* if the log is enabled for the current session. * if the log is enabled for the current session.

View File

@ -171,11 +171,9 @@ version()
void void
ModuleInit() ModuleInit()
{ {
LOGIF(LM, (skygw_log_write( MXS_NOTICE("Initialise readconnroute router module %s.", version_str);
LOGFILE_MESSAGE, spinlock_init(&instlock);
"Initialise readconnroute router module %s.\n", version_str))); instances = NULL;
spinlock_init(&instlock);
instances = NULL;
} }
/** /**
@ -261,11 +259,10 @@ char *weightby;
} }
if (total == 0) if (total == 0)
{ {
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, MXS_WARNING("Weighting Parameter for service '%s' "
"WARNING: Weighting Parameter for service '%s' "
"will be ignored as no servers have values " "will be ignored as no servers have values "
"for the parameter '%s'.\n", "for the parameter '%s'.\n",
service->name, weightby))); service->name, weightby);
} }
else else
{ {
@ -280,14 +277,12 @@ char *weightby;
backend->weight = perc; backend->weight = perc;
if (perc == 0) if (perc == 0)
{ {
LOGIF(LE, (skygw_log_write( MXS_ERROR("Server '%s' has no value "
LOGFILE_ERROR, "for weighting parameter '%s', "
"Server '%s' has no value " "no queries will be routed to "
"for weighting parameter '%s', " "this server.\n",
"no queries will be routed to " inst->servers[n]->server->unique_name,
"this server.\n", weightby);
inst->servers[n]->server->unique_name,
weightby)));
} }
} }
@ -330,13 +325,11 @@ char *weightby;
} }
else else
{ {
LOGIF(LM, (skygw_log_write( MXS_WARNING("Unsupported router "
LOGFILE_MESSAGE, "option \'%s\' for readconnroute. "
"* Warning : Unsupported router " "Expected router options are "
"option \'%s\' for readconnroute. " "[slave|master|synced|ndb]",
"Expected router options are " options[i]);
"[slave|master|synced|ndb]",
options[i])));
} }
} }
} }
@ -375,13 +368,11 @@ BACKEND *candidate = NULL;
int i; int i;
BACKEND *master_host = NULL; BACKEND *master_host = NULL;
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [newSession] new router session with session "
LOGFILE_DEBUG, "%p, and inst %p.",
"%lu [newSession] new router session with session " pthread_self(),
"%p, and inst %p.", session,
pthread_self(), inst);
session,
inst)));
client_rses = (ROUTER_CLIENT_SES *)calloc(1, sizeof(ROUTER_CLIENT_SES)); client_rses = (ROUTER_CLIENT_SES *)calloc(1, sizeof(ROUTER_CLIENT_SES));
@ -420,16 +411,14 @@ BACKEND *master_host = NULL;
*/ */
for (i = 0; inst->servers[i]; i++) { for (i = 0; inst->servers[i]; i++) {
if(inst->servers[i]) { if(inst->servers[i]) {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [newSession] Examine server in port %d with "
LOGFILE_DEBUG, "%d connections. Status is %s, "
"%lu [newSession] Examine server in port %d with " "inst->bitvalue is %d",
"%d connections. Status is %s, " pthread_self(),
"inst->bitvalue is %d", inst->servers[i]->server->port,
pthread_self(), inst->servers[i]->current_connection_count,
inst->servers[i]->server->port, STRSRVSTATUS(inst->servers[i]->server),
inst->servers[i]->current_connection_count, inst->bitmask);
STRSRVSTATUS(inst->servers[i]->server),
inst->bitmask)));
} }
if (SERVER_IN_MAINT(inst->servers[i]->server)) if (SERVER_IN_MAINT(inst->servers[i]->server))
@ -512,13 +501,11 @@ BACKEND *master_host = NULL;
if (master_host) { if (master_host) {
candidate = master_host; candidate = master_host;
} else { } else {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to create new routing session. "
LOGFILE_ERROR, "Couldn't find eligible candidate server. Freeing "
"Error : Failed to create new routing session. " "allocated resources.");
"Couldn't find eligible candidate server. Freeing " free(client_rses);
"allocated resources."))); return NULL;
free(client_rses);
return NULL;
} }
} }
@ -530,13 +517,11 @@ BACKEND *master_host = NULL;
*/ */
atomic_add(&candidate->current_connection_count, 1); atomic_add(&candidate->current_connection_count, 1);
client_rses->backend = candidate; client_rses->backend = candidate;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [newSession] Selected server in port %d. "
LOGFILE_DEBUG, "Connections : %d\n",
"%lu [newSession] Selected server in port %d. " pthread_self(),
"Connections : %d\n", candidate->server->port,
pthread_self(), candidate->current_connection_count);
candidate->server->port,
candidate->current_connection_count)));
/* /*
* Open a backend connection, putting the DCB for this * Open a backend connection, putting the DCB for this
@ -568,10 +553,8 @@ BACKEND *master_host = NULL;
CHK_CLIENT_RSES(client_rses); CHK_CLIENT_RSES(client_rses);
skygw_log_write( MXS_INFO("Readconnroute: New session for server %s. "
LOGFILE_TRACE, "Connections : %d",
"Readconnroute: New session for server %s. "
"Connections : %d",
candidate->server->unique_name, candidate->server->unique_name,
candidate->current_connection_count); candidate->current_connection_count);
return (void *)client_rses; return (void *)client_rses;
@ -623,15 +606,13 @@ static void freeSession(
} }
spinlock_release(&router->lock); spinlock_release(&router->lock);
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [freeSession] Unlinked router_client_session %p from "
LOGFILE_DEBUG, "router %p and from server on port %d. Connections : %d. ",
"%lu [freeSession] Unlinked router_client_session %p from " pthread_self(),
"router %p and from server on port %d. Connections : %d. ", router_cli_ses,
pthread_self(), router,
router_cli_ses, router_cli_ses->backend->server->port,
router, prev_val-1);
router_cli_ses->backend->server->port,
prev_val-1)));
free(router_cli_ses); free(router_cli_ses);
} }
@ -721,14 +702,12 @@ routeQuery(ROUTER *instance, void *router_session, GWBUF *queue)
if (rses_is_closed || backend_dcb == NULL || if (rses_is_closed || backend_dcb == NULL ||
SERVER_IS_DOWN(router_cli_ses->backend->server)) SERVER_IS_DOWN(router_cli_ses->backend->server))
{ {
LOGIF(LT, (skygw_log_write( MXS_ERROR("Failed to route MySQL command %d to backend "
LOGFILE_TRACE|LOGFILE_ERROR, "server.%s",
"Error : Failed to route MySQL command %d to backend " mysql_command,rses_is_closed ? " Session is closed." : "");
"server.%s", rc = 0;
mysql_command,rses_is_closed ? " Session is closed." : ""))); while((queue = GWBUF_CONSUME_ALL(queue)) != NULL);
rc = 0; goto return_rc;
while((queue = GWBUF_CONSUME_ALL(queue)) != NULL);
goto return_rc;
} }
@ -743,19 +722,20 @@ routeQuery(ROUTER *instance, void *router_session, GWBUF *queue)
queue); queue);
break; break;
case MYSQL_COM_QUERY: case MYSQL_COM_QUERY:
LOGIF(LOGFILE_TRACE,(trc = modutil_get_SQL(queue))); if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
{
trc = modutil_get_SQL(queue);
}
default: default:
rc = backend_dcb->func.write(backend_dcb, queue); rc = backend_dcb->func.write(backend_dcb, queue);
break; break;
} }
LOGIF(LOGFILE_TRACE,skygw_log_write( MXS_INFO("Routed [%s] to '%s'%s%s",
LOGFILE_DEBUG|LOGFILE_TRACE,
"Routed [%s] to '%s'%s%s",
STRPACKETTYPE(mysql_command), STRPACKETTYPE(mysql_command),
backend_dcb->server->unique_name, backend_dcb->server->unique_name,
trc?": ":".", trc?": ":".",
trc?trc:"")); trc?trc:"");
free(trc); free(trc);
return_rc: return_rc:
return rc; return rc;