diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-06-02 11:11:40 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-06-02 11:11:40 +0000 |
commit | fa297614fef1c12b1a50a0afe0d753cfbc041b88 (patch) | |
tree | f4aa60dfff06ca04099fa29e40651720bb7cbf22 | |
parent | 63eadd1f540bfbfc21c4515e95d9fa533589eced (diff) |
add timeout parameter
-rw-r--r-- | configd/src/apps/sentinel/peer-check.cpp | 4 | ||||
-rw-r--r-- | configd/src/apps/sentinel/peer-check.h | 3 | ||||
-rw-r--r-- | configd/src/apps/sentinel/rpchooks.cpp | 10 |
3 files changed, 9 insertions, 8 deletions
diff --git a/configd/src/apps/sentinel/peer-check.cpp b/configd/src/apps/sentinel/peer-check.cpp index 841d32c9631..60c3d9c96c9 100644 --- a/configd/src/apps/sentinel/peer-check.cpp +++ b/configd/src/apps/sentinel/peer-check.cpp @@ -10,7 +10,7 @@ using vespalib::make_string_short::fmt; namespace config::sentinel { -PeerCheck::PeerCheck(StatusCallback &callback, const std::string &host, int port, FRT_Supervisor &orb) +PeerCheck::PeerCheck(StatusCallback &callback, const std::string &host, int port, FRT_Supervisor &orb, int timeout_ms) : _callback(callback), _hostname(host), _portnum(port), @@ -21,7 +21,7 @@ PeerCheck::PeerCheck(StatusCallback &callback, const std::string &host, int port _target = orb.GetTarget(spec.c_str()); _req = orb.AllocRPCRequest(); _req->SetMethodName("frt.rpc.ping"); - _target->InvokeAsync(_req, 0.500, this); + _target->InvokeAsync(_req, timeout_ms * 0.001, this); } PeerCheck::~PeerCheck() { diff --git a/configd/src/apps/sentinel/peer-check.h b/configd/src/apps/sentinel/peer-check.h index 145552a9ab1..096f304467b 100644 --- a/configd/src/apps/sentinel/peer-check.h +++ b/configd/src/apps/sentinel/peer-check.h @@ -4,7 +4,6 @@ #include "status-callback.h" #include <string> -#include <vespa/fnet/task.h> #include <vespa/fnet/frt/invoker.h> #include <vespa/fnet/frt/rpcrequest.h> #include <vespa/fnet/frt/supervisor.h> @@ -15,7 +14,7 @@ namespace config::sentinel { class PeerCheck : public FRT_IRequestWait { public: - PeerCheck(StatusCallback &callback, const std::string &host, int portnum, FRT_Supervisor &orb); + PeerCheck(StatusCallback &callback, const std::string &host, int portnum, FRT_Supervisor &orb, int timeout_ms); ~PeerCheck(); PeerCheck(const PeerCheck &) = delete; diff --git a/configd/src/apps/sentinel/rpchooks.cpp b/configd/src/apps/sentinel/rpchooks.cpp index d364e74154c..24e3cd53509 100644 --- a/configd/src/apps/sentinel/rpchooks.cpp +++ b/configd/src/apps/sentinel/rpchooks.cpp @@ -45,11 +45,12 @@ RPCHooks::initRPC(FRT_Supervisor *supervisor) FRT_METHOD(RPCHooks::rpc_startService), this); rb.MethodDesc("start a service"); //------------------------------------------------------------------------- - rb.DefineMethod("sentinel.check.connectivity", "si", "s", + rb.DefineMethod("sentinel.check.connectivity", "sii", "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.ParamDesc("timeout", "Timeout for check in milliseconds"); rb.ReturnDesc("status", "Status (ok, bad, or unknown) for peer"); //------------------------------------------------------------------------- } @@ -97,11 +98,12 @@ 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); + int portnum = args[1]._intval32; + int timeout = args[2]._intval32; + LOG(debug, "got checkConnectivity %s [port %d] timeout %d", hostname, portnum, timeout); req->Detach(); auto & completionHandler = req->getStash().create<CheckCompletionHandler>(req); - req->getStash().create<PeerCheck>(completionHandler, hostname, portnum, _orb); + req->getStash().create<PeerCheck>(completionHandler, hostname, portnum, _orb, timeout); } } // namespace slobrok |