diff options
Diffstat (limited to 'configd/src/apps/sentinel/rpchooks.cpp')
-rw-r--r-- | configd/src/apps/sentinel/rpchooks.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/configd/src/apps/sentinel/rpchooks.cpp b/configd/src/apps/sentinel/rpchooks.cpp index aef58b8a1dc..d364e74154c 100644 --- a/configd/src/apps/sentinel/rpchooks.cpp +++ b/configd/src/apps/sentinel/rpchooks.cpp @@ -2,6 +2,8 @@ #include "rpchooks.h" #include "cmdq.h" +#include "check-completion-handler.h" +#include "peer-check.h" #include <vespa/fnet/frt/supervisor.h> #include <vespa/fnet/frt/rpcrequest.h> @@ -10,6 +12,13 @@ LOG_SETUP(".rpchooks"); namespace config::sentinel { +RPCHooks::RPCHooks(CommandQueue &commands, FRT_Supervisor &supervisor) + : _commands(commands), + _orb(supervisor) +{ + initRPC(&_orb); +} + RPCHooks::~RPCHooks() = default; @@ -36,6 +45,13 @@ RPCHooks::initRPC(FRT_Supervisor *supervisor) FRT_METHOD(RPCHooks::rpc_startService), this); rb.MethodDesc("start a service"); //------------------------------------------------------------------------- + rb.DefineMethod("sentinel.check.connectivity", "si", "s", + FRT_METHOD(RPCHooks::rpc_checkConnectivity), this); + rb.MethodDesc("check connectivity for peer sentinel"); + rb.ParamDesc("name", "Hostname of peer sentinel"); + rb.ParamDesc("port", "Port number of peer sentinel"); + rb.ReturnDesc("status", "Status (ok, bad, or unknown) for peer"); + //------------------------------------------------------------------------- } void @@ -76,4 +92,16 @@ RPCHooks::rpc_startService(FRT_RPCRequest *req) _commands.enqueue(std::make_unique<Cmd>(req, Cmd::START, srvNM)); } +void +RPCHooks::rpc_checkConnectivity(FRT_RPCRequest *req) +{ + FRT_Values &args = *req->GetParams(); + const char *hostname = args[0]._string._str; + uint32_t portnum = args[1]._intval32; + LOG(debug, "got checkConnectivity %s [port %d]", hostname, portnum); + req->Detach(); + auto & completionHandler = req->getStash().create<CheckCompletionHandler>(req); + req->getStash().create<PeerCheck>(completionHandler, hostname, portnum, _orb); +} + } // namespace slobrok |