Uncrustify maxscale
See script directory for method. The script to run in the top level MaxScale directory is called maxscale-uncrustify.sh, which uses another script, list-src, from the same directory (so you need to set your PATH). The uncrustify version was 0.66.
This commit is contained in:
@ -52,10 +52,10 @@ using namespace maxscale;
|
||||
#define MAX_SLAVE_COUNT "255"
|
||||
|
||||
// TODO: Don't process parameters in readwritesplit
|
||||
static bool handle_max_slaves(Config& config, const char *str)
|
||||
static bool handle_max_slaves(Config& config, const char* str)
|
||||
{
|
||||
bool rval = true;
|
||||
char *endptr;
|
||||
char* endptr;
|
||||
int val = strtol(str, &endptr, 10);
|
||||
|
||||
if (*endptr == '%' && *(endptr + 1) == '\0')
|
||||
@ -77,10 +77,10 @@ static bool handle_max_slaves(Config& config, const char *str)
|
||||
return rval;
|
||||
}
|
||||
|
||||
RWSplit::RWSplit(SERVICE* service, const Config& config):
|
||||
mxs::Router<RWSplit, RWSplitSession>(service),
|
||||
m_service(service),
|
||||
m_config(config)
|
||||
RWSplit::RWSplit(SERVICE* service, const Config& config)
|
||||
: mxs::Router<RWSplit, RWSplitSession>(service)
|
||||
, m_service(service)
|
||||
, m_config(config)
|
||||
{
|
||||
}
|
||||
|
||||
@ -110,9 +110,9 @@ const Stats& RWSplit::stats() const
|
||||
int RWSplit::max_slave_count() const
|
||||
{
|
||||
int router_nservers = m_service->n_dbref;
|
||||
int conf_max_nslaves = m_config->max_slave_connections > 0 ?
|
||||
m_config->max_slave_connections :
|
||||
(router_nservers * m_config->rw_max_slave_conn_percent) / 100;
|
||||
int conf_max_nslaves = m_config->max_slave_connections > 0
|
||||
? m_config->max_slave_connections
|
||||
: (router_nservers * m_config->rw_max_slave_conn_percent) / 100;
|
||||
return MXS_MIN(router_nservers - 1, MXS_MAX(1, conf_max_nslaves));
|
||||
}
|
||||
|
||||
@ -132,7 +132,10 @@ bool RWSplit::have_enough_servers() const
|
||||
{
|
||||
MXS_ERROR("Unable to start %s service. There are "
|
||||
"too few backend servers available. Found %d "
|
||||
"when %d is required.", m_service->name, router_nsrv, min_nsrv);
|
||||
"when %d is required.",
|
||||
m_service->name,
|
||||
router_nsrv,
|
||||
min_nsrv);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -144,7 +147,9 @@ bool RWSplit::have_enough_servers() const
|
||||
MXS_ERROR("Unable to start %s service. There are "
|
||||
"too few backend servers configured in "
|
||||
"MaxScale.cnf. Found %d when %d is required.",
|
||||
m_service->name, m_config->max_slave_connections, min_nsrv);
|
||||
m_service->name,
|
||||
m_config->max_slave_connections,
|
||||
min_nsrv);
|
||||
}
|
||||
if (nservers < min_nsrv)
|
||||
{
|
||||
@ -152,8 +157,10 @@ bool RWSplit::have_enough_servers() const
|
||||
MXS_ERROR("Unable to start %s service. There are "
|
||||
"too few backend servers configured in "
|
||||
"MaxScale.cnf. Found %d%% when at least %.0f%% "
|
||||
"would be required.", m_service->name,
|
||||
m_config->rw_max_slave_conn_percent, dbgpct);
|
||||
"would be required.",
|
||||
m_service->name,
|
||||
m_config->rw_max_slave_conn_percent,
|
||||
dbgpct);
|
||||
}
|
||||
}
|
||||
succp = false;
|
||||
@ -166,14 +173,16 @@ static void log_router_options_not_supported(SERVICE* service, MXS_CONFIG_PARAME
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
for (const auto& a: mxs::strtok(p->value, ", \t"))
|
||||
for (const auto& a : mxs::strtok(p->value, ", \t"))
|
||||
{
|
||||
ss << a << "\n";
|
||||
}
|
||||
|
||||
MXS_ERROR("`router_options` is no longer supported in readwritesplit. "
|
||||
"To define the router options as parameters, add the following "
|
||||
"lines to service '%s':\n\n%s\n", service->name, ss.str().c_str());
|
||||
"lines to service '%s':\n\n%s\n",
|
||||
service->name,
|
||||
ss.str().c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +190,7 @@ static void log_router_options_not_supported(SERVICE* service, MXS_CONFIG_PARAME
|
||||
*/
|
||||
|
||||
|
||||
RWSplit* RWSplit::create(SERVICE *service, MXS_CONFIG_PARAMETER* params)
|
||||
RWSplit* RWSplit::create(SERVICE* service, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
if (MXS_CONFIG_PARAMETER* p = config_get_param(params, CN_ROUTER_OPTIONS))
|
||||
{
|
||||
@ -218,54 +227,70 @@ RWSplit* RWSplit::create(SERVICE *service, MXS_CONFIG_PARAMETER* params)
|
||||
config.master_reconnection = true;
|
||||
}
|
||||
|
||||
return new (std::nothrow) RWSplit(service, config);
|
||||
return new( std::nothrow) RWSplit(service, config);
|
||||
}
|
||||
|
||||
RWSplitSession* RWSplit::newSession(MXS_SESSION *session)
|
||||
RWSplitSession* RWSplit::newSession(MXS_SESSION* session)
|
||||
{
|
||||
RWSplitSession* rses = NULL;
|
||||
MXS_EXCEPTION_GUARD(rses = RWSplitSession::create(this, session));
|
||||
return rses;
|
||||
}
|
||||
|
||||
void RWSplit::diagnostics(DCB *dcb)
|
||||
void RWSplit::diagnostics(DCB* dcb)
|
||||
{
|
||||
const char *weightby = serviceGetWeightingParameter(service());
|
||||
const char* weightby = serviceGetWeightingParameter(service());
|
||||
double master_pct = 0.0, slave_pct = 0.0, all_pct = 0.0;
|
||||
Config cnf = config();
|
||||
|
||||
dcb_printf(dcb, "\n");
|
||||
dcb_printf(dcb, "\tuse_sql_variables_in: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tuse_sql_variables_in: %s\n",
|
||||
mxs_target_to_str(cnf.use_sql_variables_in));
|
||||
dcb_printf(dcb, "\tslave_selection_criteria: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tslave_selection_criteria: %s\n",
|
||||
select_criteria_to_str(cnf.slave_selection_criteria));
|
||||
dcb_printf(dcb, "\tmaster_failure_mode: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tmaster_failure_mode: %s\n",
|
||||
failure_mode_to_str(cnf.master_failure_mode));
|
||||
dcb_printf(dcb, "\tmax_slave_replication_lag: %d\n",
|
||||
dcb_printf(dcb,
|
||||
"\tmax_slave_replication_lag: %d\n",
|
||||
cnf.max_slave_replication_lag);
|
||||
dcb_printf(dcb, "\tretry_failed_reads: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tretry_failed_reads: %s\n",
|
||||
cnf.retry_failed_reads ? "true" : "false");
|
||||
dcb_printf(dcb, "\tstrict_multi_stmt: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tstrict_multi_stmt: %s\n",
|
||||
cnf.strict_multi_stmt ? "true" : "false");
|
||||
dcb_printf(dcb, "\tstrict_sp_calls: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tstrict_sp_calls: %s\n",
|
||||
cnf.strict_sp_calls ? "true" : "false");
|
||||
dcb_printf(dcb, "\tdisable_sescmd_history: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tdisable_sescmd_history: %s\n",
|
||||
cnf.disable_sescmd_history ? "true" : "false");
|
||||
dcb_printf(dcb, "\tmax_sescmd_history: %lu\n",
|
||||
dcb_printf(dcb,
|
||||
"\tmax_sescmd_history: %lu\n",
|
||||
cnf.max_sescmd_history);
|
||||
dcb_printf(dcb, "\tmaster_accept_reads: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tmaster_accept_reads: %s\n",
|
||||
cnf.master_accept_reads ? "true" : "false");
|
||||
dcb_printf(dcb, "\tconnection_keepalive: %d\n",
|
||||
dcb_printf(dcb,
|
||||
"\tconnection_keepalive: %d\n",
|
||||
cnf.connection_keepalive);
|
||||
dcb_printf(dcb, "\tcausal_reads: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tcausal_reads: %s\n",
|
||||
cnf.causal_reads ? "true" : "false");
|
||||
dcb_printf(dcb, "\tcausal_reads_timeout: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tcausal_reads_timeout: %s\n",
|
||||
cnf.causal_reads_timeout.c_str());
|
||||
dcb_printf(dcb, "\tmaster_reconnection: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tmaster_reconnection: %s\n",
|
||||
cnf.master_reconnection ? "true" : "false");
|
||||
dcb_printf(dcb, "\tdelayed_retry: %s\n",
|
||||
dcb_printf(dcb,
|
||||
"\tdelayed_retry: %s\n",
|
||||
cnf.delayed_retry ? "true" : "false");
|
||||
dcb_printf(dcb, "\tdelayed_retry_timeout: %lu\n",
|
||||
dcb_printf(dcb,
|
||||
"\tdelayed_retry_timeout: %lu\n",
|
||||
cnf.delayed_retry_timeout);
|
||||
|
||||
dcb_printf(dcb, "\n");
|
||||
@ -277,38 +302,55 @@ void RWSplit::diagnostics(DCB *dcb)
|
||||
all_pct = ((double)stats().n_all / (double)stats().n_queries) * 100.0;
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "\tNumber of router sessions: %" PRIu64 "\n",
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of router sessions: %" PRIu64 "\n",
|
||||
stats().n_sessions);
|
||||
dcb_printf(dcb, "\tCurrent no. of router sessions: %d\n",
|
||||
dcb_printf(dcb,
|
||||
"\tCurrent no. of router sessions: %d\n",
|
||||
service()->stats.n_current);
|
||||
dcb_printf(dcb, "\tNumber of queries forwarded: %" PRIu64 "\n",
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of queries forwarded: %" PRIu64 "\n",
|
||||
stats().n_queries);
|
||||
dcb_printf(dcb, "\tNumber of queries forwarded to master: %" PRIu64 " (%.2f%%)\n",
|
||||
stats().n_master, master_pct);
|
||||
dcb_printf(dcb, "\tNumber of queries forwarded to slave: %" PRIu64 " (%.2f%%)\n",
|
||||
stats().n_slave, slave_pct);
|
||||
dcb_printf(dcb, "\tNumber of queries forwarded to all: %" PRIu64 " (%.2f%%)\n",
|
||||
stats().n_all, all_pct);
|
||||
dcb_printf(dcb, "\tNumber of read-write transactions: %" PRIu64 "\n",
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of queries forwarded to master: %" PRIu64 " (%.2f%%)\n",
|
||||
stats().n_master,
|
||||
master_pct);
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of queries forwarded to slave: %" PRIu64 " (%.2f%%)\n",
|
||||
stats().n_slave,
|
||||
slave_pct);
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of queries forwarded to all: %" PRIu64 " (%.2f%%)\n",
|
||||
stats().n_all,
|
||||
all_pct);
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of read-write transactions: %" PRIu64 "\n",
|
||||
stats().n_rw_trx);
|
||||
dcb_printf(dcb, "\tNumber of read-only transactions: %" PRIu64 "\n",
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of read-only transactions: %" PRIu64 "\n",
|
||||
stats().n_ro_trx);
|
||||
dcb_printf(dcb, "\tNumber of replayed transactions: %" PRIu64 "\n",
|
||||
dcb_printf(dcb,
|
||||
"\tNumber of replayed transactions: %" PRIu64 "\n",
|
||||
stats().n_trx_replay);
|
||||
|
||||
if (*weightby)
|
||||
{
|
||||
dcb_printf(dcb, "\tConnection distribution based on %s "
|
||||
dcb_printf(dcb,
|
||||
"\tConnection distribution based on %s "
|
||||
"server parameter.\n",
|
||||
weightby);
|
||||
dcb_printf(dcb, "\t\tServer Target %% Connections "
|
||||
dcb_printf(dcb,
|
||||
"\t\tServer Target %% Connections "
|
||||
"Operations\n");
|
||||
dcb_printf(dcb, "\t\t Global Router\n");
|
||||
for (SERVER_REF *ref = service()->dbref; ref; ref = ref->next)
|
||||
for (SERVER_REF* ref = service()->dbref; ref; ref = ref->next)
|
||||
{
|
||||
dcb_printf(dcb, "\t\t%-20s %3.1f%% %-6d %-6d %d\n",
|
||||
ref->server->name, (1.0 - ref->inv_weight) * 100,
|
||||
ref->server->stats.n_current, ref->connections,
|
||||
dcb_printf(dcb,
|
||||
"\t\t%-20s %3.1f%% %-6d %-6d %d\n",
|
||||
ref->server->name,
|
||||
(1.0 - ref->inv_weight) * 100,
|
||||
ref->server->stats.n_current,
|
||||
ref->connections,
|
||||
ref->server->stats.n_current_ops);
|
||||
}
|
||||
}
|
||||
@ -328,7 +370,7 @@ json_t* RWSplit::diagnostics_json() const
|
||||
json_object_set_new(rval, "ro_transactions", json_integer(stats().n_ro_trx));
|
||||
json_object_set_new(rval, "replayed_transactions", json_integer(stats().n_trx_replay));
|
||||
|
||||
const char *weightby = serviceGetWeightingParameter(service());
|
||||
const char* weightby = serviceGetWeightingParameter(service());
|
||||
|
||||
if (*weightby)
|
||||
{
|
||||
@ -340,9 +382,9 @@ json_t* RWSplit::diagnostics_json() const
|
||||
|
||||
uint64_t RWSplit::getCapabilities()
|
||||
{
|
||||
return RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING |
|
||||
RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING |
|
||||
RCAP_TYPE_RUNTIME_CONFIG;
|
||||
return RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING
|
||||
| RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING
|
||||
| RCAP_TYPE_RUNTIME_CONFIG;
|
||||
}
|
||||
|
||||
bool RWSplit::configure(MXS_CONFIG_PARAMETER* params)
|
||||
@ -364,21 +406,22 @@ bool RWSplit::configure(MXS_CONFIG_PARAMETER* params)
|
||||
* the structure that is referred to as the "module object". This is a
|
||||
* structure with the set of external entry points for this module.
|
||||
*/
|
||||
extern "C" MXS_MODULE *MXS_CREATE_MODULE()
|
||||
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
static MXS_MODULE info =
|
||||
{
|
||||
MXS_MODULE_API_ROUTER, MXS_MODULE_GA, MXS_ROUTER_VERSION,
|
||||
MXS_MODULE_API_ROUTER, MXS_MODULE_GA,
|
||||
MXS_ROUTER_VERSION,
|
||||
"A Read/Write splitting router for enhancement read scalability",
|
||||
"V1.1.0",
|
||||
RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING |
|
||||
RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING |
|
||||
RCAP_TYPE_RUNTIME_CONFIG,
|
||||
RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING
|
||||
| RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING
|
||||
| RCAP_TYPE_RUNTIME_CONFIG,
|
||||
&RWSplit::s_object,
|
||||
NULL, /* Process init. */
|
||||
NULL, /* Process finish. */
|
||||
NULL, /* Thread init. */
|
||||
NULL, /* Thread finish. */
|
||||
NULL, /* Process init. */
|
||||
NULL, /* Process finish. */
|
||||
NULL, /* Thread init. */
|
||||
NULL, /* Thread finish. */
|
||||
{
|
||||
{
|
||||
"use_sql_variables_in",
|
||||
@ -401,23 +444,40 @@ extern "C" MXS_MODULE *MXS_CREATE_MODULE()
|
||||
MXS_MODULE_OPT_NONE,
|
||||
master_failure_mode_values
|
||||
},
|
||||
{"max_slave_replication_lag", MXS_MODULE_PARAM_INT, "-1"},
|
||||
{"max_slave_connections", MXS_MODULE_PARAM_STRING, MAX_SLAVE_COUNT},
|
||||
{"retry_failed_reads", MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "50"},
|
||||
{"strict_multi_stmt", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"strict_sp_calls", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"master_accept_reads", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"connection_keepalive", MXS_MODULE_PARAM_COUNT, "0"},
|
||||
{"causal_reads", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"causal_reads_timeout", MXS_MODULE_PARAM_STRING, "120"},
|
||||
{"master_reconnection", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"delayed_retry", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"delayed_retry_timeout", MXS_MODULE_PARAM_COUNT, "10"},
|
||||
{"transaction_replay", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"transaction_replay_max_size", MXS_MODULE_PARAM_SIZE, "1Mi"},
|
||||
{"optimistic_trx", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"max_slave_replication_lag", MXS_MODULE_PARAM_INT,
|
||||
"-1" },
|
||||
{"max_slave_connections", MXS_MODULE_PARAM_STRING,
|
||||
MAX_SLAVE_COUNT },
|
||||
{"retry_failed_reads", MXS_MODULE_PARAM_BOOL,
|
||||
"true" },
|
||||
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT,
|
||||
"50" },
|
||||
{"strict_multi_stmt", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"strict_sp_calls", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"master_accept_reads", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"connection_keepalive", MXS_MODULE_PARAM_COUNT,
|
||||
"0" },
|
||||
{"causal_reads", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"causal_reads_timeout", MXS_MODULE_PARAM_STRING,
|
||||
"120" },
|
||||
{"master_reconnection", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"delayed_retry", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"delayed_retry_timeout", MXS_MODULE_PARAM_COUNT,
|
||||
"10" },
|
||||
{"transaction_replay", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"transaction_replay_max_size", MXS_MODULE_PARAM_SIZE,
|
||||
"1Mi" },
|
||||
{"optimistic_trx", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user