HintRouter: Support various hint types, round-robin rotate slaves

Supports hint types:
-master
-slave
-named server
-all

A default action, which is performed when no hint exists or on error,
can be set. The different actions are analogous to the hint types.

A maximum connection number for slaves can be set. If more slaves are
configured for the service, the filter will rotate slaves for new sessions.

Within a session with multiple slaves, the "route_to_slave"-hint will
also rotate among the slave backends.
This commit is contained in:
Esa Korhonen
2017-03-27 10:07:51 +03:00
parent ddcd1f960c
commit 90c249a8b2
5 changed files with 377 additions and 93 deletions

View File

@ -13,6 +13,7 @@
*/
#include "hintrouterdefs.hh"
#include <maxscale/router.hh>
#include "hintroutersession.hh"
@ -20,15 +21,25 @@ class HintRouter : public maxscale::Router<HintRouter, HintRouterSession>
{
public:
static HintRouter* create(SERVICE* pService, char** pzOptions);
HintRouterSession* newSession(MXS_SESSION *pSession);
void diagnostics(DCB* pOut);
uint64_t getCapabilities();
HINT_TYPE get_default_action() const
{
return m_default_action;
};
const string& get_default_server() const
{
return m_default_server;
};
private:
HintRouter(SERVICE* pService);
HintRouter(SERVICE* pService, HINT_TYPE default_action, string& default_server,
int max_slaves);
HINT_TYPE m_default_action;
string m_default_server;
int m_max_slaves;
volatile int m_total_slave_conns;
private:
HintRouter(const HintRouter&);