aboutsummaryrefslogtreecommitdiffstats
path: root/storageserver
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-05-10 11:25:48 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-05-10 12:25:38 +0000
commit4412aace869986be3a1060f78f367841353d3384 (patch)
treef4b5e1f6da5eaf1563f3b2fd64779800acfd5796 /storageserver
parent840d4e0578dc627b75bcd0050f1b253e84cc30ed (diff)
Simplify the supervisor responsibility
Diffstat (limited to 'storageserver')
-rw-r--r--storageserver/src/tests/storageservertest.cpp75
1 files changed, 37 insertions, 38 deletions
diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp
index 2ef770b68b1..413acf89f27 100644
--- a/storageserver/src/tests/storageservertest.cpp
+++ b/storageserver/src/tests/storageservertest.cpp
@@ -33,51 +33,50 @@ using document::test::makeDocumentBucket;
namespace storage {
namespace {
- uint64_t getTimeInMillis() {
- struct timeval t;
- gettimeofday(&t, 0);
- return (t.tv_sec * uint64_t(1000)) + (t.tv_usec / uint64_t(1000));
- }
-
- class SlobrokMirror {
- config::ConfigUri config;
- FRT_Supervisor visor;
- std::unique_ptr<slobrok::api::MirrorAPI> mirror;
- public:
- SlobrokMirror(const config::ConfigUri & cfg) : config(cfg) {}
+uint64_t getTimeInMillis() {
+ struct timeval t;
+ gettimeofday(&t, 0);
+ return (t.tv_sec * uint64_t(1000)) + (t.tv_usec / uint64_t(1000));
+}
- void init(uint32_t timeoutms) {
- uint64_t timeout = getTimeInMillis() + timeoutms;
- visor.Start();
- mirror.reset(new slobrok::api::MirrorAPI(visor, config));
- while (!mirror->ready()) {
- if (getTimeInMillis() > timeout)
- throw vespalib::IllegalStateException(
- "Failed to initialize slobrok mirror within "
- "timeout.", VESPA_STRLOC);
- FastOS_Thread::Sleep(1);
- }
+class SlobrokMirror {
+ config::ConfigUri config;
+ fnet::frt::StandaloneFRT visor;
+ std::unique_ptr<slobrok::api::MirrorAPI> mirror;
+
+public:
+ SlobrokMirror(const config::ConfigUri &cfg) : config(cfg) {}
+
+ void init(uint32_t timeoutms) {
+ uint64_t timeout = getTimeInMillis() + timeoutms;
+ mirror.reset(new slobrok::api::MirrorAPI(visor.supervisor(), config));
+ while (!mirror->ready()) {
+ if (getTimeInMillis() > timeout)
+ throw vespalib::IllegalStateException(
+ "Failed to initialize slobrok mirror within "
+ "timeout.", VESPA_STRLOC);
+ FastOS_Thread::Sleep(1);
}
+ }
- slobrok::api::MirrorAPI& getMirror() {
- if (mirror.get() == 0) throw vespalib::IllegalStateException(
+ slobrok::api::MirrorAPI &getMirror() {
+ if (mirror.get() == 0)
+ throw vespalib::IllegalStateException(
"You need to call init() before you can fetch mirror");
- return *mirror;
- }
- FRT_Supervisor& getSupervisor() {
- if (mirror.get() == 0) throw vespalib::IllegalStateException(
+ return *mirror;
+ }
+
+ FRT_Supervisor &getSupervisor() {
+ if (mirror.get() == 0)
+ throw vespalib::IllegalStateException(
"You need to call init() before you can fetch supervisor");
- return visor;
- }
+ return visor.supervisor();
+ }
+
+ ~SlobrokMirror() = default;
+};
- ~SlobrokMirror() {
- if (mirror) {
- mirror.reset();
- visor.ShutDown(true);
- }
- }
- };
}
struct StorageServerTest : public CppUnit::TestFixture {