Add reconfiguration to router API
Added a new router API entry point that allows configuration changes after the instance has been created. This makes alterations to most service parameters at runtime possible. An option to reconfiguration would have been the creation of a new service and the eventual destruction of the old one. This would be a more complicated and costly method but from an architectural point of view it is interesting. The actual implementation of the configuration change is left to the router. Currently, only readwritesplit performs reconfiguration as implementing it with versioned configurations is very easy. Versioned configurations can be considered an adequate first step but it is not an optimal solution as it causes a bottleneck in the reference counting of the shared configuration. Thread-specific configuration definitions would make for a more efficient solution but the implementation is more complex.
This commit is contained in:
@ -130,6 +130,13 @@ template<class RouterType, class RouterSessionType>
|
||||
class Router : public MXS_ROUTER
|
||||
{
|
||||
public:
|
||||
|
||||
// The default configure entry point, does nothing and always fails
|
||||
bool configure(MXS_CONFIG_PARAMETER* param)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static MXS_ROUTER* createInstance(SERVICE* pService, char** pzOptions)
|
||||
{
|
||||
RouterType* pRouter = NULL;
|
||||
@ -228,6 +235,14 @@ public:
|
||||
MXS_EXCEPTION_GUARD(delete pRouter);
|
||||
}
|
||||
|
||||
static bool configure(MXS_ROUTER* pInstance, MXS_CONFIG_PARAMETER* param)
|
||||
{
|
||||
RouterType* pRouter = static_cast<RouterType*>(pInstance);
|
||||
bool rval = false;
|
||||
MXS_EXCEPTION_GUARD(rval = pRouter->configure(param));
|
||||
return rval;
|
||||
}
|
||||
|
||||
static MXS_ROUTER_OBJECT s_object;
|
||||
|
||||
protected:
|
||||
@ -254,6 +269,7 @@ MXS_ROUTER_OBJECT Router<RouterType, RouterSessionType>::s_object =
|
||||
&Router<RouterType, RouterSessionType>::handleError,
|
||||
&Router<RouterType, RouterSessionType>::getCapabilities,
|
||||
&Router<RouterType, RouterSessionType>::destroyInstance,
|
||||
&Router<RouterType, RouterSessionType>::configure,
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user