MXS-1461 Rename Upstream to Client

This commit is contained in:
Johan Wikman
2017-11-15 16:11:00 +02:00
parent a35a4c7e9f
commit 083c3bcad7
4 changed files with 37 additions and 36 deletions

View File

@ -4,10 +4,10 @@ add_executable(test_dbfwfilter
filtermodule.cc
mock.cc
mock_backend.cc
mock_client.cc
mock_dcb.cc
mock_routersession.cc
mock_session.cc
mock_upstream.cc
module.cc
tempfile.cc
)

View File

@ -25,13 +25,14 @@ namespace mock
{
/**
* An instance of Upstream represents an upstream object of a filter.
* An instance of Client represents a client. It can be used as the
* upstream filter of another filter.
*/
class Upstream : public MXS_FILTER_SESSION
class Client : public MXS_FILTER_SESSION
, public Dcb::Handler
{
Upstream(const Upstream&);
Upstream& operator = (const Upstream&);
Client(const Client&);
Client& operator = (const Client&);
public:
/**
@ -61,7 +62,7 @@ public:
virtual int32_t maxscale_reply(GWBUF* pResponse) = 0;
/**
* Called when @reset is called on the @c Upstream instance.
* Called when @reset is called on the @c Client instance.
*/
virtual void reset();
};
@ -71,8 +72,8 @@ public:
*
* @param pHandler Optional response handler.
*/
Upstream(Handler* pHandler = NULL);
~Upstream();
Client(Handler* pHandler = NULL);
~Client();
/**
* Set a response handler
@ -91,14 +92,14 @@ public:
size_t n_responses() const;
/**
* Reset the Upstream object. The number of counted responsed will
* be set to 0. If the Upstream object has a handler, then its @c reset
* Reset the Client object. The number of counted responsed will
* be set to 0. If the Client object has a handler, then its @c reset
* function will be called as well.
*/
void reset();
/**
* Set this object as upstream filter of provided filter.
* Set this object as client filter of provided filter.
*
* @param session The filter session whose upstream filter should be set.
*/

View File

@ -11,7 +11,7 @@
* Public License.
*/
#include "maxscale/mock/upstream.hh"
#include "maxscale/mock/client.hh"
namespace maxscale
{
@ -20,31 +20,31 @@ namespace mock
{
//
// Upstream
// Client
//
Upstream::Upstream(Handler* pHandler)
Client::Client(Handler* pHandler)
: m_pHandler(pHandler)
, m_n_responses(0)
{
}
Upstream::~Upstream()
Client::~Client()
{
}
size_t Upstream::n_responses() const
size_t Client::n_responses() const
{
return m_n_responses;
}
Upstream::Handler* Upstream::set_handler(Handler* pHandler)
Client::Handler* Client::set_handler(Handler* pHandler)
{
Handler* pH = m_pHandler;
m_pHandler = pHandler;
return pH;
}
void Upstream::reset()
void Client::reset()
{
m_n_responses = 0;
@ -54,18 +54,18 @@ void Upstream::reset()
}
}
void Upstream::set_as_upstream_on(FilterModule::Session& filter_session)
void Client::set_as_upstream_on(FilterModule::Session& filter_session)
{
MXS_UPSTREAM upstream;
upstream.instance = &m_instance;
upstream.session = this;
upstream.clientReply = &Upstream::clientReply;
upstream.clientReply = &Client::clientReply;
upstream.error = NULL;
filter_session.setUpstream(&upstream);
}
int32_t Upstream::clientReply(GWBUF* pResponse)
int32_t Client::clientReply(GWBUF* pResponse)
{
int32_t rv = 1;
@ -83,7 +83,7 @@ int32_t Upstream::clientReply(GWBUF* pResponse)
return rv;
}
int32_t Upstream::write(GWBUF* pResponse)
int32_t Client::write(GWBUF* pResponse)
{
int32_t rv = 1;
@ -102,25 +102,25 @@ int32_t Upstream::write(GWBUF* pResponse)
}
//static
int32_t Upstream::clientReply(MXS_FILTER* pInstance,
int32_t Client::clientReply(MXS_FILTER* pInstance,
MXS_FILTER_SESSION* pSession,
GWBUF* pResponse)
{
Upstream* pUpstream = reinterpret_cast<Upstream*>(pSession);
ss_dassert(pInstance == &pUpstream->m_instance);
Client* pClient = reinterpret_cast<Client*>(pSession);
ss_dassert(pInstance == &pClient->m_instance);
return pUpstream->clientReply(pResponse);
return pClient->clientReply(pResponse);
}
//
// Upstream::Handler
// Client::Handler
//
Upstream::Handler::~Handler()
Client::Handler::~Handler()
{
}
void Upstream::Handler::reset()
void Client::Handler::reset()
{
}

View File

@ -20,7 +20,7 @@
#include "maxscale/mock/backend.hh"
#include "maxscale/mock/routersession.hh"
#include "maxscale/mock/session.hh"
#include "maxscale/mock/upstream.hh"
#include "maxscale/mock/client.hh"
#include "tempfile.hh"
using namespace std;
@ -177,8 +177,8 @@ int test(FilterModule::Instance& filter_instance, const FW_TEST& t)
if (c.zStatement)
{
mock::Upstream upstream;
mock::Session session(c.zUser, c.zHost, &upstream);
mock::Client client;
mock::Session session(c.zUser, c.zHost, &client);
auto_ptr<FilterModule::Session> sFilter_session = filter_instance.newSession(&session);
@ -186,7 +186,7 @@ int test(FilterModule::Instance& filter_instance, const FW_TEST& t)
{
router_session.set_as_downstream_on(sFilter_session.get());
upstream.set_as_upstream_on(*sFilter_session.get());
client.set_as_upstream_on(*sFilter_session.get());
rv += test(*sFilter_session.get(), router_session, c);
}