diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-05-10 11:25:48 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-05-10 12:25:38 +0000 |
commit | 4412aace869986be3a1060f78f367841353d3384 (patch) | |
tree | f4b5e1f6da5eaf1563f3b2fd64779800acfd5796 /storageserver/src | |
parent | 840d4e0578dc627b75bcd0050f1b253e84cc30ed (diff) |
Simplify the supervisor responsibility
Diffstat (limited to 'storageserver/src')
-rw-r--r-- | storageserver/src/tests/storageservertest.cpp | 75 |
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 { |