Move testfilter, router etc to examples
Also changed Plugin devel manual to match. Modified roundrobinrouter to use static_cast due to the change in router api definitions.
This commit is contained in:
@ -187,10 +187,12 @@ add_subdirectory(plugins)
|
|||||||
add_subdirectory(query_classifier)
|
add_subdirectory(query_classifier)
|
||||||
add_subdirectory(server)
|
add_subdirectory(server)
|
||||||
add_subdirectory(include/maxscale)
|
add_subdirectory(include/maxscale)
|
||||||
add_subdirectory(Documentation)
|
|
||||||
if(NOT WITHOUT_MAXADMIN)
|
if(NOT WITHOUT_MAXADMIN)
|
||||||
add_subdirectory(client)
|
add_subdirectory(client)
|
||||||
endif()
|
endif()
|
||||||
|
if(BUILD_TESTS)
|
||||||
|
add_subdirectory(examples)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Generate text versions of some documents
|
# Generate text versions of some documents
|
||||||
execute_process(COMMAND perl ${CMAKE_SOURCE_DIR}/Documentation/format.pl
|
execute_process(COMMAND perl ${CMAKE_SOURCE_DIR}/Documentation/format.pl
|
||||||
|
@ -1 +0,0 @@
|
|||||||
install_custom_file(Plugin-development-guide.md ${CMAKE_INSTALL_INCLUDEDIR}/maxscale/Documentation devel)
|
|
@ -43,8 +43,8 @@ modules are written in C++.
|
|||||||
|
|
||||||
The *RoundRobinRouter* is a practical example of a simple router plugin. The
|
The *RoundRobinRouter* is a practical example of a simple router plugin. The
|
||||||
RoundRobinRouter is compiled, installed and ran in [section
|
RoundRobinRouter is compiled, installed and ran in [section
|
||||||
5.1](#hands-on-example:-roundrobinrouter). The source for the router is included
|
5.1](#hands-on-example:-roundrobinrouter). The source for the router is located
|
||||||
in the plugin development package.
|
in the `examples`-folder.
|
||||||
|
|
||||||
## Module categories
|
## Module categories
|
||||||
|
|
@ -128,6 +128,7 @@ document.
|
|||||||
- [Binlog Router Design (in development)](http://mariadb-corporation.github.io/MaxScale/Design-Documents/binlog-router-html-docs)
|
- [Binlog Router Design (in development)](http://mariadb-corporation.github.io/MaxScale/Design-Documents/binlog-router-html-docs)
|
||||||
- [DCB States (to be replaced in StarUML)](Design-Documents/DCB-States.pdf)
|
- [DCB States (to be replaced in StarUML)](Design-Documents/DCB-States.pdf)
|
||||||
- [Schema Sharding Router Technical Documentation](Design-Documents/SchemaRouter-technical.md)
|
- [Schema Sharding Router Technical Documentation](Design-Documents/SchemaRouter-technical.md)
|
||||||
|
- [Plugin development guide](Design-Documents/Plugin-development-guide.md)
|
||||||
|
|
||||||
## Earlier Release Notes
|
## Earlier Release Notes
|
||||||
|
|
||||||
@ -145,4 +146,3 @@ document.
|
|||||||
- [MariaDB MaxScale 0.7 Release Notes](Release-Notes/MaxScale-0.7-Release-Notes.md)
|
- [MariaDB MaxScale 0.7 Release Notes](Release-Notes/MaxScale-0.7-Release-Notes.md)
|
||||||
- [MariaDB MaxScale 0.6 Release Notes](Release-Notes/MaxScale-0.6-Release-Notes.md)
|
- [MariaDB MaxScale 0.6 Release Notes](Release-Notes/MaxScale-0.6-Release-Notes.md)
|
||||||
- [MariaDB MaxScale 0.5 Release Notes](Release-Notes/MaxScale-0.5-Release-Notes.md)
|
- [MariaDB MaxScale 0.5 Release Notes](Release-Notes/MaxScale-0.5-Release-Notes.md)
|
||||||
|
|
||||||
|
20
examples/CMakeLists.txt
Normal file
20
examples/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
include_directories(${MARIADB_CONNECTOR_INCLUDE_DIR})
|
||||||
|
|
||||||
|
add_library(roundrobinrouter SHARED roundrobinrouter.cpp)
|
||||||
|
target_link_libraries(roundrobinrouter maxscale-common)
|
||||||
|
set_target_properties(roundrobinrouter PROPERTIES VERSION "1.0.0")
|
||||||
|
install_module(roundrobinrouter core)
|
||||||
|
|
||||||
|
add_library(testroute SHARED testroute.c)
|
||||||
|
target_link_libraries(testroute maxscale-common)
|
||||||
|
set_target_properties(testroute PROPERTIES VERSION "1.0.0")
|
||||||
|
install_module(testroute core)
|
||||||
|
|
||||||
|
add_library(testfilter SHARED testfilter.c)
|
||||||
|
target_link_libraries(testfilter maxscale-common)
|
||||||
|
set_target_properties(testfilter PROPERTIES VERSION "1.0.0")
|
||||||
|
install_module(testfilter core)
|
||||||
|
|
||||||
|
add_library(testprotocol SHARED testprotocol.c)
|
||||||
|
set_target_properties(testprotocol PROPERTIES VERSION "1.0.0")
|
||||||
|
install_module(testprotocol core)
|
@ -107,7 +107,7 @@ class RRRouter;
|
|||||||
class RRRouterSession;
|
class RRRouterSession;
|
||||||
|
|
||||||
/* Each service using this router will have a router object instance. */
|
/* Each service using this router will have a router object instance. */
|
||||||
class RRRouter
|
class RRRouter : public MXS_ROUTER
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SERVICE* m_service; /* Service this router is part of */
|
SERVICE* m_service; /* Service this router is part of */
|
||||||
@ -135,7 +135,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Every client connection has a corresponding session. */
|
/* Every client connection has a corresponding session. */
|
||||||
class RRRouterSession
|
class RRRouterSession : public MXS_ROUTER_SESSION
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool m_closed; /* true when closeSession is called */
|
bool m_closed; /* true when closeSession is called */
|
||||||
@ -344,8 +344,8 @@ void RRRouter::client_reply(RRRouterSession* rses, GWBUF* buf, DCB* backend_dcb)
|
|||||||
MXS_NOTICE("Replied to client.\n");
|
MXS_NOTICE("Replied to client.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RRRouter::handle_error(RRRouterSession* rses, GWBUF* message,
|
void RRRouter::handle_error(RRRouterSession* rses, GWBUF* message, DCB* problem_dcb,
|
||||||
DCB* problem_dcb, mxs_error_action_t action, bool* succp)
|
mxs_error_action_t action, bool* succp)
|
||||||
{
|
{
|
||||||
/* Don't handle same error twice on same DCB */
|
/* Don't handle same error twice on same DCB */
|
||||||
if (problem_dcb->dcb_errhandle_called)
|
if (problem_dcb->dcb_errhandle_called)
|
||||||
@ -562,16 +562,16 @@ void RRRouter::decide_target(RRRouterSession* rses, GWBUF* querybuf, DCB*& targe
|
|||||||
* "extern C", but they do need to be callable from C code.
|
* "extern C", but they do need to be callable from C code.
|
||||||
*/
|
*/
|
||||||
static MXS_ROUTER* createInstance(SERVICE* service, char** options);
|
static MXS_ROUTER* createInstance(SERVICE* service, char** options);
|
||||||
static void* newSession(MXS_ROUTER* instance, MXS_SESSION* session);
|
static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session);
|
||||||
static void closeSession(MXS_ROUTER* instance, void* session);
|
static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session);
|
||||||
static void freeSession(MXS_ROUTER* instance, void* session);
|
static void freeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session);
|
||||||
static int routeQuery(MXS_ROUTER* instance, void* session, GWBUF* querybuf);
|
static int routeQuery(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session, GWBUF* querybuf);
|
||||||
static void diagnostics(MXS_ROUTER* instance, DCB* dcb);
|
static void diagnostics(MXS_ROUTER* instance, DCB* dcb);
|
||||||
static void clientReply(MXS_ROUTER* instance, void* router_session, GWBUF* resultbuf,
|
static void clientReply(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session,
|
||||||
DCB* backend_dcb);
|
GWBUF* resultbuf, DCB* backend_dcb);
|
||||||
static void handleError(MXS_ROUTER* instance, void* router_session,
|
static void handleError(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session,
|
||||||
GWBUF* errmsgbuf, DCB* backend_dcb,
|
GWBUF* errmsgbuf, DCB* backend_dcb, mxs_error_action_t action,
|
||||||
mxs_error_action_t action, bool* succp);
|
bool* succp);
|
||||||
static uint64_t getCapabilities(MXS_ROUTER *instance);
|
static uint64_t getCapabilities(MXS_ROUTER *instance);
|
||||||
static void destroyInstance(MXS_ROUTER* instance);
|
static void destroyInstance(MXS_ROUTER* instance);
|
||||||
/* The next two entry points are usually optional. */
|
/* The next two entry points are usually optional. */
|
||||||
@ -669,7 +669,7 @@ static MXS_ROUTER* createInstance(SERVICE* service, char** options)
|
|||||||
{
|
{
|
||||||
MXS_ERROR("Module command registration failed.");
|
MXS_ERROR("Module command registration failed.");
|
||||||
}
|
}
|
||||||
return (MXS_ROUTER*)instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -682,12 +682,12 @@ static MXS_ROUTER* createInstance(SERVICE* service, char** options)
|
|||||||
* @param session The MaxScale session (generic client connection data)
|
* @param session The MaxScale session (generic client connection data)
|
||||||
* @return Client specific data for this router
|
* @return Client specific data for this router
|
||||||
*/
|
*/
|
||||||
static void* newSession(MXS_ROUTER* instance, MXS_SESSION* session)
|
static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session)
|
||||||
{
|
{
|
||||||
RRRouter* router = (RRRouter*)instance;
|
RRRouter* router = static_cast<RRRouter*>(instance);
|
||||||
RRRouterSession* rses = NULL;
|
RRRouterSession* rses = NULL;
|
||||||
MXS_EXCEPTION_GUARD(rses = router->create_session(session));
|
MXS_EXCEPTION_GUARD(rses = router->create_session(session));
|
||||||
return (void*)rses;
|
return rses;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Close an existing router session for this router instance (API).
|
* @brief Close an existing router session for this router instance (API).
|
||||||
@ -700,9 +700,9 @@ static void* newSession(MXS_ROUTER* instance, MXS_SESSION* session)
|
|||||||
* @param instance The router object instance
|
* @param instance The router object instance
|
||||||
* @param session The router session
|
* @param session The router session
|
||||||
*/
|
*/
|
||||||
static void closeSession(MXS_ROUTER* instance, void* session)
|
static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session)
|
||||||
{
|
{
|
||||||
RRRouterSession* rses = (RRRouterSession*)session;
|
RRRouterSession* rses = static_cast<RRRouterSession*>(session);
|
||||||
MXS_EXCEPTION_GUARD(rses->close());
|
MXS_EXCEPTION_GUARD(rses->close());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,9 +716,9 @@ static void closeSession(MXS_ROUTER* instance, void* session)
|
|||||||
* @param session Router client session
|
* @param session Router client session
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void freeSession(MXS_ROUTER* instance, void* session)
|
static void freeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session)
|
||||||
{
|
{
|
||||||
RRRouterSession* rses = (RRRouterSession*)session;
|
RRRouterSession* rses = static_cast<RRRouterSession*>(session);
|
||||||
delete rses;
|
delete rses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,10 +734,10 @@ static void freeSession(MXS_ROUTER* instance, void* session)
|
|||||||
* @param buffer Buffer containing the query (or command)
|
* @param buffer Buffer containing the query (or command)
|
||||||
* @return 1 on success, 0 on error
|
* @return 1 on success, 0 on error
|
||||||
*/
|
*/
|
||||||
static int routeQuery(MXS_ROUTER* instance, void* session, GWBUF* buffer)
|
static int routeQuery(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session, GWBUF* buffer)
|
||||||
{
|
{
|
||||||
RRRouter* router = (RRRouter*)instance;
|
RRRouter* router = static_cast<RRRouter*>(instance);
|
||||||
RRRouterSession* rses = (RRRouterSession*)session;
|
RRRouterSession* rses = static_cast<RRRouterSession*>(session);
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
MXS_EXCEPTION_GUARD(rval = router->route_query(rses, buffer));
|
MXS_EXCEPTION_GUARD(rval = router->route_query(rses, buffer));
|
||||||
return rval;
|
return rval;
|
||||||
@ -754,7 +754,7 @@ static int routeQuery(MXS_ROUTER* instance, void* session, GWBUF* buffer)
|
|||||||
*/
|
*/
|
||||||
static void diagnostics(MXS_ROUTER* instance, DCB* dcb)
|
static void diagnostics(MXS_ROUTER* instance, DCB* dcb)
|
||||||
{
|
{
|
||||||
RRRouter* router = (RRRouter*)instance;
|
RRRouter* router = static_cast<RRRouter*>(instance);
|
||||||
dcb_printf(dcb, "\t\tQueries routed successfully: %lu\n", router->m_routing_s);
|
dcb_printf(dcb, "\t\tQueries routed successfully: %lu\n", router->m_routing_s);
|
||||||
dcb_printf(dcb, "\t\tFailed routing attempts: %lu\n", router->m_routing_f);
|
dcb_printf(dcb, "\t\tFailed routing attempts: %lu\n", router->m_routing_f);
|
||||||
dcb_printf(dcb, "\t\tClient replies routed: %lu\n", router->m_routing_c);
|
dcb_printf(dcb, "\t\tClient replies routed: %lu\n", router->m_routing_c);
|
||||||
@ -772,11 +772,11 @@ static void diagnostics(MXS_ROUTER* instance, DCB* dcb)
|
|||||||
* @param backend_dcb The backend DCB (data source)
|
* @param backend_dcb The backend DCB (data source)
|
||||||
* @param queue The GWBUF with reply data
|
* @param queue The GWBUF with reply data
|
||||||
*/
|
*/
|
||||||
static void clientReply(MXS_ROUTER* instance, void* session, GWBUF* queue,
|
static void clientReply(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session, GWBUF* queue,
|
||||||
DCB* backend_dcb)
|
DCB* backend_dcb)
|
||||||
{
|
{
|
||||||
RRRouter* router = (RRRouter*)instance;
|
RRRouter* router = static_cast<RRRouter*>(instance);
|
||||||
RRRouterSession* rses = (RRRouterSession*)session;
|
RRRouterSession* rses = static_cast<RRRouterSession*>(session);
|
||||||
MXS_EXCEPTION_GUARD(router->client_reply(rses, queue, backend_dcb));
|
MXS_EXCEPTION_GUARD(router->client_reply(rses, queue, backend_dcb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,12 +794,12 @@ static void clientReply(MXS_ROUTER* instance, void* session, GWBUF* queue,
|
|||||||
* @param action The action: ERRACT_NEW_CONNECTION or ERRACT_REPLY_CLIENT
|
* @param action The action: ERRACT_NEW_CONNECTION or ERRACT_REPLY_CLIENT
|
||||||
* @param succp Output result of action, true if router can continue
|
* @param succp Output result of action, true if router can continue
|
||||||
*/
|
*/
|
||||||
static void handleError(MXS_ROUTER* instance, void* session,
|
static void handleError(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session,
|
||||||
GWBUF* message, DCB* problem_dcb,
|
GWBUF* message, DCB* problem_dcb,
|
||||||
mxs_error_action_t action, bool* succp)
|
mxs_error_action_t action, bool* succp)
|
||||||
{
|
{
|
||||||
RRRouter* router = (RRRouter*)instance;
|
RRRouter* router = static_cast<RRRouter*>(instance);
|
||||||
RRRouterSession* rses = (RRRouterSession*)session;
|
RRRouterSession* rses = static_cast<RRRouterSession*>(session);
|
||||||
MXS_EXCEPTION_GUARD(router->handle_error(rses, message, problem_dcb, action, succp));
|
MXS_EXCEPTION_GUARD(router->handle_error(rses, message, problem_dcb, action, succp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -832,7 +832,7 @@ static uint64_t getCapabilities(MXS_ROUTER *instance)
|
|||||||
*/
|
*/
|
||||||
static void destroyInstance(MXS_ROUTER* instance)
|
static void destroyInstance(MXS_ROUTER* instance)
|
||||||
{
|
{
|
||||||
RRRouter* router = (RRRouter*)instance;
|
RRRouter* router = static_cast<RRRouter*>(instance);
|
||||||
delete router;
|
delete router;
|
||||||
}
|
}
|
||||||
|
|
@ -10,7 +10,6 @@ add_subdirectory(nullfilter)
|
|||||||
add_subdirectory(qlafilter)
|
add_subdirectory(qlafilter)
|
||||||
add_subdirectory(regexfilter)
|
add_subdirectory(regexfilter)
|
||||||
add_subdirectory(tee)
|
add_subdirectory(tee)
|
||||||
add_subdirectory(testfilter)
|
|
||||||
add_subdirectory(topfilter)
|
add_subdirectory(topfilter)
|
||||||
add_subdirectory(tpmfilter)
|
add_subdirectory(tpmfilter)
|
||||||
add_subdirectory(masking)
|
add_subdirectory(masking)
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
add_library(testfilter SHARED testfilter.c)
|
|
||||||
target_link_libraries(testfilter maxscale-common)
|
|
||||||
set_target_properties(testfilter PROPERTIES VERSION "1.0.0")
|
|
||||||
install_module(testfilter core)
|
|
@ -8,6 +8,3 @@ add_subdirectory(maxscaled)
|
|||||||
add_subdirectory(MySQL)
|
add_subdirectory(MySQL)
|
||||||
add_subdirectory(telnetd)
|
add_subdirectory(telnetd)
|
||||||
|
|
||||||
if(BUILD_TESTS)
|
|
||||||
add_subdirectory(testprotocol)
|
|
||||||
endif()
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
add_library(testprotocol SHARED testprotocol.c)
|
|
||||||
set_target_properties(testprotocol PROPERTIES VERSION "1.0.0")
|
|
||||||
install_module(testprotocol core)
|
|
@ -11,8 +11,5 @@ add_subdirectory(maxinfo)
|
|||||||
add_subdirectory(readconnroute)
|
add_subdirectory(readconnroute)
|
||||||
add_subdirectory(readwritesplit)
|
add_subdirectory(readwritesplit)
|
||||||
add_subdirectory(schemarouter)
|
add_subdirectory(schemarouter)
|
||||||
add_subdirectory(roundrobinrouter)
|
|
||||||
|
|
||||||
if(BUILD_TESTS)
|
|
||||||
add_subdirectory(testroute)
|
|
||||||
endif()
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
add_library(roundrobinrouter SHARED roundrobinrouter.cpp)
|
|
||||||
target_link_libraries(roundrobinrouter maxscale-common)
|
|
||||||
set_target_properties(roundrobinrouter PROPERTIES VERSION "1.0.0")
|
|
||||||
install_module(roundrobinrouter core)
|
|
||||||
|
|
||||||
install_custom_file(roundrobinrouter.cpp ${CMAKE_INSTALL_INCLUDEDIR}/maxscale/Documentation devel)
|
|
@ -1,4 +0,0 @@
|
|||||||
add_library(testroute SHARED testroute.c)
|
|
||||||
target_link_libraries(testroute maxscale-common)
|
|
||||||
set_target_properties(testroute PROPERTIES VERSION "1.0.0")
|
|
||||||
install_module(testroute core)
|
|
Reference in New Issue
Block a user