diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-05 05:32:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 05:32:02 -0800 |
commit | 15d09c5b5a02bd3c7cf859401e4a613edeebd901 (patch) | |
tree | 440e04af619d9f83279fd593ca272dba772ddb5e /storage | |
parent | 17a8ab2b1d0600e9651b1aa0748edba8f48707bf (diff) | |
parent | 1cfdd7f98bf1a33e7edc6cfb646ee53d5654c7f4 (diff) |
Merge branch 'master' into balder/use-duration-in-messagebus-and-storageapi-rebased-1
Diffstat (limited to 'storage')
12 files changed, 46 insertions, 29 deletions
diff --git a/storage/src/tests/common/metricstest.cpp b/storage/src/tests/common/metricstest.cpp index d1421845b81..d698cbb5e05 100644 --- a/storage/src/tests/common/metricstest.cpp +++ b/storage/src/tests/common/metricstest.cpp @@ -1,6 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/document/fieldvalue/document.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> #include <vespa/storage/bucketdb/bucketmanager.h> @@ -14,6 +13,7 @@ #include <vespa/config/common/exceptions.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/gtest/gtest.h> +#include <vespa/vespalib/util/time.h> #include <gmock/gmock.h> #include <thread> @@ -202,7 +202,7 @@ void MetricsTest::createFakeLoad() while (uint64_t(_metricManager->getLastProcessedTime()) < _clock->getTimeInSeconds().getTime()) { - FastOS_Thread::Sleep(5); + std::this_thread::sleep_for(5ms); _metricManager->timeChangedNotification(); } } @@ -257,7 +257,7 @@ TEST_F(MetricsTest, snapshot_presenting) { uint64_t(_metricManager->getLastProcessedTime()) < _clock->getTimeInSeconds().getTime()) { - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); } } LOG(debug, "5 minute snapshot should have been taken. Adding put count"); diff --git a/storage/src/tests/common/teststorageapp.cpp b/storage/src/tests/common/teststorageapp.cpp index dd89082d3e7..082af954871 100644 --- a/storage/src/tests/common/teststorageapp.cpp +++ b/storage/src/tests/common/teststorageapp.cpp @@ -7,10 +7,11 @@ #include <vespa/config-load-type.h> #include <vespa/config-fleetcontroller.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/util/time.h> #include <vespa/config/config.h> #include <vespa/config/helper/configgetter.hpp> +#include <thread> #include <vespa/log/log.h> LOG_SETUP(".test.servicelayerapp"); @@ -111,7 +112,7 @@ TestStorageApp::waitUntilInitialized( framework::MilliSecTime endTime( clock.getTimeInMillis() + timeout.getMillis()); while (!isInitialized()) { - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); framework::MilliSecTime currentTime(clock.getTimeInMillis()); if (currentTime > endTime) { std::ostringstream error; diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp index 8fa8a6bcede..d456401876e 100644 --- a/storage/src/tests/distributor/distributortest.cpp +++ b/storage/src/tests/distributor/distributortest.cpp @@ -11,9 +11,10 @@ #include <vespa/document/test/make_document_bucket.h> #include <vespa/document/test/make_bucket_space.h> #include <vespa/storage/config/config-stor-distributormanager.h> -#include <tests/common/dummystoragelink.h> #include <vespa/storage/distributor/distributor.h> #include <vespa/vespalib/text/stringtokenizer.h> +#include <vespa/vespalib/util/time.h> +#include <thread> #include <vespa/vespalib/gtest/gtest.h> #include <gmock/gmock.h> @@ -383,7 +384,7 @@ TEST_F(DistributorTest, tick_processes_status_requests) { thread, "statustest", tickWaitMs, tickMaxProcessTime, ticksBeforeWait)); while (true) { - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); framework::TickingLockGuard guard( distributor_thread_pool().freezeCriticalTicks()); if (!distributor_status_todos().empty()) { diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp index b46c0236150..64306fa7c24 100644 --- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp @@ -20,8 +20,10 @@ #include <vespa/persistence/spi/test.h> #include <vespa/config/common/exceptions.h> #include <vespa/fastos/file.h> +#include <vespa/vespalib/util/time.h> #include <vespa/vespalib/gtest/gtest.h> #include <atomic> +#include <thread> #include <vespa/log/log.h> LOG_SETUP(".filestormanagertest"); @@ -556,7 +558,7 @@ public: auto cmd = std::make_shared<api::PutCommand>(makeDocumentBucket(bucket), _doc, 100); _handler.schedule(cmd, 0); - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); } _threadDone = true; @@ -589,13 +591,13 @@ public: if (msg.second.get()) { uint32_t originalConfig = _config.load(); _fetchedCount++; - FastOS_Thread::Sleep(5); + std::this_thread::sleep_for(5ms); if (_config.load() != originalConfig) { _failed = true; } } else { - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); } } @@ -634,7 +636,7 @@ TEST_F(FileStorManagerTest, handler_paused_multi_thread) { thread.start(pool); for (uint32_t i = 0; i < 50; ++i) { - FastOS_Thread::Sleep(2); + std::this_thread::sleep_for(2ms); ResumeGuard guard = filestorHandler.pause(); thread._config.fetch_add(1); uint32_t count = thread._fetchedCount; @@ -646,7 +648,7 @@ TEST_F(FileStorManagerTest, handler_paused_multi_thread) { ASSERT_FALSE(thread._failed); while (!pushthread._threadDone || !thread._threadDone) { - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); } } @@ -869,7 +871,7 @@ TEST_F(FileStorManagerTest, handler_timeout) { filestorHandler.schedule(cmd, 0); } - FastOS_Thread::Sleep(51); + std::this_thread::sleep_for(51ms); for (;;) { auto lock = filestorHandler.getNextMessage(0, stripeId); if (lock.first.get()) { @@ -944,7 +946,7 @@ TEST_F(FileStorManagerTest, priority) { // Wait until everything is done. int count = 0; while (documents.size() != top.getNumReplies() && count < 10000) { - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); count++; } ASSERT_LT(count, 10000); diff --git a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp index 0d43f8a9020..ba344971c3b 100644 --- a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp +++ b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp @@ -9,6 +9,8 @@ #include <vespa/vespalib/util/thread.h> #include <vespa/vespalib/stllike/hash_set_insert.hpp> #include <vespa/vespalib/gtest/gtest.h> +#include <vespa/vespalib/util/time.h> +#include <thread> #include <vespa/log/log.h> LOG_SETUP(".operationabortingtest"); @@ -53,7 +55,7 @@ public: (void) context; _queueBarrier.await(); // message abort stage with active opertion in disk queue - FastOS_Thread::Sleep(75); + std::this_thread::sleep_for(75ms); _completionBarrier.await(); // test finished return spi::Result(); diff --git a/storage/src/tests/storageserver/bucketintegritycheckertest.cpp b/storage/src/tests/storageserver/bucketintegritycheckertest.cpp index ae466f04734..8a68adf226c 100644 --- a/storage/src/tests/storageserver/bucketintegritycheckertest.cpp +++ b/storage/src/tests/storageserver/bucketintegritycheckertest.cpp @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/storage/bucketdb/bucketmanager.h> -#include <vespa/storage/persistence/filestorage/filestormanager.h> #include <vespa/storage/storageserver/bucketintegritychecker.h> #include <vespa/storageapi/message/persistence.h> #include <tests/common/testhelper.h> @@ -9,6 +8,8 @@ #include <vespa/vespalib/io/fileutil.h> #include <tests/common/teststorageapp.h> #include <vespa/vespalib/gtest/gtest.h> +#include <vespa/vespalib/util/time.h> +#include <thread> using namespace ::testing; @@ -175,13 +176,13 @@ TEST_F(BucketIntegrityCheckerTest, basic_functionality) { checker.getSchedulingOptions()._minCycleTime = framework::SecondTime(60 * 60); topLink.open(); // Waiting for system to be initialized - FastOS_Thread::Sleep(10); // Give next message chance to come + std::this_thread::sleep_for(10ms); // Give next message chance to come ASSERT_COMMAND_COUNT(0, *dummyLink); topLink.doneInit(); checker.bump(); // Should have started new run with 2 pending per disk dummyLink->waitForMessages(4, _timeout); - FastOS_Thread::Sleep(10); // Give 5th message chance to come + std::this_thread::sleep_for(10ms); // Give 5th message chance to come ASSERT_COMMAND_COUNT(4, *dummyLink); auto* cmd1 = dynamic_cast<RepairBucketCommand*>(dummyLink->getCommand(0).get()); EXPECT_EQ(230, cmd1->getPriority()); @@ -200,13 +201,13 @@ TEST_F(BucketIntegrityCheckerTest, basic_functionality) { // Answering a message on disk with no more buckets does not trigger new auto reply1 = std::make_shared<RepairBucketReply>(*cmd3); ASSERT_TRUE(checker.onUp(reply1)); - FastOS_Thread::Sleep(10); // Give next message chance to come + std::this_thread::sleep_for(10ms); // Give next message chance to come ASSERT_COMMAND_COUNT(4, *dummyLink); // Answering a message on disk with more buckets trigger new repair auto reply2 = std::make_shared<RepairBucketReply>(*cmd2); ASSERT_TRUE(checker.onUp(reply2)); dummyLink->waitForMessages(5, _timeout); - FastOS_Thread::Sleep(10); // Give 6th message chance to come + std::this_thread::sleep_for(10ms); // Give 6th message chance to come ASSERT_COMMAND_COUNT(5, *dummyLink); auto* cmd5 = dynamic_cast<RepairBucketCommand*>(dummyLink->getCommand(4).get()); ASSERT_TRUE(cmd5); @@ -217,7 +218,7 @@ TEST_F(BucketIntegrityCheckerTest, basic_functionality) { reply3->setResult(api::ReturnCode(api::ReturnCode::IGNORED)); ASSERT_TRUE(checker.onUp(reply3)); dummyLink->waitForMessages(6, _timeout); - FastOS_Thread::Sleep(10); // Give 7th message chance to come + std::this_thread::sleep_for(10ms); // Give 7th message chance to come ASSERT_COMMAND_COUNT(6, *dummyLink); auto* cmd6 = dynamic_cast<RepairBucketCommand*>(dummyLink->getCommand(5).get()); ASSERT_TRUE(cmd6); @@ -227,7 +228,7 @@ TEST_F(BucketIntegrityCheckerTest, basic_functionality) { auto reply4 = std::make_shared<RepairBucketReply>(*cmd4); reply3->setResult(api::ReturnCode(api::ReturnCode::BUCKET_NOT_FOUND)); ASSERT_TRUE(checker.onUp(reply4)); - FastOS_Thread::Sleep(10); // Give 7th message chance to come + std::this_thread::sleep_for(10ms); // Give 7th message chance to come ASSERT_COMMAND_COUNT(6, *dummyLink); // Send a repair reply that actually have corrected the bucket. @@ -247,13 +248,13 @@ TEST_F(BucketIntegrityCheckerTest, basic_functionality) { EXPECT_EQ(document::BucketId(16, 0x234), cmd7->getBucketId()); auto reply7 = std::make_shared<RepairBucketReply>(*cmd7); ASSERT_TRUE(checker.onUp(reply7)); - FastOS_Thread::Sleep(10); // Give 8th message chance to come + std::this_thread::sleep_for(10ms); // Give 8th message chance to come ASSERT_COMMAND_COUNT(7, *dummyLink); // Still not time for next iteration dummyLink->reset(); _node->getClock().setAbsoluteTimeInSeconds(getDate("week1 sun 00:59:59")); - FastOS_Thread::Sleep(10); // Give new run chance to start + std::this_thread::sleep_for(10ms); // Give new run chance to start ASSERT_COMMAND_COUNT(0, *dummyLink); // Pass time until next cycle should start diff --git a/storage/src/tests/storageserver/communicationmanagertest.cpp b/storage/src/tests/storageserver/communicationmanagertest.cpp index caee6e6ab91..6657a9f1600 100644 --- a/storage/src/tests/storageserver/communicationmanagertest.cpp +++ b/storage/src/tests/storageserver/communicationmanagertest.cpp @@ -15,6 +15,8 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/documentapi/messagebus/messages/removedocumentmessage.h> #include <vespa/documentapi/messagebus/messages/getdocumentreply.h> +#include <vespa/vespalib/util/time.h> +#include <thread> #include <vespa/vespalib/gtest/gtest.h> using document::test::makeDocumentBucket; @@ -65,7 +67,7 @@ TEST_F(CommunicationManagerTest, simple) { distributor.open(); storage.open(); - FastOS_Thread::Sleep(1000); + std::this_thread::sleep_for(1s); // Send a message through from distributor to storage auto cmd = std::make_shared<api::GetCommand>( diff --git a/storage/src/tests/storageserver/statereportertest.cpp b/storage/src/tests/storageserver/statereportertest.cpp index c84f9311c52..dc8094275d1 100644 --- a/storage/src/tests/storageserver/statereportertest.cpp +++ b/storage/src/tests/storageserver/statereportertest.cpp @@ -11,6 +11,8 @@ #include <vespa/config/common/exceptions.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/gtest/gtest.h> +#include <vespa/vespalib/util/time.h> +#include <thread> #include <vespa/log/log.h> LOG_SETUP(".test.statereporter"); @@ -233,7 +235,7 @@ TEST_F(StateReporterTest, report_metrics) { uint64_t(_metricManager->getLastProcessedTime()) < _clock->getTimeInSeconds().getTime()) { - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); } } LOG(debug, "5 minute snapshot should have been taken. Adding put count"); diff --git a/storage/src/vespa/storage/storageserver/fnetlistener.cpp b/storage/src/vespa/storage/storageserver/fnetlistener.cpp index 45bd9c64fac..c5d7880d966 100644 --- a/storage/src/vespa/storage/storageserver/fnetlistener.cpp +++ b/storage/src/vespa/storage/storageserver/fnetlistener.cpp @@ -6,9 +6,11 @@ #include <vespa/storageapi/message/state.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/host_name.h> +#include <vespa/vespalib/util/time.h> #include <vespa/fnet/frt/supervisor.h> #include <vespa/fnet/transport.h> #include <sstream> +#include <thread> #include <vespa/log/log.h> LOG_SETUP(".rpc.listener"); @@ -50,7 +52,7 @@ FNetListener::registerHandle(vespalib::stringref handle) { _slobrokRegister.registerName(handle); while (_slobrokRegister.busy()) { LOG(debug, "Waiting to register in slobrok"); - FastOS_Thread::Sleep(50); + std::this_thread::sleep_for(50ms); } _handle = handle; } diff --git a/storage/src/vespa/storage/storageserver/fnetlistener.h b/storage/src/vespa/storage/storageserver/fnetlistener.h index 205a5af4586..e37727beb44 100644 --- a/storage/src/vespa/storage/storageserver/fnetlistener.h +++ b/storage/src/vespa/storage/storageserver/fnetlistener.h @@ -5,6 +5,7 @@ #include <atomic> class FNET_Transport; +class FastOS_ThreadPool; namespace storage { diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp index c5a0a031067..e962ee4b1b6 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.cpp +++ b/storage/src/vespa/storage/storageserver/storagenode.cpp @@ -14,6 +14,7 @@ #include <vespa/storage/common/statusmetricconsumer.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/util/time.h> #include <vespa/metrics/metricmanager.h> #include <fcntl.h> @@ -568,7 +569,7 @@ StorageNode::waitUntilInitialized(uint32_t timeout) { lib::NodeState nodeState(*_component->getStateUpdater().getReportedNodeState()); if (nodeState.getState() == lib::State::UP) break; } - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); if (clock.getTimeInMillis() >= endTime) { std::ostringstream ost; ost << "Storage server not initialized after waiting timeout of " diff --git a/storage/src/vespa/storage/tools/storage-cmd.cpp b/storage/src/vespa/storage/tools/storage-cmd.cpp index daaa890873f..8c0fcc83330 100644 --- a/storage/src/vespa/storage/tools/storage-cmd.cpp +++ b/storage/src/vespa/storage/tools/storage-cmd.cpp @@ -3,6 +3,8 @@ #include <vespa/slobrok/sbmirror.h> #include <vespa/fastos/app.h> #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/time.h> +#include <thread> #include <vespa/log/log.h> LOG_SETUP("vespa-storage-cmd"); @@ -61,7 +63,7 @@ public: slobrok::api::MirrorAPI mirror(supervisor.supervisor(), sbcfg); while (!mirror.ready()) { - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); } slobrok::api::MirrorAPI::SpecList list = mirror.lookup(_argv[1]); |