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:
@ -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 (!serviceSetFilters(service, filters))
|
||||
|
@ -110,12 +110,6 @@ bool service_server_in_use(const SERVER *server);
|
||||
/** Update the server weights used by services */
|
||||
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
|
||||
*
|
||||
|
@ -127,7 +127,6 @@ SERVICE* service_alloc(const char *name, const char *router)
|
||||
service->retry_start = true;
|
||||
service->conn_idle_timeout = SERVICE_NO_SESSION_TIMEOUT;
|
||||
service->svc_config_param = NULL;
|
||||
service->routerOptions = NULL;
|
||||
service->log_auth_warnings = true;
|
||||
service->strip_db_esc = true;
|
||||
service->rate_limits = rate_limits;
|
||||
@ -420,47 +419,6 @@ int serviceStartAllPorts(SERVICE* service)
|
||||
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
|
||||
*
|
||||
@ -478,9 +436,8 @@ int serviceInitialize(SERVICE *service)
|
||||
service_calculate_weights(service);
|
||||
|
||||
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)
|
||||
{
|
||||
@ -503,8 +460,6 @@ int serviceInitialize(SERVICE *service)
|
||||
service->state = SERVICE_STATE_FAILED;
|
||||
}
|
||||
|
||||
free_string_array(router_options);
|
||||
|
||||
return listeners;
|
||||
}
|
||||
|
||||
@ -959,62 +914,6 @@ serviceHasBackend(SERVICE *service, SERVER *server)
|
||||
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
|
||||
* associated with this service.
|
||||
@ -2427,18 +2326,7 @@ json_t* service_parameters_to_json(const SERVICE* service)
|
||||
{
|
||||
json_t* rval = json_object();
|
||||
|
||||
string options;
|
||||
|
||||
if (service->routerOptions && service->routerOptions[0])
|
||||
{
|
||||
options += service->routerOptions[0];
|
||||
|
||||
for (int i = 1; service->routerOptions[i]; i++)
|
||||
{
|
||||
options += ",";
|
||||
options += service->routerOptions[i];
|
||||
}
|
||||
}
|
||||
string options{config_get_string(service->svc_config_param, "router_options")};
|
||||
|
||||
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));
|
||||
|
@ -62,7 +62,6 @@ using namespace maxscale;
|
||||
*/
|
||||
void Avro::read_source_service_options(SERVICE* source)
|
||||
{
|
||||
char** options = source->routerOptions;
|
||||
MXS_CONFIG_PARAMETER* params = source->svc_config_param;
|
||||
|
||||
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];
|
||||
strcpy(option, options[i]);
|
||||
|
||||
char *value = strchr(option, '=');
|
||||
if (value)
|
||||
{
|
||||
*value++ = '\0';
|
||||
value = trim(value);
|
||||
|
||||
if (strcmp(option, "binlogdir") == 0)
|
||||
{
|
||||
binlogdir = value;
|
||||
}
|
||||
else if (strcmp(option, "filestem") == 0)
|
||||
{
|
||||
filestem = value;
|
||||
}
|
||||
}
|
||||
binlogdir = kv[1];
|
||||
}
|
||||
else if (kv[0] == "filestem")
|
||||
{
|
||||
filestem = kv[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ static bool conversion_task_ctl(Avro *inst, bool start);
|
||||
*
|
||||
* @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");
|
||||
mxs_avro_codec_type codec = static_cast<mxs_avro_codec_type>(config_get_enum(service->svc_config_param,
|
||||
|
@ -54,7 +54,7 @@
|
||||
#include <maxscale/paths.h>
|
||||
|
||||
/* 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 MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance,
|
||||
MXS_SESSION *session);
|
||||
@ -233,8 +233,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
*
|
||||
* @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;
|
||||
uuid_t defuuid;
|
||||
@ -322,8 +321,6 @@ createInstance(SERVICE *service, char **options)
|
||||
strcpy(inst->binlog_name, "");
|
||||
strcpy(inst->prevbinlog, "");
|
||||
|
||||
MXS_CONFIG_PARAMETER *params = service->svc_config_param;
|
||||
|
||||
inst->initbinlog = config_get_integer(params, "file");
|
||||
|
||||
inst->short_burst = config_get_integer(params, "shortburst");
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class Cat: public mxs::Router<Cat, CatSession>
|
||||
Cat& operator =(const Cat&) = delete;
|
||||
public:
|
||||
~Cat();
|
||||
static Cat* create(SERVICE* pService, char** pzOptions);
|
||||
static Cat* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
|
||||
CatSession* newSession(MXS_SESSION* pSession);
|
||||
void diagnostics(DCB* pDcb);
|
||||
json_t* diagnostics_json() const;
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <maxscale/log_manager.h>
|
||||
|
||||
/* 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 void closeSession(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
|
||||
*/
|
||||
static MXS_ROUTER *
|
||||
createInstance(SERVICE *service, char **options)
|
||||
static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
CLI_INSTANCE *inst;
|
||||
int i;
|
||||
|
||||
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);
|
||||
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
|
||||
* insert this router instance into the linked list of routers
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include <maxscale/log_manager.h>
|
||||
|
||||
/* 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 void closeSession(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
|
||||
*/
|
||||
static MXS_ROUTER *
|
||||
createInstance(SERVICE *service, char **options)
|
||||
static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
CLI_INSTANCE *inst;
|
||||
int i;
|
||||
|
||||
if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL)
|
||||
{
|
||||
|
@ -54,11 +54,10 @@ HintRouter::HintRouter(SERVICE* pService, HINT_TYPE default_action, string& defa
|
||||
}
|
||||
|
||||
//static
|
||||
HintRouter* HintRouter::create(SERVICE* pService, char** pzOptions)
|
||||
HintRouter* HintRouter::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
HR_ENTRY();
|
||||
|
||||
MXS_CONFIG_PARAMETER* params = pService->svc_config_param;
|
||||
HINT_TYPE default_action = (HINT_TYPE)config_get_enum(params, DEFAULT_ACTION,
|
||||
default_action_values);
|
||||
string default_server(config_get_string(params, DEFAULT_SERVER));
|
||||
|
@ -20,7 +20,7 @@
|
||||
class HintRouter : public maxscale::Router<HintRouter, HintRouterSession>
|
||||
{
|
||||
public:
|
||||
static HintRouter* create(SERVICE* pService, char** pzOptions);
|
||||
static HintRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
|
||||
HintRouterSession* newSession(MXS_SESSION *pSession);
|
||||
void diagnostics(DCB* pOut);
|
||||
json_t* diagnostics_json() const;
|
||||
|
@ -66,7 +66,7 @@ static int handle_url(INFO_INSTANCE *instance, INFO_SESSION *router_session, GWB
|
||||
static int maxinfo_send_ok(DCB *dcb);
|
||||
|
||||
/* 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 void closeSession(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
|
||||
*/
|
||||
static MXS_ROUTER *
|
||||
createInstance(SERVICE *service, char **options)
|
||||
static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
INFO_INSTANCE *inst;
|
||||
int i;
|
||||
@ -158,14 +157,6 @@ createInstance(SERVICE *service, char **options)
|
||||
inst->service = service;
|
||||
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
|
||||
* insert this router instance into the linked list of routers
|
||||
|
@ -91,7 +91,7 @@
|
||||
#include <maxscale/utils.hh>
|
||||
|
||||
/* 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 void closeSession(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
|
||||
*/
|
||||
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)));
|
||||
|
||||
@ -245,7 +245,7 @@ static MXS_ROUTER* createInstance(SERVICE *service, char **options)
|
||||
spinlock_init(&inst->lock);
|
||||
inst->bitmask_and_bitvalue = 0;
|
||||
|
||||
if (!configureInstance((MXS_ROUTER*)inst, service->svc_config_param))
|
||||
if (!configureInstance((MXS_ROUTER*)inst, params))
|
||||
{
|
||||
free_readconn_instance(inst);
|
||||
inst = nullptr;
|
||||
|
@ -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));
|
||||
|
||||
if (!handle_max_slaves(config, config_get_string(params, "max_slave_connections")) ||
|
||||
(options && !rwsplit_process_router_options(config, options)))
|
||||
if (!handle_max_slaves(config, config_get_string(params, "max_slave_connections")))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ public:
|
||||
*
|
||||
* @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
|
||||
|
@ -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(conf, "auth_all_servers")) == NULL)
|
||||
if ((config_get_param(params, "auth_all_servers")) == NULL)
|
||||
{
|
||||
MXS_NOTICE("Authentication data is fetched from all servers. To disable this "
|
||||
"add 'auth_all_servers=0' to the service.");
|
||||
pService->users_from_all = true;
|
||||
}
|
||||
|
||||
SConfig config(new Config(pService->svc_config_param));
|
||||
SConfig config(new Config(params));
|
||||
return new SchemaRouter(pService, config);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class SchemaRouter: public mxs::Router<SchemaRouter, SchemaRouterSession>
|
||||
{
|
||||
public:
|
||||
~SchemaRouter();
|
||||
static SchemaRouter* create(SERVICE* pService, char** pzOptions);
|
||||
static SchemaRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
|
||||
SchemaRouterSession* newSession(MXS_SESSION* pSession);
|
||||
void diagnostics(DCB* pDcb);
|
||||
json_t* diagnostics_json() const;
|
||||
|
Reference in New Issue
Block a user