Uncrustify maxscale
See script directory for method. The script to run in the top level MaxScale directory is called maxscale-uncrustify.sh, which uses another script, list-src, from the same directory (so you need to set your PATH). The uncrustify version was 0.66.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "hintrouterdefs.hh"
|
||||
|
||||
@ -27,9 +27,10 @@ public:
|
||||
|
||||
Dcb(const Dcb& rhs)
|
||||
: m_sInner(rhs.m_sInner)
|
||||
{};
|
||||
{
|
||||
}
|
||||
|
||||
Dcb& operator = (Dcb rhs)
|
||||
Dcb& operator=(Dcb rhs)
|
||||
{
|
||||
m_sInner.swap(rhs.m_sInner);
|
||||
return *this;
|
||||
@ -55,4 +56,3 @@ private:
|
||||
static void deleter(DCB* dcb);
|
||||
SDCB m_sInner;
|
||||
};
|
||||
|
||||
|
@ -22,27 +22,29 @@
|
||||
|
||||
static const MXS_ENUM_VALUE default_action_values[] =
|
||||
{
|
||||
{"master", HINT_ROUTE_TO_MASTER},
|
||||
{"slave", HINT_ROUTE_TO_SLAVE},
|
||||
{"named", HINT_ROUTE_TO_NAMED_SERVER},
|
||||
{"all", HINT_ROUTE_TO_ALL},
|
||||
{NULL} /* Last must be NULL */
|
||||
{"master", HINT_ROUTE_TO_MASTER },
|
||||
{"slave", HINT_ROUTE_TO_SLAVE },
|
||||
{"named", HINT_ROUTE_TO_NAMED_SERVER},
|
||||
{"all", HINT_ROUTE_TO_ALL },
|
||||
{NULL} /* Last must be NULL */
|
||||
};
|
||||
static const char DEFAULT_ACTION[] = "default_action";
|
||||
static const char DEFAULT_SERVER[] = "default_server";
|
||||
static const char MAX_SLAVES[] = "max_slaves";
|
||||
|
||||
HintRouter::HintRouter(SERVICE* pService, HINT_TYPE default_action, string& default_server,
|
||||
HintRouter::HintRouter(SERVICE* pService,
|
||||
HINT_TYPE default_action,
|
||||
string& default_server,
|
||||
int max_slaves)
|
||||
: maxscale::Router<HintRouter, HintRouterSession>(pService),
|
||||
m_routed_to_master(0),
|
||||
m_routed_to_slave(0),
|
||||
m_routed_to_named(0),
|
||||
m_routed_to_all(0),
|
||||
m_default_action(default_action),
|
||||
m_default_server(default_server),
|
||||
m_max_slaves(max_slaves),
|
||||
m_total_slave_conns(0)
|
||||
: maxscale::Router<HintRouter, HintRouterSession>(pService)
|
||||
, m_routed_to_master(0)
|
||||
, m_routed_to_slave(0)
|
||||
, m_routed_to_named(0)
|
||||
, m_routed_to_all(0)
|
||||
, m_default_action(default_action)
|
||||
, m_default_server(default_server)
|
||||
, m_max_slaves(max_slaves)
|
||||
, m_total_slave_conns(0)
|
||||
{
|
||||
HR_ENTRY();
|
||||
if (m_max_slaves < 0)
|
||||
@ -53,19 +55,20 @@ HintRouter::HintRouter(SERVICE* pService, HINT_TYPE default_action, string& defa
|
||||
MXS_NOTICE("Hint router [%s] created.", pService->name);
|
||||
}
|
||||
|
||||
//static
|
||||
// static
|
||||
HintRouter* HintRouter::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
HR_ENTRY();
|
||||
|
||||
HINT_TYPE default_action = (HINT_TYPE)config_get_enum(params, DEFAULT_ACTION,
|
||||
HINT_TYPE default_action = (HINT_TYPE)config_get_enum(params,
|
||||
DEFAULT_ACTION,
|
||||
default_action_values);
|
||||
string default_server(config_get_string(params, DEFAULT_SERVER));
|
||||
int max_slaves = config_get_integer(params, MAX_SLAVES);
|
||||
return new HintRouter(pService, default_action, default_server, max_slaves);
|
||||
}
|
||||
|
||||
HintRouterSession* HintRouter::newSession(MXS_SESSION *pSession)
|
||||
HintRouterSession* HintRouter::newSession(MXS_SESSION* pSession)
|
||||
{
|
||||
typedef HintRouterSession::RefArray::size_type array_index;
|
||||
HR_ENTRY();
|
||||
@ -189,7 +192,8 @@ json_t* HintRouter::diagnostics_json() const
|
||||
return rval;
|
||||
}
|
||||
|
||||
Dcb HintRouter::connect_to_backend(MXS_SESSION* session, SERVER_REF* sref,
|
||||
Dcb HintRouter::connect_to_backend(MXS_SESSION* session,
|
||||
SERVER_REF* sref,
|
||||
HintRouterSession::BackendMap* all_backends)
|
||||
{
|
||||
Dcb result(NULL);
|
||||
@ -217,17 +221,17 @@ 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 */
|
||||
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 */
|
||||
RCAP_TYPE_STMT_INPUT | RCAP_TYPE_RESULTSET_OUTPUT,
|
||||
&HintRouter::s_object,
|
||||
NULL, /* Process init, can be null */
|
||||
NULL, /* Process finish, can be null */
|
||||
NULL, /* Thread init */
|
||||
NULL, /* Thread finish */
|
||||
NULL, /* Process init, can be null */
|
||||
NULL, /* Process finish, can be null */
|
||||
NULL, /* Thread init */
|
||||
NULL, /* Thread finish */
|
||||
{
|
||||
{
|
||||
DEFAULT_ACTION,
|
||||
@ -236,8 +240,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
MXS_MODULE_OPT_NONE,
|
||||
default_action_values
|
||||
},
|
||||
{DEFAULT_SERVER, MXS_MODULE_PARAM_SERVER, ""},
|
||||
{MAX_SLAVES, MXS_MODULE_PARAM_INT, "-1"},
|
||||
{DEFAULT_SERVER, MXS_MODULE_PARAM_SERVER,"" },
|
||||
{MAX_SLAVES, MXS_MODULE_PARAM_INT, "-1"},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
};
|
||||
|
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "hintrouterdefs.hh"
|
||||
|
||||
@ -21,9 +21,9 @@ class HintRouter : public maxscale::Router<HintRouter, HintRouterSession>
|
||||
{
|
||||
public:
|
||||
static HintRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params);
|
||||
HintRouterSession* newSession(MXS_SESSION *pSession);
|
||||
void diagnostics(DCB* pOut);
|
||||
json_t* diagnostics_json() const;
|
||||
HintRouterSession* newSession(MXS_SESSION* pSession);
|
||||
void diagnostics(DCB* pOut);
|
||||
json_t* diagnostics_json() const;
|
||||
uint64_t getCapabilities() const
|
||||
{
|
||||
return RCAP_TYPE_NONE;
|
||||
@ -31,28 +31,31 @@ public:
|
||||
HINT_TYPE get_default_action() const
|
||||
{
|
||||
return m_default_action;
|
||||
};
|
||||
}
|
||||
const string& get_default_server() const
|
||||
{
|
||||
return m_default_server;
|
||||
};
|
||||
}
|
||||
/* Simple, approximate statistics */
|
||||
volatile unsigned int m_routed_to_master;
|
||||
volatile unsigned int m_routed_to_slave;
|
||||
volatile unsigned int m_routed_to_named;
|
||||
volatile unsigned int m_routed_to_all;
|
||||
private:
|
||||
HintRouter(SERVICE* pService, HINT_TYPE default_action, string& default_server,
|
||||
HintRouter(SERVICE* pService,
|
||||
HINT_TYPE default_action,
|
||||
string& default_server,
|
||||
int max_slaves);
|
||||
|
||||
HINT_TYPE m_default_action;
|
||||
string m_default_server;
|
||||
int m_max_slaves;
|
||||
HINT_TYPE m_default_action;
|
||||
string m_default_server;
|
||||
int m_max_slaves;
|
||||
volatile int m_total_slave_conns;
|
||||
private:
|
||||
HintRouter(const HintRouter&);
|
||||
HintRouter& operator = (const HintRouter&);
|
||||
HintRouter& operator=(const HintRouter&);
|
||||
|
||||
static Dcb connect_to_backend(MXS_SESSION* session, SERVER_REF* sref,
|
||||
static Dcb connect_to_backend(MXS_SESSION* session,
|
||||
SERVER_REF* sref,
|
||||
HintRouterSession::BackendMap* all_backends);
|
||||
};
|
||||
|
@ -10,14 +10,14 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
#include <maxscale/dcb.h>
|
||||
#include <maxscale/log.h>
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
#if defined (SS_DEBUG)
|
||||
#define DEBUG_HINTROUTER
|
||||
#undef DEBUG_HINTROUTER
|
||||
#else
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
#ifdef DEBUG_HINTROUTER
|
||||
#define HR_DEBUG(msg, ...) MXS_NOTICE(msg, ##__VA_ARGS__)
|
||||
#define HR_ENTRY() HR_DEBUG(__func__)
|
||||
#define HR_ENTRY() HR_DEBUG(__func__)
|
||||
#else
|
||||
#define HR_DEBUG(msg, ...)
|
||||
#define HR_ENTRY()
|
||||
|
@ -31,7 +31,8 @@ class Writer : std::unary_function<HintRouterSession::MapElement, bool>
|
||||
public:
|
||||
Writer(GWBUF* pPacket)
|
||||
: m_pPacket(pPacket)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(HintRouterSession::MapElement& elem)
|
||||
{
|
||||
@ -53,8 +54,8 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
HintRouterSession::HintRouterSession(MXS_SESSION* pSession,
|
||||
HintRouter* pRouter,
|
||||
HintRouterSession::HintRouterSession(MXS_SESSION* pSession,
|
||||
HintRouter* pRouter,
|
||||
const BackendMap& backends)
|
||||
: maxscale::RouterSession(pSession)
|
||||
, m_router(pRouter)
|
||||
@ -150,10 +151,10 @@ void HintRouterSession::clientReply(GWBUF* pPacket, DCB* pBackend)
|
||||
}
|
||||
}
|
||||
|
||||
void HintRouterSession::handleError(GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
void HintRouterSession::handleError(GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
mxs_error_action_t action,
|
||||
bool* pSuccess)
|
||||
bool* pSuccess)
|
||||
{
|
||||
HR_ENTRY();
|
||||
|
||||
@ -271,8 +272,8 @@ bool HintRouterSession::route_by_hint(GWBUF* pPacket, HINT* hint, bool print_err
|
||||
case HINT_ROUTE_TO_ALL:
|
||||
{
|
||||
HR_DEBUG("Writing packet to %lu backends.", m_backends.size());
|
||||
BackendMap::size_type n_writes =
|
||||
std::count_if(m_backends.begin(), m_backends.end(), Writer(pPacket));
|
||||
BackendMap::size_type n_writes
|
||||
= std::count_if(m_backends.begin(), m_backends.end(), Writer(pPacket));
|
||||
if (n_writes != 0)
|
||||
{
|
||||
m_surplus_replies = n_writes - 1;
|
||||
@ -290,7 +291,8 @@ bool HintRouterSession::route_by_hint(GWBUF* pPacket, HINT* hint, bool print_err
|
||||
if (print_errors)
|
||||
{
|
||||
MXS_ERROR("Write failed for '%lu' out of '%lu' backends.",
|
||||
(size - n_writes), size);
|
||||
(size - n_writes),
|
||||
size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "hintrouterdefs.hh"
|
||||
|
||||
@ -29,16 +29,16 @@ class HintRouter;
|
||||
class HintRouterSession : public maxscale::RouterSession
|
||||
{
|
||||
public:
|
||||
typedef std::unordered_map<string, Dcb> BackendMap; // All backends, indexed by name
|
||||
typedef std::vector<Dcb> BackendArray;
|
||||
typedef std::vector<SERVER_REF*> RefArray;
|
||||
typedef BackendMap::value_type MapElement;
|
||||
typedef BackendArray::size_type size_type;
|
||||
typedef std::unordered_map<string, Dcb> BackendMap; // All backends, indexed by name
|
||||
typedef std::vector<Dcb> BackendArray;
|
||||
typedef std::vector<SERVER_REF*> RefArray;
|
||||
typedef BackendMap::value_type MapElement;
|
||||
typedef BackendArray::size_type size_type;
|
||||
|
||||
HintRouterSession(MXS_SESSION* pSession,
|
||||
HintRouter* pRouter,
|
||||
HintRouterSession(MXS_SESSION* pSession,
|
||||
HintRouter* pRouter,
|
||||
const BackendMap& backends
|
||||
);
|
||||
);
|
||||
|
||||
~HintRouterSession();
|
||||
|
||||
@ -48,23 +48,23 @@ public:
|
||||
|
||||
void clientReply(GWBUF* pPacket, DCB* pBackend);
|
||||
|
||||
void handleError(GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
void handleError(GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
mxs_error_action_t action,
|
||||
bool* pSuccess);
|
||||
bool* pSuccess);
|
||||
|
||||
private:
|
||||
HintRouterSession(const HintRouterSession&); // denied
|
||||
HintRouterSession& operator = (const HintRouterSession&); // denied
|
||||
HintRouterSession(const HintRouterSession&); // denied
|
||||
HintRouterSession& operator=(const HintRouterSession&); // denied
|
||||
private:
|
||||
bool route_by_hint(GWBUF* pPacket, HINT* current_hint, bool ignore_errors);
|
||||
bool route_to_slave(GWBUF* pPacket, bool print_errors);
|
||||
void update_connections();
|
||||
|
||||
HintRouter* m_router;
|
||||
BackendMap m_backends; // all connections
|
||||
Dcb m_master; // connection to master
|
||||
BackendArray m_slaves; // connections to slaves
|
||||
size_type m_n_routed_to_slave; // packets routed to a single slave, used for rr
|
||||
size_type m_surplus_replies; // how many replies should be ignored
|
||||
HintRouter* m_router;
|
||||
BackendMap m_backends; // all connections
|
||||
Dcb m_master; // connection to master
|
||||
BackendArray m_slaves; // connections to slaves
|
||||
size_type m_n_routed_to_slave; // packets routed to a single slave, used for rr
|
||||
size_type m_surplus_replies; // how many replies should be ignored
|
||||
};
|
||||
|
Reference in New Issue
Block a user