Remove router_options

Relaced router_options with configuration parameters in the createInstance
router entry point. The same needs to be done for the filter API as barely
any filters use the feature.

Some routers (binlogrouter) still support router_options but using it is
deprecated. This had to be done as their use wasn't deprecated in 2.2.
This commit is contained in:
Markus Mäkelä
2018-07-10 05:42:01 +03:00
parent f11f8980b2
commit cbb8c68770
24 changed files with 49 additions and 216 deletions

View File

@ -58,6 +58,11 @@ The use of `router_options` with avrorouter was deprecated in MaxScale 2.1. In
MaxScale 2.3, the use of `router_options` is no longer supported and the options MaxScale 2.3, the use of `router_options` is no longer supported and the options
should be given as parameters instead. should be given as parameters instead.
### `router_options` in readwritesplit
The use of `router_options` with readwritesplit, which was deprecated in
MaxScale 2.2.0, has been removed in MaxScale 2.3.0.
### `QUERY-LAST-TRANSACTION` and `QUERY-TRANSACTION` CDC commands ### `QUERY-LAST-TRANSACTION` and `QUERY-TRANSACTION` CDC commands
The CDC protocol no longer accepts the `QUERY-LAST-TRANSACTION` and The CDC protocol no longer accepts the `QUERY-LAST-TRANSACTION` and

View File

@ -567,7 +567,7 @@ void RRRouter::decide_target(RRRouterSession* rses, GWBUF* querybuf, DCB*& targe
* The functions implementing the router module API. These do not need to be * The functions implementing the router module API. These do not need to be
* "extern C", but they do need to be callable from C code. * "extern C", but they do need to be callable from C code.
*/ */
static MXS_ROUTER* createInstance(SERVICE* service, char** options); static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params);
static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session); static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session);
static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session); static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session);
static void freeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session); static void freeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session);
@ -663,7 +663,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @param options The options for this query router * @param options The options for this query router
* @return NULL in failure, pointer to router in success. * @return NULL in failure, pointer to router in success.
*/ */
static MXS_ROUTER* createInstance(SERVICE* service, char** options) static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params)
{ {
RRRouter* instance = NULL; RRRouter* instance = NULL;
/* The core of MaxScale is written in C and does not understand exceptions. /* The core of MaxScale is written in C and does not understand exceptions.

View File

@ -15,7 +15,7 @@
#include <maxscale/router.h> #include <maxscale/router.h>
#include <maxscale/modinfo.h> #include <maxscale/modinfo.h>
static MXS_ROUTER *createInstance(SERVICE *service, char **options); static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params);
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session);
static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *session);
static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *session);
@ -94,8 +94,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* *
* @return The instance data for this new instance * @return The instance data for this new instance
*/ */
static MXS_ROUTER * static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
createInstance(SERVICE *service, char **options)
{ {
return (MXS_ROUTER*)MXS_MALLOC(sizeof(TESTROUTER)); return (MXS_ROUTER*)MXS_MALLOC(sizeof(TESTROUTER));
} }

View File

@ -90,11 +90,11 @@ typedef struct mxs_router_object
* other API functions. * other API functions.
* *
* @param service The service where the instance is created * @param service The service where the instance is created
* @param options Router options * @param params Parameters for the router
* *
* @return New router instance on NULL on error * @return New router instance on NULL on error
*/ */
MXS_ROUTER *(*createInstance)(SERVICE *service, char **options); MXS_ROUTER *(*createInstance)(SERVICE* service, MXS_CONFIG_PARAMETER* params);
/** /**
* Called to create a new user session within the router * Called to create a new user session within the router
@ -240,7 +240,7 @@ typedef struct mxs_router_object
* must update these versions numbers in accordance with the rules in * must update these versions numbers in accordance with the rules in
* modinfo.h. * modinfo.h.
*/ */
#define MXS_ROUTER_VERSION { 3, 1, 0 } #define MXS_ROUTER_VERSION { 4, 0, 0 }
/** /**
* Specifies capabilities specific for routers. Common capabilities * Specifies capabilities specific for routers. Common capabilities

View File

@ -98,7 +98,7 @@ protected:
* class MyRouter : public maxscale::Router<MyRouter, MyRouterSession> * class MyRouter : public maxscale::Router<MyRouter, MyRouterSession>
* { * {
* public: * public:
* static MyRouter* create(SERVICE* pService, char** pzOptions); * static MyRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
* *
* MyRouterSession* newSession(MXS_SESSION* pSession); * MyRouterSession* newSession(MXS_SESSION* pSession);
* *
@ -137,11 +137,11 @@ public:
return false; return false;
} }
static MXS_ROUTER* createInstance(SERVICE* pService, char** pzOptions) static MXS_ROUTER* createInstance(SERVICE* pService, MXS_CONFIG_PARAMETER* params)
{ {
RouterType* pRouter = NULL; RouterType* pRouter = NULL;
MXS_EXCEPTION_GUARD(pRouter = RouterType::create(pService, pzOptions)); MXS_EXCEPTION_GUARD(pRouter = RouterType::create(pService, params));
return pRouter; return pRouter;
} }

View File

@ -129,7 +129,6 @@ typedef struct service
SERV_LISTENER *ports; /**< Linked list of ports and protocols SERV_LISTENER *ports; /**< Linked list of ports and protocols
* that this service will listen on */ * that this service will listen on */
char *routerModule; /**< Name of router module to use */ char *routerModule; /**< Name of router module to use */
char **routerOptions; /**< Router specific option strings */
struct mxs_router_object *router; /**< The router we are using */ struct mxs_router_object *router; /**< The router we are using */
struct mxs_router *router_instance;/**< The router instance for this service */ struct mxs_router *router_instance;/**< The router instance for this service */
char version_string[MAX_SERVICE_VERSION_LEN]; /**< version string for this service listeners */ char version_string[MAX_SERVICE_VERSION_LEN]; /**< version string for this service listeners */

View File

@ -3316,17 +3316,6 @@ int configure_new_service(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj)
} }
} }
if (roptions)
{
char *lasts;
char *s = strtok_r(roptions, ",", &lasts);
while (s)
{
serviceAddRouterOption(service, s);
s = strtok_r(NULL, ",", &lasts);
}
}
if (filters) if (filters)
{ {
if (!serviceSetFilters(service, filters)) if (!serviceSetFilters(service, filters))

View File

@ -110,12 +110,6 @@ bool service_server_in_use(const SERVER *server);
/** Update the server weights used by services */ /** Update the server weights used by services */
void service_update_weights(); void service_update_weights();
/**
* Alteration of the service configuration
*/
void serviceAddRouterOption(SERVICE *service, char *option);
void serviceClearRouterOptions(SERVICE *service);
/** /**
* @brief Add parameters to a service * @brief Add parameters to a service
* *

View File

@ -127,7 +127,6 @@ SERVICE* service_alloc(const char *name, const char *router)
service->retry_start = true; service->retry_start = true;
service->conn_idle_timeout = SERVICE_NO_SESSION_TIMEOUT; service->conn_idle_timeout = SERVICE_NO_SESSION_TIMEOUT;
service->svc_config_param = NULL; service->svc_config_param = NULL;
service->routerOptions = NULL;
service->log_auth_warnings = true; service->log_auth_warnings = true;
service->strip_db_esc = true; service->strip_db_esc = true;
service->rate_limits = rate_limits; service->rate_limits = rate_limits;
@ -420,47 +419,6 @@ int serviceStartAllPorts(SERVICE* service)
return listeners; return listeners;
} }
/** Helper function for copying an array of strings */
static char** copy_string_array(char** original)
{
char **array = NULL;
if (original)
{
int values = 0;
while (original[values])
{
values++;
}
array = (char**)MXS_MALLOC(sizeof(char*) * (values + 1));
if (array)
{
for (int i = 0; i < values; i++)
{
array[i] = MXS_STRDUP_A(original[i]);
}
array[values] = NULL;
}
}
return array;
}
/** Helper function for freeing an array of strings */
static void free_string_array(char** array)
{
if (array)
{
for (int i = 0; array[i]; i++)
{
MXS_FREE(array[i]);
}
MXS_FREE(array);
}
}
/** /**
* Start a service * Start a service
* *
@ -478,9 +436,8 @@ int serviceInitialize(SERVICE *service)
service_calculate_weights(service); service_calculate_weights(service);
int listeners = 0; int listeners = 0;
char **router_options = copy_string_array(service->routerOptions);
if ((service->router_instance = service->router->createInstance(service, router_options))) if ((service->router_instance = service->router->createInstance(service, service->svc_config_param)))
{ {
if (service->router->getCapabilities) if (service->router->getCapabilities)
{ {
@ -503,8 +460,6 @@ int serviceInitialize(SERVICE *service)
service->state = SERVICE_STATE_FAILED; service->state = SERVICE_STATE_FAILED;
} }
free_string_array(router_options);
return listeners; return listeners;
} }
@ -959,62 +914,6 @@ serviceHasBackend(SERVICE *service, SERVER *server)
return ptr != NULL; return ptr != NULL;
} }
/**
* Add a router option to a service
*
* @param service The service to add the router option to
* @param option The option string
*/
void
serviceAddRouterOption(SERVICE *service, char *option)
{
int i;
spinlock_acquire(&service->spin);
if (service->routerOptions == NULL)
{
service->routerOptions = (char **)MXS_CALLOC(2, sizeof(char *));
MXS_ABORT_IF_NULL(service->routerOptions);
service->routerOptions[0] = MXS_STRDUP_A(option);
service->routerOptions[1] = NULL;
}
else
{
for (i = 0; service->routerOptions[i]; i++)
{
;
}
service->routerOptions = (char **)MXS_REALLOC(service->routerOptions, (i + 2) * sizeof(char *));
MXS_ABORT_IF_NULL(service->routerOptions);
service->routerOptions[i] = MXS_STRDUP_A(option);
service->routerOptions[i + 1] = NULL;
}
spinlock_release(&service->spin);
}
/**
* Remove the router options for the service
*
* @param service The service to remove the options from
*/
void
serviceClearRouterOptions(SERVICE *service)
{
int i;
spinlock_acquire(&service->spin);
if (service->routerOptions != NULL)
{
for (i = 0; service->routerOptions[i]; i++)
{
MXS_FREE(service->routerOptions[i]);
}
MXS_FREE(service->routerOptions);
service->routerOptions = NULL;
}
spinlock_release(&service->spin);
}
/** /**
* Set the service user that is used to log in to the backebd servers * Set the service user that is used to log in to the backebd servers
* associated with this service. * associated with this service.
@ -2427,18 +2326,7 @@ json_t* service_parameters_to_json(const SERVICE* service)
{ {
json_t* rval = json_object(); json_t* rval = json_object();
string options; string options{config_get_string(service->svc_config_param, "router_options")};
if (service->routerOptions && service->routerOptions[0])
{
options += service->routerOptions[0];
for (int i = 1; service->routerOptions[i]; i++)
{
options += ",";
options += service->routerOptions[i];
}
}
json_object_set_new(rval, CN_ROUTER_OPTIONS, json_string(options.c_str())); json_object_set_new(rval, CN_ROUTER_OPTIONS, json_string(options.c_str()));
json_object_set_new(rval, CN_USER, json_string(service->credentials.name)); json_object_set_new(rval, CN_USER, json_string(service->credentials.name));

View File

@ -62,7 +62,6 @@ using namespace maxscale;
*/ */
void Avro::read_source_service_options(SERVICE* source) void Avro::read_source_service_options(SERVICE* source)
{ {
char** options = source->routerOptions;
MXS_CONFIG_PARAMETER* params = source->svc_config_param; MXS_CONFIG_PARAMETER* params = source->svc_config_param;
for (MXS_CONFIG_PARAMETER* p = params; p; p = p->next) for (MXS_CONFIG_PARAMETER* p = params; p; p = p->next)
@ -77,28 +76,17 @@ void Avro::read_source_service_options(SERVICE* source)
} }
} }
if (options) for (auto&& opt: mxs::strtok(config_get_string(params, "router_options"), ", \t"))
{ {
for (int i = 0; options[i]; i++) auto&& kv = mxs::strtok(opt, "=");
if (kv[0] == "binlogdir")
{ {
char option[strlen(options[i]) + 1]; binlogdir = kv[1];
strcpy(option, options[i]); }
else if (kv[0] == "filestem")
char *value = strchr(option, '='); {
if (value) filestem = kv[1];
{
*value++ = '\0';
value = trim(value);
if (strcmp(option, "binlogdir") == 0)
{
binlogdir = value;
}
else if (strcmp(option, "filestem") == 0)
{
filestem = value;
}
}
} }
} }
} }

View File

@ -59,7 +59,7 @@ static bool conversion_task_ctl(Avro *inst, bool start);
* *
* @return The instance data for this new instance * @return The instance data for this new instance
*/ */
MXS_ROUTER* createInstance(SERVICE *service, char **options) MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
{ {
uint64_t block_size = config_get_size(service->svc_config_param, "block_size"); uint64_t block_size = config_get_size(service->svc_config_param, "block_size");
mxs_avro_codec_type codec = static_cast<mxs_avro_codec_type>(config_get_enum(service->svc_config_param, mxs_avro_codec_type codec = static_cast<mxs_avro_codec_type>(config_get_enum(service->svc_config_param,

View File

@ -54,7 +54,7 @@
#include <maxscale/paths.h> #include <maxscale/paths.h>
/* The router entry points */ /* The router entry points */
static MXS_ROUTER *createInstance(SERVICE *service, char **options); static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params);
static void free_instance(ROUTER_INSTANCE *instance); static void free_instance(ROUTER_INSTANCE *instance);
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance,
MXS_SESSION *session); MXS_SESSION *session);
@ -233,8 +233,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
* *
* @return The instance data for this new instance * @return The instance data for this new instance
*/ */
static MXS_ROUTER * static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
createInstance(SERVICE *service, char **options)
{ {
ROUTER_INSTANCE *inst; ROUTER_INSTANCE *inst;
uuid_t defuuid; uuid_t defuuid;
@ -322,8 +321,6 @@ createInstance(SERVICE *service, char **options)
strcpy(inst->binlog_name, ""); strcpy(inst->binlog_name, "");
strcpy(inst->prevbinlog, ""); strcpy(inst->prevbinlog, "");
MXS_CONFIG_PARAMETER *params = service->svc_config_param;
inst->initbinlog = config_get_integer(params, "file"); inst->initbinlog = config_get_integer(params, "file");
inst->short_burst = config_get_integer(params, "shortburst"); inst->short_burst = config_get_integer(params, "shortburst");

View File

@ -25,7 +25,7 @@ Cat::~Cat()
{ {
} }
Cat* Cat::create(SERVICE* pService, char** pzOptions) Cat* Cat::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params)
{ {
return new Cat(pService); return new Cat(pService);
} }

View File

@ -25,7 +25,7 @@ class Cat: public mxs::Router<Cat, CatSession>
Cat& operator =(const Cat&) = delete; Cat& operator =(const Cat&) = delete;
public: public:
~Cat(); ~Cat();
static Cat* create(SERVICE* pService, char** pzOptions); static Cat* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
CatSession* newSession(MXS_SESSION* pSession); CatSession* newSession(MXS_SESSION* pSession);
void diagnostics(DCB* pDcb); void diagnostics(DCB* pDcb);
json_t* diagnostics_json() const; json_t* diagnostics_json() const;

View File

@ -43,7 +43,7 @@
#include <maxscale/log_manager.h> #include <maxscale/log_manager.h>
/* The router entry points */ /* The router entry points */
static MXS_ROUTER *createInstance(SERVICE *service, char **options); static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params);
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session);
static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
@ -116,11 +116,9 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
* *
* @return The instance data for this new instance * @return The instance data for this new instance
*/ */
static MXS_ROUTER * static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
createInstance(SERVICE *service, char **options)
{ {
CLI_INSTANCE *inst; CLI_INSTANCE *inst;
int i;
if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL) if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL)
{ {
@ -131,14 +129,6 @@ createInstance(SERVICE *service, char **options)
spinlock_init(&inst->lock); spinlock_init(&inst->lock);
inst->sessions = NULL; inst->sessions = NULL;
if (options)
{
for (i = 0; options[i]; i++)
{
MXS_ERROR("Unknown option for CLI '%s'", options[i]);
}
}
/* /*
* We have completed the creation of the instance data, so now * We have completed the creation of the instance data, so now
* insert this router instance into the linked list of routers * insert this router instance into the linked list of routers

View File

@ -42,7 +42,7 @@
#include <maxscale/log_manager.h> #include <maxscale/log_manager.h>
/* The router entry points */ /* The router entry points */
static MXS_ROUTER *createInstance(SERVICE *service, char **options); static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params);
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session);
static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
@ -115,11 +115,9 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
* *
* @return The instance data for this new instance * @return The instance data for this new instance
*/ */
static MXS_ROUTER * static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params)
createInstance(SERVICE *service, char **options)
{ {
CLI_INSTANCE *inst; CLI_INSTANCE *inst;
int i;
if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL) if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL)
{ {

View File

@ -54,11 +54,10 @@ HintRouter::HintRouter(SERVICE* pService, HINT_TYPE default_action, string& defa
} }
//static //static
HintRouter* HintRouter::create(SERVICE* pService, char** pzOptions) HintRouter* HintRouter::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params)
{ {
HR_ENTRY(); HR_ENTRY();
MXS_CONFIG_PARAMETER* params = pService->svc_config_param;
HINT_TYPE default_action = (HINT_TYPE)config_get_enum(params, DEFAULT_ACTION, HINT_TYPE default_action = (HINT_TYPE)config_get_enum(params, DEFAULT_ACTION,
default_action_values); default_action_values);
string default_server(config_get_string(params, DEFAULT_SERVER)); string default_server(config_get_string(params, DEFAULT_SERVER));

View File

@ -20,7 +20,7 @@
class HintRouter : public maxscale::Router<HintRouter, HintRouterSession> class HintRouter : public maxscale::Router<HintRouter, HintRouterSession>
{ {
public: public:
static HintRouter* create(SERVICE* pService, char** pzOptions); static HintRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
HintRouterSession* newSession(MXS_SESSION *pSession); HintRouterSession* newSession(MXS_SESSION *pSession);
void diagnostics(DCB* pOut); void diagnostics(DCB* pOut);
json_t* diagnostics_json() const; json_t* diagnostics_json() const;

View File

@ -66,7 +66,7 @@ static int handle_url(INFO_INSTANCE *instance, INFO_SESSION *router_session, GWB
static int maxinfo_send_ok(DCB *dcb); static int maxinfo_send_ok(DCB *dcb);
/* The router entry points */ /* The router entry points */
static MXS_ROUTER *createInstance(SERVICE *service, char **options); static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params);
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session);
static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
@ -143,8 +143,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
* *
* @return The instance data for this new instance * @return The instance data for this new instance
*/ */
static MXS_ROUTER * static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
createInstance(SERVICE *service, char **options)
{ {
INFO_INSTANCE *inst; INFO_INSTANCE *inst;
int i; int i;
@ -158,14 +157,6 @@ createInstance(SERVICE *service, char **options)
inst->service = service; inst->service = service;
spinlock_init(&inst->lock); spinlock_init(&inst->lock);
if (options)
{
for (i = 0; options[i]; i++)
{
MXS_ERROR("Unknown option for MaxInfo '%s'", options[i]);
}
}
/* /*
* We have completed the creation of the instance data, so now * We have completed the creation of the instance data, so now
* insert this router instance into the linked list of routers * insert this router instance into the linked list of routers

View File

@ -91,7 +91,7 @@
#include <maxscale/utils.hh> #include <maxscale/utils.hh>
/* The router entry points */ /* The router entry points */
static MXS_ROUTER *createInstance(SERVICE *service, char **options); static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params);
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session);
static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
@ -234,7 +234,7 @@ static bool configureInstance(MXS_ROUTER* instance, MXS_CONFIG_PARAMETER* params
* *
* @return The instance data for this new instance * @return The instance data for this new instance
*/ */
static MXS_ROUTER* createInstance(SERVICE *service, char **options) static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
{ {
ROUTER_INSTANCE* inst = static_cast<ROUTER_INSTANCE*>(MXS_CALLOC(1, sizeof(ROUTER_INSTANCE))); ROUTER_INSTANCE* inst = static_cast<ROUTER_INSTANCE*>(MXS_CALLOC(1, sizeof(ROUTER_INSTANCE)));
@ -245,7 +245,7 @@ static MXS_ROUTER* createInstance(SERVICE *service, char **options)
spinlock_init(&inst->lock); spinlock_init(&inst->lock);
inst->bitmask_and_bitvalue = 0; inst->bitmask_and_bitvalue = 0;
if (!configureInstance((MXS_ROUTER*)inst, service->svc_config_param)) if (!configureInstance((MXS_ROUTER*)inst, params))
{ {
free_readconn_instance(inst); free_readconn_instance(inst);
inst = nullptr; inst = nullptr;

View File

@ -273,13 +273,11 @@ bool RWSplit::have_enough_servers() const
*/ */
RWSplit* RWSplit::create(SERVICE *service, char **options) RWSplit* RWSplit::create(SERVICE *service, MXS_CONFIG_PARAMETER* params)
{ {
MXS_CONFIG_PARAMETER* params = service->svc_config_param;
SConfig config(new Config(params)); SConfig config(new Config(params));
if (!handle_max_slaves(config, config_get_string(params, "max_slave_connections")) || if (!handle_max_slaves(config, config_get_string(params, "max_slave_connections")))
(options && !rwsplit_process_router_options(config, options)))
{ {
return NULL; return NULL;
} }

View File

@ -256,7 +256,7 @@ public:
* *
* @return New router instance or NULL on error * @return New router instance or NULL on error
*/ */
static RWSplit* create(SERVICE* pService, char** pzOptions); static RWSplit* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
/** /**
* @brief Create a new session for this router instance * @brief Create a new session for this router instance

View File

@ -54,18 +54,16 @@ SchemaRouter::~SchemaRouter()
{ {
} }
SchemaRouter* SchemaRouter::create(SERVICE* pService, char** pzOptions) SchemaRouter* SchemaRouter::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params)
{ {
MXS_CONFIG_PARAMETER* conf = pService->svc_config_param; if ((config_get_param(params, "auth_all_servers")) == NULL)
if ((config_get_param(conf, "auth_all_servers")) == NULL)
{ {
MXS_NOTICE("Authentication data is fetched from all servers. To disable this " MXS_NOTICE("Authentication data is fetched from all servers. To disable this "
"add 'auth_all_servers=0' to the service."); "add 'auth_all_servers=0' to the service.");
pService->users_from_all = true; pService->users_from_all = true;
} }
SConfig config(new Config(pService->svc_config_param)); SConfig config(new Config(params));
return new SchemaRouter(pService, config); return new SchemaRouter(pService, config);
} }

View File

@ -34,7 +34,7 @@ class SchemaRouter: public mxs::Router<SchemaRouter, SchemaRouterSession>
{ {
public: public:
~SchemaRouter(); ~SchemaRouter();
static SchemaRouter* create(SERVICE* pService, char** pzOptions); static SchemaRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
SchemaRouterSession* newSession(MXS_SESSION* pSession); SchemaRouterSession* newSession(MXS_SESSION* pSession);
void diagnostics(DCB* pDcb); void diagnostics(DCB* pDcb);
json_t* diagnostics_json() const; json_t* diagnostics_json() const;