summaryrefslogtreecommitdiffstats
path: root/slobrok
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-12-05 21:59:00 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2016-12-12 02:55:45 +0100
commit36be03af9ccb5ede87f7a5bc3d37526cdc9b2bc4 (patch)
tree4f95a3c666ad80a5e6066dfcf2d75f54e67d6866 /slobrok
parentf94a9a21d6d546868ef2cf63ea3532469450ffd7 (diff)
Avoid pulling in all of slobrok and config everywhere.
Diffstat (limited to 'slobrok')
-rw-r--r--slobrok/src/tests/mirrorapi/match_test.cpp2
-rw-r--r--slobrok/src/vespa/slobrok/imirrorapi.h67
-rw-r--r--slobrok/src/vespa/slobrok/sbmirror.h68
3 files changed, 76 insertions, 61 deletions
diff --git a/slobrok/src/tests/mirrorapi/match_test.cpp b/slobrok/src/tests/mirrorapi/match_test.cpp
index 874c39a6d3f..571748dfd28 100644
--- a/slobrok/src/tests/mirrorapi/match_test.cpp
+++ b/slobrok/src/tests/mirrorapi/match_test.cpp
@@ -9,6 +9,8 @@ class MatchTester : public slobrok::api::IMirrorAPI
}
virtual uint32_t updates() const override { return 0; }
+ virtual bool ready() const { return true; }
+
const std::string name;
void testMatch(const char *n, const char *p, bool expected)
diff --git a/slobrok/src/vespa/slobrok/imirrorapi.h b/slobrok/src/vespa/slobrok/imirrorapi.h
new file mode 100644
index 00000000000..1995969e94a
--- /dev/null
+++ b/slobrok/src/vespa/slobrok/imirrorapi.h
@@ -0,0 +1,67 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include <string>
+#include <vector>
+
+namespace slobrok {
+namespace api {
+
+/**
+ * @brief Defines an interface for the name server lookup.
+ **/
+class IMirrorAPI {
+protected:
+ static bool match(const char *name, const char *pattern);
+
+public:
+ /**
+ * @brief Release any allocated resources.
+ **/
+ virtual ~IMirrorAPI() { }
+
+ /**
+ * @brief pair of <name, connectionspec>.
+ *
+ * The first element of pair is a string containing the service name.
+ * The second is the connection spec, typically "tcp/foo.bar.com:42"
+ **/
+ typedef std::pair<std::string, std::string> Spec;
+
+ /**
+ * @brief vector of <name, connectionspec> pairs.
+ *
+ * The first element of each pair is a string containing the service name.
+ * The second is the connection spec, typically "tcp/foo.bar.com:42"
+ **/
+ typedef std::vector<Spec> SpecList;
+
+ /**
+ * Obtain all the services matching a given pattern.
+ *
+ * The pattern is matched against all service names in the local mirror repository. A service name may contain '/'
+ * as a separator token. A pattern may contain '*' to match anything up to the next '/' (or the end of the
+ * name). This means that the pattern 'foo/<!-- slash-star -->*<!-- star-slash -->/baz' would match the service
+ * names 'foo/bar/baz' and 'foo/xyz/baz'. The pattern 'foo/b*' would match 'foo/bar', but neither 'foo/xyz' nor
+ * 'foo/bar/baz'. The pattern 'a*b' will never match anything.
+ *
+ * @return a list of all matching services, with corresponding connect specs
+ * @param pattern The pattern used for matching
+ **/
+ virtual SpecList lookup(const std::string & pattern) const = 0;
+
+ /**
+ * Obtain the number of updates seen by this mirror. The value may wrap, but will never become 0 again. This can be
+ * used for name lookup optimization, because the results returned by lookup() will never change unless this number
+ * also changes.
+ *
+ * @return number of slobrok updates seen
+ **/
+ virtual uint32_t updates() const = 0;
+
+ virtual bool ready() const = 0;
+};
+
+} // namespace api
+} // namespace slobrok
+
diff --git a/slobrok/src/vespa/slobrok/sbmirror.h b/slobrok/src/vespa/slobrok/sbmirror.h
index 7336e511d92..2193fee487f 100644
--- a/slobrok/src/vespa/slobrok/sbmirror.h
+++ b/slobrok/src/vespa/slobrok/sbmirror.h
@@ -1,72 +1,18 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/fnet/frt/frt.h>
-#include <vespa/vespalib/util/gencnt.h>
-#include <vespa/vespalib/util/sync.h>
+#include "imirrorapi.h"
#include "backoff.h"
#include "sblist.h"
#include "cfg.h"
-#include <string>
-#include <vector>
+#include <vespa/fnet/frt/frt.h>
+#include <vespa/vespalib/util/gencnt.h>
+#include <vespa/vespalib/util/sync.h>
namespace slobrok {
namespace api {
/**
- * @brief Defines an interface for the name server lookup.
- **/
-class IMirrorAPI {
-protected:
- static bool match(const char *name, const char *pattern);
-
-public:
- /**
- * @brief Release any allocated resources.
- **/
- virtual ~IMirrorAPI() { }
-
- /**
- * @brief pair of <name, connectionspec>.
- *
- * The first element of pair is a string containing the service name.
- * The second is the connection spec, typically "tcp/foo.bar.com:42"
- **/
- typedef std::pair<std::string, std::string> Spec;
-
- /**
- * @brief vector of <name, connectionspec> pairs.
- *
- * The first element of each pair is a string containing the service name.
- * The second is the connection spec, typically "tcp/foo.bar.com:42"
- **/
- typedef std::vector<Spec> SpecList;
-
- /**
- * Obtain all the services matching a given pattern.
- *
- * The pattern is matched against all service names in the local mirror repository. A service name may contain '/'
- * as a separator token. A pattern may contain '*' to match anything up to the next '/' (or the end of the
- * name). This means that the pattern 'foo/<!-- slash-star -->*<!-- star-slash -->/baz' would match the service
- * names 'foo/bar/baz' and 'foo/xyz/baz'. The pattern 'foo/b*' would match 'foo/bar', but neither 'foo/xyz' nor
- * 'foo/bar/baz'. The pattern 'a*b' will never match anything.
- *
- * @return a list of all matching services, with corresponding connect specs
- * @param pattern The pattern used for matching
- **/
- virtual SpecList lookup(const std::string & pattern) const = 0;
-
- /**
- * Obtain the number of updates seen by this mirror. The value may wrap, but will never become 0 again. This can be
- * used for name lookup optimization, because the results returned by lookup() will never change unless this number
- * also changes.
- *
- * @return number of slobrok updates seen
- **/
- virtual uint32_t updates() const = 0;
-};
-
-/**
* @brief A MirrorAPI object is used to keep track of the services registered
* with a slobrok cluster.
*
@@ -102,10 +48,10 @@ public:
~MirrorAPI();
// Inherit doc from IMirrorAPI.
- SpecList lookup(const std::string & pattern) const;
+ SpecList lookup(const std::string & pattern) const override;
// Inherit doc from IMirrorAPI.
- uint32_t updates() const { return _updates.getAsInt(); }
+ uint32_t updates() const override { return _updates.getAsInt(); }
/**
* @brief Ask if the MirrorAPI has got any useful information from
@@ -119,7 +65,7 @@ public:
* @return true if the MirrorAPI object has
* asked for updates from a Slobrok and got any answer back
**/
- bool ready() const;
+ bool ready() const override;
private:
MirrorAPI(const MirrorAPI &);