MXS-2275 Add skeleton softfail/unsoftfail support
Add skeleton implementation for the functionality for being able to softfail and unsoftfail a Clustrix node.
This commit is contained in:
@ -13,8 +13,38 @@
|
|||||||
|
|
||||||
#include "clustrixmon.hh"
|
#include "clustrixmon.hh"
|
||||||
#include <maxscale/modinfo.h>
|
#include <maxscale/modinfo.h>
|
||||||
|
#include <maxscale/modulecmd.hh>
|
||||||
#include "clustrixmonitor.hh"
|
#include "clustrixmonitor.hh"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
bool handle_softfail(const MODULECMD_ARG* args, json_t** error_out)
|
||||||
|
{
|
||||||
|
mxb_assert(args->argc == 2);
|
||||||
|
mxb_assert(MODULECMD_GET_TYPE(&args->argv[0].type) == MODULECMD_ARG_MONITOR);
|
||||||
|
mxb_assert(MODULECMD_GET_TYPE(&args->argv[1].type) == MODULECMD_ARG_SERVER);
|
||||||
|
|
||||||
|
ClustrixMonitor* pMon = static_cast<ClustrixMonitor*>(args->argv[0].value.monitor);
|
||||||
|
SERVER* pServer = args->argv[1].value.server;
|
||||||
|
|
||||||
|
return pMon->softfail(pServer, error_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handle_unsoftfail(const MODULECMD_ARG* args, json_t** error_out)
|
||||||
|
{
|
||||||
|
mxb_assert(args->argc == 2);
|
||||||
|
mxb_assert(MODULECMD_GET_TYPE(&args->argv[0].type) == MODULECMD_ARG_MONITOR);
|
||||||
|
mxb_assert(MODULECMD_GET_TYPE(&args->argv[1].type) == MODULECMD_ARG_SERVER);
|
||||||
|
|
||||||
|
ClustrixMonitor* pMon = static_cast<ClustrixMonitor*>(args->argv[0].value.monitor);
|
||||||
|
SERVER* pServer = args->argv[1].value.server;
|
||||||
|
|
||||||
|
return pMon->unsoftfail(pServer, error_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The module entry point routine. It is this routine that
|
* The module entry point routine. It is this routine that
|
||||||
* must populate the structure that is referred to as the
|
* must populate the structure that is referred to as the
|
||||||
@ -27,6 +57,36 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise the MariaDB Clustrix Monitor module.");
|
MXS_NOTICE("Initialise the MariaDB Clustrix Monitor module.");
|
||||||
|
|
||||||
|
static modulecmd_arg_type_t softfail_argv[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN,
|
||||||
|
"Monitor name (from configuration file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MODULECMD_ARG_SERVER, "Node to be softfailed."
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
modulecmd_register_command(MXS_MODULE_NAME, "softfail", MODULECMD_TYPE_ACTIVE,
|
||||||
|
handle_softfail, MXS_ARRAY_NELEMS(softfail_argv), softfail_argv,
|
||||||
|
"Perform softfail of node");
|
||||||
|
|
||||||
|
static modulecmd_arg_type_t unsoftfail_argv[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN,
|
||||||
|
"Monitor name (from configuration file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MODULECMD_ARG_SERVER, "Node to be unsoftfailed."
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
modulecmd_register_command(MXS_MODULE_NAME, "unsoftfail", MODULECMD_TYPE_ACTIVE,
|
||||||
|
handle_unsoftfail, MXS_ARRAY_NELEMS(unsoftfail_argv), unsoftfail_argv,
|
||||||
|
"Perform unsoftfail of node");
|
||||||
|
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_MONITOR,
|
MXS_MODULE_API_MONITOR,
|
||||||
|
@ -55,6 +55,18 @@ bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError)
|
||||||
|
{
|
||||||
|
MXS_NOTICE("Should softfail %s.", pServer->address);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClustrixMonitor::unsoftfail(SERVER* pServer, json_t** ppError)
|
||||||
|
{
|
||||||
|
MXS_NOTICE("Should unsoftfail %s.", pServer->address);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ClustrixMonitor::pre_loop()
|
void ClustrixMonitor::pre_loop()
|
||||||
{
|
{
|
||||||
make_health_check();
|
make_health_check();
|
||||||
|
@ -64,6 +64,9 @@ public:
|
|||||||
|
|
||||||
bool configure(const MXS_CONFIG_PARAMETER* pParams) override;
|
bool configure(const MXS_CONFIG_PARAMETER* pParams) override;
|
||||||
|
|
||||||
|
bool softfail(SERVER* pServer, json_t** ppError);
|
||||||
|
bool unsoftfail(SERVER* pServer, json_t** ppError);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ClustrixMonitor(const std::string& name, const std::string& module);
|
ClustrixMonitor(const std::string& name, const std::string& module);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user