Merge branch '2.2' into 2.2-mrm

This commit is contained in:
Johan Wikman 2017-11-07 12:05:33 +02:00
commit f44020496a
8 changed files with 223 additions and 1 deletions

View File

@ -15,6 +15,10 @@ target_link_libraries(testfilter maxscale-common)
set_target_properties(testfilter PROPERTIES VERSION "1.0.0")
install_module(testfilter core)
add_library(examplecppfilter SHARED examplefilter.cc examplefiltersession.cc)
set_target_properties(examplecppfilter PROPERTIES VERSION "1.0.0")
install_module(examplecppfilter core)
add_library(testprotocol SHARED testprotocol.c)
set_target_properties(testprotocol PROPERTIES VERSION "1.0.0")
install_module(testprotocol core)

78
examples/examplefilter.cc Normal file
View File

@ -0,0 +1,78 @@
/*
* 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: 2020-01-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.
*/
// All log messages from this module are prefixed with this
#define MXS_MODULE_NAME "examplefilter"
#include "examplefilter.hh"
// This declares a module in MaxScale
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{
static MXS_MODULE info =
{
MXS_MODULE_API_FILTER,
MXS_MODULE_IN_DEVELOPMENT,
MXS_FILTER_VERSION,
"An example filter that does nothing",
"V1.0.0",
RCAP_TYPE_NONE,
&ExampleFilter::s_object, // This is defined in the MaxScale filter template
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{ "an_example_parameter", MXS_MODULE_PARAM_STRING, "a-default-value" },
{ MXS_END_MODULE_PARAMS }
}
};
return &info;
}
ExampleFilter::ExampleFilter()
{
}
ExampleFilter::~ExampleFilter()
{
}
// static
ExampleFilter* ExampleFilter::create(const char* zName, char** pzOptions, MXS_CONFIG_PARAMETER* pParams)
{
return new ExampleFilter();
}
ExampleFilterSession* ExampleFilter::newSession(MXS_SESSION* pSession)
{
return ExampleFilterSession::create(pSession, this);
}
// static
void ExampleFilter::diagnostics(DCB* pDcb) const
{
}
// static
json_t* ExampleFilter::diagnostics_json() const
{
return NULL;
}
// static
uint64_t ExampleFilter::getCapabilities()
{
return RCAP_TYPE_NONE;
}

46
examples/examplefilter.hh Normal file
View File

@ -0,0 +1,46 @@
#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: 2020-01-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/filter.hh>
#include "examplefiltersession.hh"
class ExampleFilter : public maxscale::Filter<ExampleFilter, ExampleFilterSession>
{
// Prevent copy-constructor and assignment operator usage
ExampleFilter(const ExampleFilter&);
ExampleFilter& operator = (const ExampleFilter&);
public:
~ExampleFilter();
// Creates a new filter instance
static ExampleFilter* create(const char* zName, char** pzOptions, MXS_CONFIG_PARAMETER* ppParams);
// Creates a new session for this filter
ExampleFilterSession* newSession(MXS_SESSION* pSession);
// Print diagnostics to a DCB
void diagnostics(DCB* pDcb) const;
// Returns JSON form diagnostic data
json_t* diagnostics_json() const;
// Get filter capabilities
uint64_t getCapabilities();
private:
// Used in the create function
ExampleFilter();
};

View File

@ -0,0 +1,43 @@
/*
* 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: 2020-01-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.
*/
// All log messages from this module are prefixed with this
#define MXS_MODULE_NAME "examplefilter"
#include "examplefiltersession.hh"
#include "examplefilter.hh"
ExampleFilterSession::ExampleFilterSession(MXS_SESSION* pSession)
: mxs::FilterSession(pSession)
{
}
ExampleFilterSession::~ExampleFilterSession()
{
}
//static
ExampleFilterSession* ExampleFilterSession::create(MXS_SESSION* pSession, const ExampleFilter* pFilter)
{
return new ExampleFilterSession(pSession);
}
int ExampleFilterSession::routeQuery(GWBUF* pPacket)
{
return mxs::FilterSession::routeQuery(pPacket);
}
int ExampleFilterSession::clientReply(GWBUF* pPacket)
{
return mxs::FilterSession::clientReply(pPacket);
}

View File

@ -0,0 +1,44 @@
#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: 2020-01-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/filter.hh>
class ExampleFilter;
class ExampleFilterSession : public maxscale::FilterSession
{
// Prevent copy-constructor and assignment operator usage
ExampleFilterSession(const ExampleFilterSession&);
ExampleFilterSession& operator = (const ExampleFilterSession&);
public:
~ExampleFilterSession();
// Called when a client session has been closed
void close();
// Create a new filter session
static ExampleFilterSession* create(MXS_SESSION* pSession, const ExampleFilter* pFilter);
// Handle a query from the client
int routeQuery(GWBUF* pPacket);
// Handle a reply from server
int clientReply(GWBUF* pPacket);
private:
// Used in the create function
ExampleFilterSession(MXS_SESSION* pSession);
};

View File

@ -51,7 +51,7 @@ add_library(testcore SHARED testconnections.cpp mariadb_nodes.cpp
sql_t1.cpp test_binlog_fnc.cpp get_my_ip.cpp big_load.cpp get_com_select_insert.cpp
different_size.cpp fw_copy_rules maxinfo_func.cpp config_operations.cpp rds_vpc.cpp execute_cmd.cpp
blob_test.cpp)
target_link_libraries(testcore ${MYSQL_CLIENT} z crypt nsl m pthread ssl crypto dl rt ${CDC_CONNECTOR_LIBRARIES} ${JANSSON_LIBRARIES})
target_link_libraries(testcore ${MYSQL_CLIENT} ${CDC_CONNECTOR_LIBRARIES} ${JANSSON_LIBRARIES} z nsl m pthread ssl dl rt crypto crypt)
install(TARGETS testcore DESTINATION system-test)
add_dependencies(testcore connector-c cdc_connector)

View File

@ -9,6 +9,9 @@ add_library(cachetester
../../../../../query_classifier/test/testreader.cc
)
# Depends on C/C
add_dependencies(cachetester connector-c)
add_executable(testrules testrules.cc ../rules.cc)
target_link_libraries(testrules maxscale-common ${JANSSON_LIBRARIES})

View File

@ -7,6 +7,10 @@ if(BISON_FOUND AND FLEX_FOUND)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_library(dbfwfilter-core STATIC ${BISON_ruleparser_OUTPUTS} ${FLEX_token_OUTPUTS} rules.cc user.cc)
# Depends on PCRE2
add_dependencies(dbfwfilter-core pcre2 connector-c)
add_library(dbfwfilter SHARED dbfwfilter.cc)
target_link_libraries(dbfwfilter maxscale-common MySQLCommon dbfwfilter-core)
set_target_properties(dbfwfilter PROPERTIES VERSION "1.0.0")