summaryrefslogtreecommitdiffstats
path: root/slobrok
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-06-28 13:16:32 +0000
committerArne Juul <arnej@verizonmedia.com>2021-06-29 06:52:11 +0000
commit1ad390539b694faec37051346721010d2c50035b (patch)
tree8f4428bbe494b2742d3944e2f6b8e35bec534868 /slobrok
parent2f1ff6b80c7f769c2c50d9889c38efed613a7b9c (diff)
GC old code
Diffstat (limited to 'slobrok')
-rw-r--r--slobrok/src/vespa/slobrok/server/CMakeLists.txt2
-rw-r--r--slobrok/src/vespa/slobrok/server/history.cpp71
-rw-r--r--slobrok/src/vespa/slobrok/server/history.h40
-rw-r--r--slobrok/src/vespa/slobrok/server/visible_map.cpp170
-rw-r--r--slobrok/src/vespa/slobrok/server/visible_map.h87
5 files changed, 0 insertions, 370 deletions
diff --git a/slobrok/src/vespa/slobrok/server/CMakeLists.txt b/slobrok/src/vespa/slobrok/server/CMakeLists.txt
index 89007f626f3..5951e876ecc 100644
--- a/slobrok/src/vespa/slobrok/server/CMakeLists.txt
+++ b/slobrok/src/vespa/slobrok/server/CMakeLists.txt
@@ -4,7 +4,6 @@ vespa_add_library(slobrok_slobrokserver
cmd.cpp
configshim.cpp
exchange_manager.cpp
- history.cpp
i_monitored_server.cpp
i_rpc_server_manager.cpp
managed_rpc_server.cpp
@@ -24,7 +23,6 @@ vespa_add_library(slobrok_slobrokserver
service_map_history.cpp
service_mapping.cpp
slobrokserver.cpp
- visible_map.cpp
INSTALL lib64
DEPENDS
slobrok
diff --git a/slobrok/src/vespa/slobrok/server/history.cpp b/slobrok/src/vespa/slobrok/server/history.cpp
deleted file mode 100644
index 059f0ff4b89..00000000000
--- a/slobrok/src/vespa/slobrok/server/history.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "history.h"
-
-#include <vespa/log/log.h>
-LOG_SETUP(".history");
-
-namespace slobrok {
-
-void
-History::verify() const
-{
- if (_entries.size() > 0) {
- citer_t i = _entries.cbegin();
- vespalib::GenCnt gen = i->gen;
-
- while (++i != _entries.cend()) {
- gen.add();
- LOG_ASSERT(gen == i->gen);
- }
- }
-}
-
-void
-History::add(const std::string &name, vespalib::GenCnt gen)
-{
- _entries.emplace_back(name, gen);
-
- if (_entries.size() > 1500) {
- _entries.erase(_entries.begin(), _entries.begin() + 500);
- LOG(debug, "history size after trim: %lu",
- (unsigned long)_entries.size());
- }
- verify();
-}
-
-
-bool
-History::has(vespalib::GenCnt gen) const
-{
- if (_entries.size() == 0)
- return false;
-
- vespalib::GenCnt first = _entries.front().gen;
- vespalib::GenCnt last = _entries.back().gen;
-
- return gen.inRangeInclusive(first, last);
-}
-
-
-std::set<std::string>
-History::since(vespalib::GenCnt gen) const
-{
- citer_t i = _entries.cbegin();
- citer_t end = _entries.cend();
- while (i != end) {
- if (i->gen == gen) break;
- ++i;
- }
- std::set<std::string> ret;
- while (i != end) {
- ret.insert(i->name);
- ++i;
- }
- LOG_ASSERT(ret.size() > 0);
- return ret;
-}
-
-//-----------------------------------------------------------------------------
-
-} // namespace slobrok
diff --git a/slobrok/src/vespa/slobrok/server/history.h b/slobrok/src/vespa/slobrok/server/history.h
deleted file mode 100644
index d88b1348c6d..00000000000
--- a/slobrok/src/vespa/slobrok/server/history.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#pragma once
-
-#include <vespa/vespalib/util/gencnt.h>
-#include <vector>
-#include <string>
-#include <set>
-
-namespace slobrok {
-
-class History
-{
-private:
- struct HistoryEntry {
- std::string name;
- vespalib::GenCnt gen;
- HistoryEntry(const std::string &n, vespalib::GenCnt g)
- : name(n), gen(g) {}
- };
-
- std::vector<HistoryEntry> _entries;
-
- typedef std::vector<HistoryEntry>::const_iterator citer_t;
-
- void verify() const;
-public:
- void add(const std::string &name, vespalib::GenCnt gen);
-
- bool has(vespalib::GenCnt gen) const;
-
- std::set<std::string> since(vespalib::GenCnt gen) const;
-
- History() : _entries() {}
- ~History() {}
-};
-
-//-----------------------------------------------------------------------------
-
-} // namespace slobrok
-
diff --git a/slobrok/src/vespa/slobrok/server/visible_map.cpp b/slobrok/src/vespa/slobrok/server/visible_map.cpp
deleted file mode 100644
index d26bb49d874..00000000000
--- a/slobrok/src/vespa/slobrok/server/visible_map.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "visible_map.h"
-
-#include <vespa/log/log.h>
-LOG_SETUP(".vismap");
-
-namespace slobrok {
-
-void
-VisibleMap::updated()
-{
- _genCnt.add();
- WaitList waitList;
- std::swap(waitList, _waitList);
- for (auto & entry : waitList) {
- entry->updated(*this);
- }
-}
-
-void
-VisibleMap::aborted()
-{
- WaitList waitList;
- std::swap(waitList, _waitList);
- for (auto & entry : waitList) {
- entry->aborted(*this);
- }
-}
-
-void
-VisibleMap::addUpdateListener(IUpdateListener *l)
-{
- _waitList.push_back(l);
-}
-
-
-void
-VisibleMap::removeUpdateListener(IUpdateListener *l)
-{
- uint32_t i = 0;
- uint32_t size = _waitList.size();
- while (i < size) {
- if (_waitList[i] == l) {
- std::swap(_waitList[i], _waitList[size - 1]);
- _waitList.pop_back();
- --size;
- } else {
- ++i;
- }
- }
- LOG_ASSERT(size == _waitList.size());
-}
-
-//-----------------------------------------------------------------------------
-
-const NamedService *
-VisibleMap::lookup(const std::string &name) const {
- auto found = _map.find(name);
- return (found == _map.end()) ? nullptr : found->second;
-}
-
-std::vector<const NamedService *>
-VisibleMap::allVisible() const
-{
- std::vector<const NamedService *> retval;
- // get list of all names in myrpcsrvmap
- for (const auto & entry : _map) {
- retval.push_back(entry.second);
- }
- return retval;
-}
-
-
-
-void
-VisibleMap::addNew(const NamedService *rpcsrv)
-{
- LOG_ASSERT(rpcsrv != nullptr);
- LOG_ASSERT(_map.find(rpcsrv->getName()) == _map.end());
- _map[rpcsrv->getName()] = rpcsrv;
-
- _history.add(rpcsrv->getName(), _genCnt);
- updated();
-}
-
-
-const NamedService *
-VisibleMap::remove(const std::string &name) {
-
- const NamedService *d = _map[name];
- _map.erase(name);
- if (d != nullptr) {
- _history.add(name, _genCnt);
- updated();
- }
- return d;
-}
-
-
-const NamedService *
-VisibleMap::update(const NamedService *rpcsrv) {
- LOG_ASSERT(rpcsrv != nullptr);
-
- const NamedService *d = rpcsrv;
- std::swap(d, _map[rpcsrv->getName()]);
- LOG_ASSERT(d != nullptr);
-
- _history.add(rpcsrv->getName(), _genCnt);
- updated();
-
- return d;
-}
-
-VisibleMap::MapDiff
-VisibleMap::history(const vespalib::GenCnt& gen) const
-{
- MapDiff retval;
- std::set<std::string> names = _history.since(gen);
- for (const auto & name : names)
- {
- const NamedService *val = lookup(name.c_str());
- if (val == nullptr) {
- retval.removed.push_back(name);
- } else {
- retval.updated.push_back(val);
- }
- }
- return retval;
-}
-
-VisibleMap::MapDiff::MapDiff() = default;
-VisibleMap::MapDiff::~MapDiff() = default;
-
-VisibleMap::VisibleMap()
- : _map(),
- _waitList(),
- _genCnt(1)
-{
-}
-VisibleMap::~VisibleMap()
-{
- aborted();
-}
-
-
-bool
-VisibleMap::match(const char *name, const char *pattern)
-{
- LOG_ASSERT(name != nullptr);
- LOG_ASSERT(pattern != nullptr);
- while (*pattern != '\0') {
- if (*name == *pattern) {
- ++name;
- ++pattern;
- } else if (*pattern == '*') {
- ++pattern;
- while (*name != '/' && *name != '\0') {
- ++name;
- }
- } else {
- return false;
- }
- }
- return (*name == *pattern);
-}
-
-//-----------------------------------------------------------------------------
-
-} // namespace slobrok
diff --git a/slobrok/src/vespa/slobrok/server/visible_map.h b/slobrok/src/vespa/slobrok/server/visible_map.h
deleted file mode 100644
index 6ea2d5e2a46..00000000000
--- a/slobrok/src/vespa/slobrok/server/visible_map.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#pragma once
-
-#include "history.h"
-#include "named_service.h"
-#include <unordered_map>
-#include <string>
-#include <memory>
-
-namespace slobrok {
-
-/**
- * @class VisibleMap
- * @brief API to the collection of NamedService
- * name->spec mappings visible to the world
- **/
-
-class VisibleMap
-{
-public:
- class IUpdateListener
- {
- public:
- /**
- * Signals that the given RPC server map has been updated. The
- * notification will be one-shot; to get further update
- * notifications you will need to re-register the listener.
- *
- * @param map the map that became updated
- **/
- virtual void updated(VisibleMap &map) = 0;
- virtual void aborted(VisibleMap &map) = 0;
- protected:
- virtual ~IUpdateListener() {}
- };
-
- typedef std::vector<const NamedService *> RpcSrvlist;
-
- struct MapDiff
- {
- MapDiff();
- ~MapDiff();
- std::vector<std::string> removed;
- RpcSrvlist updated;
- };
-
-private:
- using Map = std::unordered_map<std::string, const NamedService *>;
- using WaitList = std::vector<IUpdateListener *>;
-
- Map _map;
- WaitList _waitList;
- vespalib::GenCnt _genCnt;
- History _history;
-
- static bool match(const char *name, const char *pattern);
-
- void updated();
- void aborted();
-
-public:
- void addUpdateListener(IUpdateListener *l);
- void removeUpdateListener(IUpdateListener *l);
-
- void addNew(const NamedService *rpcsrv);
- const NamedService *remove(const std::string &name);
- const NamedService *update(const NamedService *rpcsrv);
-
- const NamedService *lookup(const std::string &name) const;
- RpcSrvlist allVisible() const;
-
- const vespalib::GenCnt& genCnt() { return _genCnt; }
-
- bool hasHistory(vespalib::GenCnt gen) const { return _history.has(gen); }
-
- MapDiff history(const vespalib::GenCnt& gen) const;
-
- VisibleMap(const VisibleMap &) = delete;
- VisibleMap &operator=(const VisibleMap &) = delete;
- VisibleMap();
- ~VisibleMap();
-};
-
-//-----------------------------------------------------------------------------
-
-} // namespace slobrok
-