Add skeleton hint router

The hint router will perform its scheduling solely based upon hints
provided by a filter (e.g. namedserverfilter) placed before it.
This commit is contained in:
Johan Wikman
2017-03-03 15:35:37 +02:00
parent 7f9fdd0f3d
commit 4cd9309b30
6 changed files with 213 additions and 0 deletions

View File

@ -7,6 +7,7 @@ endif()
add_subdirectory(cli)
add_subdirectory(debugcli)
add_subdirectory(hintrouter)
add_subdirectory(maxinfo)
add_subdirectory(readconnroute)
add_subdirectory(readwritesplit)

View File

@ -0,0 +1,8 @@
add_library(hintrouter SHARED
hintrouter.cc
hintroutersession.cc
)
target_link_libraries(hintrouter maxscale-common)
set_target_properties(hintrouter PROPERTIES VERSION "1.0.0")
install_module(hintrouter core)

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#define MXS_MODULE_NAME "hintrouter"
#include "hintrouter.hh"
#include <maxscale/log_manager.h>
HintRouter::HintRouter(SERVICE* pService)
: maxscale::Router<HintRouter, HintRouterSession>(pService)
{
MXS_NOTICE("Hint router [%s] created.", pService->name);
}
//static
HintRouter* HintRouter::create(SERVICE* pService, char** pzOptions)
{
return new HintRouter(pService);
}
HintRouterSession* HintRouter::newSession(MXS_SESSION *pSession)
{
return new HintRouterSession(pSession, this);
}
void HintRouter::diagnostics(DCB* pOut)
{
}
uint64_t HintRouter::getCapabilities()
{
return 0;
}
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{
static MXS_MODULE module =
{
MXS_MODULE_API_ROUTER, /* Module type */
MXS_MODULE_BETA_RELEASE, /* Release status */
MXS_ROUTER_VERSION, /* Implemented module API version */
"A hint router", /* Description */
"V1.0.0", /* Module version */
&HintRouter::s_object,
NULL, /* Process init, can be null */
NULL, /* Process finish, can be null */
NULL, /* Thread init */
NULL, /* Thread finish */
{
{MXS_END_MODULE_PARAMS}
}
};
return &module;
}

View File

@ -0,0 +1,36 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxscale/cppdefs.hh>
#include <maxscale/router.hh>
#include "hintroutersession.hh"
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();
private:
HintRouter(SERVICE* pService);
private:
HintRouter(const HintRouter&);
HintRouter& operator = (const HintRouter&);
};

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#define MXS_MODULE_NAME "hintrouter"
#include "hintroutersession.hh"
#include <maxscale/log_manager.h>
HintRouterSession::HintRouterSession(MXS_SESSION* pSession, HintRouter* pRouter)
: maxscale::RouterSession(pSession)
, m_pRouter(pRouter)
{
}
HintRouterSession::~HintRouterSession()
{
}
void HintRouterSession::close()
{
}
int32_t HintRouterSession::routeQuery(GWBUF* pPacket)
{
MXS_ERROR("routeQuery not implemented yet.");
return 0;
}
void HintRouterSession::clientReply(GWBUF* pPacket, DCB* pBackend)
{
MXS_ERROR("clientReply not implemented yet.");
}
void HintRouterSession::handleError(GWBUF* pMessage,
DCB* pProblem,
mxs_error_action_t action,
bool* pSuccess)
{
MXS_ERROR("handleError not implemented yet.");
}

View File

@ -0,0 +1,45 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxscale/cppdefs.hh>
#include <maxscale/router.hh>
class HintRouter;
class HintRouterSession : public maxscale::RouterSession
{
public:
HintRouterSession(MXS_SESSION* pSession,
HintRouter* pRouter);
~HintRouterSession();
void close();
int32_t routeQuery(GWBUF* pPacket);
void clientReply(GWBUF* pPacket, DCB* pBackend);
void handleError(GWBUF* pMessage,
DCB* pProblem,
mxs_error_action_t action,
bool* pSuccess);
private:
HintRouterSession(const HintRouterSession&);
HintRouterSession& operator = (const HintRouterSession&);
private:
HintRouter* m_pRouter;
};