diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-08-11 14:36:33 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-08-16 06:22:20 +0000 |
commit | f9d92a66b4181633a811b178b2a2f8497798d7bc (patch) | |
tree | e73c1f584c2d8bb008002f5521fe14d84c0733fd | |
parent | e536003faa53fd4df212010357d2327946122c14 (diff) |
let LocalRpcMonitorMap implement MapSource
-rw-r--r-- | slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.cpp | 11 | ||||
-rw-r--r-- | slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.h | 12 |
2 files changed, 15 insertions, 8 deletions
diff --git a/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.cpp b/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.cpp index 50a11c7b521..7141da29b6d 100644 --- a/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.cpp +++ b/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.cpp @@ -9,9 +9,11 @@ namespace slobrok { LocalRpcMonitorMap::LocalRpcMonitorMap(FRT_Supervisor &supervisor) : _map(), + _dispatcher(), _history(), _supervisor(supervisor) { + _dispatcher.registerListener(_history); } LocalRpcMonitorMap::~LocalRpcMonitorMap() = default; @@ -46,7 +48,7 @@ void LocalRpcMonitorMap::add(const ServiceMapping &mapping) { mapping.name.c_str(), mapping.spec.c_str(), exists.name().c_str(), exists.spec().c_str()); if (exists.up) { - _history.remove(exists.mapping()); + _dispatcher.remove(exists.mapping()); } _map.erase(old); } @@ -69,9 +71,10 @@ void LocalRpcMonitorMap::remove(const ServiceMapping &mapping) { mapping.name.c_str(), exists.spec().c_str(), mapping.spec.c_str()); + return; } if (exists.up) { - _history.remove(exists.mapping()); + _dispatcher.remove(exists.mapping()); } _map.erase(iter); } else { @@ -88,7 +91,7 @@ void LocalRpcMonitorMap::notifyFailedRpcSrv(ManagedRpcServer *rpcsrv, std::strin LOG(debug, "failed: %s->%s", mapping.name.c_str(), mapping.spec.c_str()); if (psd->up) { psd->up = false; - _history.remove(mapping); + _dispatcher.remove(mapping); } } @@ -100,7 +103,7 @@ void LocalRpcMonitorMap::notifyOkRpcSrv(ManagedRpcServer *rpcsrv) { LOG(debug, "ok: %s->%s", mapping.name.c_str(), mapping.spec.c_str()); if (! psd->up) { psd->up = true; - _history.add(mapping); + _dispatcher.add(mapping); } } diff --git a/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.h b/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.h index 3f732d6875b..7d3ed6b466a 100644 --- a/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.h +++ b/slobrok/src/vespa/slobrok/server/local_rpc_monitor_map.h @@ -1,14 +1,16 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "map_listener.h" -#include "map_source.h" -#include "service_mapping.h" -#include "service_map_history.h" #include "i_rpc_server_manager.h" #include "managed_rpc_server.h" #include "map_listener.h" +#include "map_listener.h" +#include "map_source.h" #include "named_service.h" +#include "proxy_map_source.h" +#include "service_map_history.h" +#include "service_mapping.h" + #include <vector> #include <memory> #include <map> @@ -37,6 +39,7 @@ private: using Map = std::map<vespalib::string, PerService>; Map _map; + ProxyMapSource _dispatcher; ServiceMapHistory _history; FRT_Supervisor &_supervisor; @@ -46,6 +49,7 @@ public: LocalRpcMonitorMap(FRT_Supervisor &_supervisor); ~LocalRpcMonitorMap(); + MapSource &dispatcher() { return _dispatcher; } ServiceMapHistory & history(); void add(const ServiceMapping &mapping) override; |