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:
@ -7,6 +7,7 @@ endif()
|
||||
|
||||
add_subdirectory(cli)
|
||||
add_subdirectory(debugcli)
|
||||
add_subdirectory(hintrouter)
|
||||
add_subdirectory(maxinfo)
|
||||
add_subdirectory(readconnroute)
|
||||
add_subdirectory(readwritesplit)
|
||||
|
8
server/modules/routing/hintrouter/CMakeLists.txt
Normal file
8
server/modules/routing/hintrouter/CMakeLists.txt
Normal 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)
|
68
server/modules/routing/hintrouter/hintrouter.cc
Normal file
68
server/modules/routing/hintrouter/hintrouter.cc
Normal 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;
|
||||
}
|
36
server/modules/routing/hintrouter/hintrouter.hh
Normal file
36
server/modules/routing/hintrouter/hintrouter.hh
Normal 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&);
|
||||
};
|
55
server/modules/routing/hintrouter/hintroutersession.cc
Normal file
55
server/modules/routing/hintrouter/hintroutersession.cc
Normal 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.");
|
||||
}
|
45
server/modules/routing/hintrouter/hintroutersession.hh
Normal file
45
server/modules/routing/hintrouter/hintroutersession.hh
Normal 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;
|
||||
};
|
Reference in New Issue
Block a user