From 0d58172a97648bd6823b675fcd7df49be3729562 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 30 Jul 2019 21:49:37 +0200 Subject: Use enum class for storage::spi::Result::ErrorType. --- .../conformancetest/conformancetest.cpp | 66 +++++++++++----------- .../persistence/dummyimpl/dummypersistence.cpp | 24 ++++---- persistence/src/vespa/persistence/spi/result.cpp | 7 ++- persistence/src/vespa/persistence/spi/result.h | 8 ++- searchcore/src/apps/proton/downpersistence.cpp | 2 +- .../documentdb/feedhandler/feedhandler_test.cpp | 10 ++-- .../persistenceengine/persistenceengine_test.cpp | 40 ++++++------- .../proton/persistenceengine/persistenceengine.cpp | 32 +++++------ .../searchcore/proton/server/buckethandler.cpp | 2 +- .../vespa/searchcore/proton/server/feedhandler.cpp | 8 +-- .../common/persistenceproviderwrapper.cpp | 4 +- .../common/persistenceproviderwrapper.h | 2 +- storage/src/tests/persistence/mergehandlertest.cpp | 12 ++-- .../persistence/provider_error_wrapper_test.cpp | 10 ++-- .../vespa/storage/persistence/bucketprocessor.cpp | 4 +- .../src/vespa/storage/persistence/mergehandler.cpp | 12 ++-- .../vespa/storage/persistence/persistenceutil.cpp | 12 ++-- .../storage/persistence/processallhandler.cpp | 2 +- .../storage/persistence/provider_error_wrapper.cpp | 4 +- 19 files changed, 134 insertions(+), 127 deletions(-) diff --git a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp index f77d7705a66..3ae13d6b21c 100644 --- a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp +++ b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp @@ -157,7 +157,7 @@ doIterate(PersistenceProvider& spi, Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); IterateResult result(spi.iterate(id, maxByteSize, context)); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); chunks.push_back(Chunk{result.steal_entries()}); if (result.isCompleted() @@ -214,13 +214,13 @@ iterateBucket(PersistenceProvider& spi, versions, context); - EXPECT_EQ(Result::NONE, iter.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, iter.getErrorCode()); while (true) { IterateResult result = spi.iterate(iter.getIteratorId(), std::numeric_limits().max(), context); - if (result.getErrorCode() != Result::NONE) { + if (result.getErrorCode() != Result::ErrorType::NONE) { return std::vector(); } auto list = result.steal_entries(); @@ -639,7 +639,7 @@ TEST_F(ConformanceTest, testPutNewDocumentVersion) GetResult gr = spi->get(bucket, document::AllFields(), doc1->getId(), context); - EXPECT_EQ(Result::NONE, gr.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, gr.getErrorCode()); EXPECT_EQ(Timestamp(4), gr.getTimestamp()); if (!((*doc2)==gr.getDocument())) { @@ -691,7 +691,7 @@ TEST_F(ConformanceTest, testPutOlderDocumentVersion) GetResult gr = spi->get(bucket, document::AllFields(), doc1->getId(), context); - EXPECT_EQ(Result::NONE, gr.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, gr.getErrorCode()); EXPECT_EQ(Timestamp(5), gr.getTimestamp()); EXPECT_EQ(*doc1, gr.getDocument()); } @@ -822,7 +822,7 @@ TEST_F(ConformanceTest, testRemove) doc1->getId(), context); - EXPECT_EQ(Result::NONE, getResult.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, getResult.getErrorCode()); EXPECT_EQ(Timestamp(0), getResult.getTimestamp()); EXPECT_TRUE(!getResult.hasDocument()); } @@ -848,7 +848,7 @@ TEST_F(ConformanceTest, testRemoveMerge) removeId, context); spi->flush(bucket, context); - EXPECT_EQ(Result::NONE, removeResult.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, removeResult.getErrorCode()); EXPECT_EQ(false, removeResult.wasFound()); } { @@ -876,7 +876,7 @@ TEST_F(ConformanceTest, testRemoveMerge) removeId, context); spi->flush(bucket, context); - EXPECT_EQ(Result::NONE, removeResult.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, removeResult.getErrorCode()); EXPECT_EQ(false, removeResult.wasFound()); } // Old entry may or may not be present, depending on the provider. @@ -904,7 +904,7 @@ TEST_F(ConformanceTest, testRemoveMerge) removeId, context); spi->flush(bucket, context); - EXPECT_EQ(Result::NONE, removeResult.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, removeResult.getErrorCode()); EXPECT_EQ(false, removeResult.wasFound()); } { @@ -957,7 +957,7 @@ TEST_F(ConformanceTest, testUpdate) context); spi->flush(bucket, context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(3), result.getExistingTimestamp()); } @@ -967,7 +967,7 @@ TEST_F(ConformanceTest, testUpdate) doc1->getId(), context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(4), result.getTimestamp()); EXPECT_EQ(document::IntFieldValue(42), static_cast( @@ -983,7 +983,7 @@ TEST_F(ConformanceTest, testUpdate) doc1->getId(), context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(0), result.getTimestamp()); EXPECT_TRUE(!result.hasDocument()); } @@ -993,13 +993,13 @@ TEST_F(ConformanceTest, testUpdate) context); spi->flush(bucket, context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(0), result.getExistingTimestamp()); } { GetResult result = spi->get(bucket, document::AllFields(), doc1->getId(), context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(0), result.getTimestamp()); EXPECT_TRUE(!result.hasDocument()); } @@ -1010,13 +1010,13 @@ TEST_F(ConformanceTest, testUpdate) // but since CreateIfNonExistent is set it should be auto-created anyway. UpdateResult result = spi->update(bucket, Timestamp(7), update, context); spi->flush(bucket, context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(7), result.getExistingTimestamp()); } { GetResult result = spi->get(bucket, document::AllFields(), doc1->getId(), context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(7), result.getTimestamp()); EXPECT_EQ(document::IntFieldValue(42), reinterpret_cast( @@ -1039,7 +1039,7 @@ TEST_F(ConformanceTest, testGet) GetResult result = spi->get(bucket, document::AllFields(), doc1->getId(), context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(0), result.getTimestamp()); } @@ -1060,7 +1060,7 @@ TEST_F(ConformanceTest, testGet) GetResult result = spi->get(bucket, document::AllFields(), doc1->getId(), context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(0), result.getTimestamp()); } } @@ -1077,7 +1077,7 @@ TEST_F(ConformanceTest, testIterateCreateIterator) spi::CreateIteratorResult result( createIterator(*spi, b, createSelection(""))); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); // Iterator ID 0 means invalid iterator, so cannot be returned // from a successful createIterator call. EXPECT_TRUE(result.getIteratorId() != IteratorId(0)); @@ -1096,7 +1096,7 @@ TEST_F(ConformanceTest, testIterateWithUnknownId) IteratorId unknownId(123); IterateResult result(spi->iterate(unknownId, 1024, context)); - EXPECT_EQ(Result::PERMANENT_ERROR, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::PERMANENT_ERROR, result.getErrorCode()); } TEST_F(ConformanceTest, testIterateDestroyIterator) @@ -1111,7 +1111,7 @@ TEST_F(ConformanceTest, testIterateDestroyIterator) CreateIteratorResult iter(createIterator(*spi, b, createSelection(""))); { IterateResult result(spi->iterate(iter.getIteratorId(), 1024, context)); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); } { @@ -1122,7 +1122,7 @@ TEST_F(ConformanceTest, testIterateDestroyIterator) // Iteration should now fail { IterateResult result(spi->iterate(iter.getIteratorId(), 1024, context)); - EXPECT_EQ(Result::PERMANENT_ERROR, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::PERMANENT_ERROR, result.getErrorCode()); } { Result destroyResult( @@ -1422,7 +1422,7 @@ TEST_F(ConformanceTest, testIterationRequiringDocumentIdOnlyMatching) CreateIteratorResult iter( createIterator(*spi, b, sel, NEWEST_DOCUMENT_OR_REMOVE)); - EXPECT_TRUE(iter.getErrorCode() == Result::NONE); + EXPECT_TRUE(iter.getErrorCode() == Result::ErrorType::NONE); std::vector chunks = doIterate(*spi, iter.getIteratorId(), 4096); std::vector docs; @@ -1444,14 +1444,14 @@ TEST_F(ConformanceTest, testIterateBadDocumentSelection) { CreateIteratorResult iter( createIterator(*spi, b, createSelection("the muppet show"))); - if (iter.getErrorCode() == Result::NONE) { + if (iter.getErrorCode() == Result::ErrorType::NONE) { IterateResult result( spi->iterate(iter.getIteratorId(), 4096, context)); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(size_t(0), result.getEntries().size()); EXPECT_EQ(true, result.isCompleted()); } else { - EXPECT_EQ(Result::PERMANENT_ERROR, iter.getErrorCode()); + EXPECT_EQ(Result::ErrorType::PERMANENT_ERROR, iter.getErrorCode()); EXPECT_EQ(IteratorId(0), iter.getIteratorId()); } } @@ -1461,14 +1461,14 @@ TEST_F(ConformanceTest, testIterateBadDocumentSelection) b, createSelection( "unknownddoctype.something=thatthing"))); - if (iter.getErrorCode() == Result::NONE) { + if (iter.getErrorCode() == Result::ErrorType::NONE) { IterateResult result(spi->iterate( iter.getIteratorId(), 4096, context)); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(size_t(0), result.getEntries().size()); EXPECT_EQ(true, result.isCompleted()); } else { - EXPECT_EQ(Result::PERMANENT_ERROR, iter.getErrorCode()); + EXPECT_EQ(Result::ErrorType::PERMANENT_ERROR, iter.getErrorCode()); EXPECT_EQ(IteratorId(0), iter.getIteratorId()); } } @@ -1491,7 +1491,7 @@ TEST_F(ConformanceTest, testIterateAlreadyCompleted) verifyDocs(docs, chunks); IterateResult result(spi->iterate(iter.getIteratorId(), 4096, context)); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(size_t(0), result.getEntries().size()); EXPECT_TRUE(result.isCompleted()); @@ -1511,7 +1511,7 @@ TEST_F(ConformanceTest, testIterateEmptyBucket) CreateIteratorResult iter(createIterator(*spi, b, sel)); IterateResult result(spi->iterate(iter.getIteratorId(), 4096, context)); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(size_t(0), result.getEntries().size()); EXPECT_TRUE(result.isCompleted()); @@ -1556,7 +1556,7 @@ testDeleteBucketPostCondition(const PersistenceProvider::UP &spi, doc1.getId(), context); - EXPECT_EQ(Result::NONE, result.getErrorCode()); + EXPECT_EQ(Result::ErrorType::NONE, result.getErrorCode()); EXPECT_EQ(Timestamp(0), result.getTimestamp()); } } @@ -2152,7 +2152,7 @@ TEST_F(ConformanceTest, testMaintain) spi->put(bucket, Timestamp(3), doc1, context); spi->flush(bucket, context); - EXPECT_EQ(Result::NONE, + EXPECT_EQ(Result::ErrorType::NONE, spi->maintain(bucket, LOW).getErrorCode()); } diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp index 65759a0c783..6834f453695 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp @@ -409,7 +409,7 @@ DummyPersistence::setActiveState(const Bucket& b, BucketContentGuard::UP bc(acquireBucketWithLock(b)); if (!bc.get()) { - return BucketInfoResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return BucketInfoResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } (*bc)->setActive(newState == BucketInfo::ACTIVE); return Result(); @@ -424,7 +424,7 @@ DummyPersistence::getBucketInfo(const Bucket& b) const if (!bc.get()) { LOG(debug, "getBucketInfo(%s) : (bucket not found)", b.toString().c_str()); - return BucketInfoResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return BucketInfoResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } BucketInfo info((*bc)->getBucketInfo()); @@ -446,7 +446,7 @@ DummyPersistence::put(const Bucket& b, Timestamp t, const Document::SP& doc, assert(b.getBucketSpace() == FixedBucketSpaces::default_space()); BucketContentGuard::UP bc(acquireBucketWithLock(b)); if (!bc.get()) { - return BucketInfoResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return BucketInfoResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } DocEntry::SP existing = (*bc)->getEntry(t); @@ -454,7 +454,7 @@ DummyPersistence::put(const Bucket& b, Timestamp t, const Document::SP& doc, if (doc->getId() == *existing->getDocumentId()) { return Result(); } else { - return Result(Result::TIMESTAMP_EXISTS, + return Result(Result::ErrorType::TIMESTAMP_EXISTS, "Timestamp already existed"); } } @@ -474,7 +474,7 @@ DummyPersistence::maintain(const Bucket& b, if (_simulateMaintainFailure) { BucketContentGuard::UP bc(acquireBucketWithLock(b)); if (!bc.get()) { - return BucketInfoResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return BucketInfoResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } if (!(*bc)->_entries.empty()) { @@ -503,7 +503,7 @@ DummyPersistence::remove(const Bucket& b, BucketContentGuard::UP bc(acquireBucketWithLock(b)); if (!bc.get()) { - return RemoveResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return RemoveResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } DocEntry::SP entry((*bc)->getEntry(did)); @@ -564,13 +564,13 @@ DummyPersistence::createIterator( true).release()); if (!docSelection.get()) { return CreateIteratorResult( - Result::PERMANENT_ERROR, + Result::ErrorType::PERMANENT_ERROR, "Got invalid/unparseable document selection string"); } } BucketContentGuard::UP bc(acquireBucketWithLock(b, LockMode::Shared)); if (!bc.get()) { - return CreateIteratorResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return CreateIteratorResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } Iterator* it; @@ -650,7 +650,7 @@ DummyPersistence::iterate(IteratorId id, uint64_t maxByteSize, Context& ctx) con vespalib::MonitorGuard lock(_monitor); std::map::iterator iter(_iterators.find(id)); if (iter == _iterators.end()) { - return IterateResult(Result::PERMANENT_ERROR, + return IterateResult(Result::ErrorType::PERMANENT_ERROR, "Bug! Used iterate without sending createIterator first"); } it = iter->second.get(); @@ -659,7 +659,7 @@ DummyPersistence::iterate(IteratorId id, uint64_t maxByteSize, Context& ctx) con BucketContentGuard::UP bc(acquireBucketWithLock(it->_bucket, LockMode::Shared)); if (!bc.get()) { ctx.trace(9, "finished iterate(); bucket not found"); - return IterateResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return IterateResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } LOG(debug, "Iterator %" PRIu64 " acquired bucket lock", uint64_t(id)); @@ -776,7 +776,7 @@ DummyPersistence::split(const Bucket& source, BucketContentGuard::UP sourceGuard(acquireBucketWithLock(source)); if (!sourceGuard.get()) { LOG(debug, "%s not found", source.toString().c_str()); - return Result(Result::TRANSIENT_ERROR, "Bucket not found"); + return Result(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } BucketContentGuard::UP target1Guard(acquireBucketWithLock(target1)); BucketContentGuard::UP target2Guard(acquireBucketWithLock(target2)); @@ -863,7 +863,7 @@ DummyPersistence::revert(const Bucket& b, Timestamp t, Context&) BucketContentGuard::UP bc(acquireBucketWithLock(b)); if (!bc.get()) { - return BucketInfoResult(Result::TRANSIENT_ERROR, "Bucket not found"); + return BucketInfoResult(Result::ErrorType::TRANSIENT_ERROR, "Bucket not found"); } BucketContent& content(**bc); diff --git a/persistence/src/vespa/persistence/spi/result.cpp b/persistence/src/vespa/persistence/spi/result.cpp index 4aa01d22649..024f5595102 100644 --- a/persistence/src/vespa/persistence/spi/result.cpp +++ b/persistence/src/vespa/persistence/spi/result.cpp @@ -3,6 +3,7 @@ #include "result.h" #include #include +#include namespace storage::spi { @@ -13,7 +14,7 @@ Result::~Result() { } vespalib::string Result::toString() const { vespalib::asciistream os; - os << "Result(" << _errorCode << ", " << _errorMessage << ")"; + os << "Result(" << static_cast(_errorCode) << ", " << _errorMessage << ")"; return os.str(); } @@ -22,6 +23,10 @@ operator << (std::ostream & os, const Result & r) { return os << r.toString(); } +std::ostream & operator << (std::ostream & os, const Result::ErrorType &errorCode) { + return os << static_cast(errorCode); +} + GetResult::GetResult(Document::UP doc, Timestamp timestamp) : Result(), _timestamp(timestamp), diff --git a/persistence/src/vespa/persistence/spi/result.h b/persistence/src/vespa/persistence/spi/result.h index 0daa784caa4..fe8e74706bb 100644 --- a/persistence/src/vespa/persistence/spi/result.h +++ b/persistence/src/vespa/persistence/spi/result.h @@ -13,7 +13,7 @@ class Result { public: typedef std::unique_ptr UP; - enum ErrorType { + enum class ErrorType { NONE, TRANSIENT_ERROR, PERMANENT_ERROR, @@ -26,7 +26,7 @@ public: /** * Constructor to use for a result where there is no error. */ - Result() : _errorCode(NONE), _errorMessage() {} + Result() : _errorCode(ErrorType::NONE), _errorMessage() {} /** * Constructor to use when an error has been detected. @@ -46,7 +46,7 @@ public: } bool hasError() const { - return _errorCode != NONE; + return _errorCode != ErrorType::NONE; } ErrorType getErrorCode() const { @@ -66,6 +66,8 @@ private: std::ostream & operator << (std::ostream & os, const Result & r); +std::ostream & operator << (std::ostream & os, const Result::ErrorType &errorCode); + class BucketInfoResult : public Result { public: /** diff --git a/searchcore/src/apps/proton/downpersistence.cpp b/searchcore/src/apps/proton/downpersistence.cpp index 33ad4bc5024..4b911eb6d2b 100644 --- a/searchcore/src/apps/proton/downpersistence.cpp +++ b/searchcore/src/apps/proton/downpersistence.cpp @@ -10,7 +10,7 @@ namespace storage::spi { namespace { -Result errorResult(Result::FATAL_ERROR, "Node is down"); +Result errorResult(Result::ErrorType::FATAL_ERROR, "Node is down"); } diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 39fc93d5725..4b3b68a85ea 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -684,7 +684,7 @@ TEST_F("require that put is rejected if resource limit is reached", FeedHandlerF FeedTokenContext token; f.handler.performOperation(std::move(token.token), std::move(op)); EXPECT_EQUAL(0, f.feedView.put_count); - EXPECT_EQUAL(Result::RESOURCE_EXHAUSTED, token.getResult()->getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::RESOURCE_EXHAUSTED, token.getResult()->getErrorCode()); EXPECT_EQUAL("Put operation rejected for document 'id:test:searchdocument::foo' of type 'searchdocument': 'Attribute resource limit reached'", token.getResult()->getErrorMessage()); } @@ -700,7 +700,7 @@ TEST_F("require that update is rejected if resource limit is reached", FeedHandl f.handler.performOperation(std::move(token.token), std::move(op)); EXPECT_EQUAL(0, f.feedView.update_count); EXPECT_TRUE(dynamic_cast(token.getResult())); - EXPECT_EQUAL(Result::RESOURCE_EXHAUSTED, token.getResult()->getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::RESOURCE_EXHAUSTED, token.getResult()->getErrorCode()); EXPECT_EQUAL("Update operation rejected for document 'id:test:searchdocument::foo' of type 'searchdocument': 'Attribute resource limit reached'", token.getResult()->getErrorMessage()); } @@ -715,7 +715,7 @@ TEST_F("require that remove is NOT rejected if resource limit is reached", FeedH FeedTokenContext token; f.handler.performOperation(std::move(token.token), std::move(op)); EXPECT_EQUAL(1, f.feedView.remove_count); - EXPECT_EQUAL(Result::NONE, token.getResult()->getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::NONE, token.getResult()->getErrorCode()); EXPECT_EQUAL("", token.getResult()->getErrorMessage()); } @@ -738,7 +738,7 @@ checkUpdate(FeedHandlerFixture &f, SchemaContext &schemaContext, EXPECT_TRUE(dynamic_cast(token.getResult())); if (expectReject) { TEST_DO(f.feedView.checkCounts(0, 0u, 0, 0u)); - EXPECT_EQUAL(Result::TRANSIENT_ERROR, token.getResult()->getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::TRANSIENT_ERROR, token.getResult()->getErrorCode()); if (fieldName == "tensor2") { EXPECT_EQUAL("Update operation rejected for document 'id:test:searchdocument::foo' of type 'searchdocument': 'Wrong tensor type: Field tensor type is 'tensor(x{},y{})' but other tensor type is 'tensor(x{})''", token.getResult()->getErrorMessage()); @@ -752,7 +752,7 @@ checkUpdate(FeedHandlerFixture &f, SchemaContext &schemaContext, } else { TEST_DO(f.feedView.checkCounts(0, 0u, 1, 16u)); } - EXPECT_EQUAL(Result::NONE, token.getResult()->getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::NONE, token.getResult()->getErrorCode()); EXPECT_EQUAL("", token.getResult()->getErrorMessage()); } } diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index 5484b8eacf0..cdc0e8656d8 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -469,7 +469,7 @@ TEST_F("require that puts are routed to handler", SimpleFixture) assertHandler(bucket1, tstamp1, docId1, f.hset.handler1); assertHandler(bucket1, tstamp1, docId2, f.hset.handler2); - EXPECT_EQUAL(Result(Result::PERMANENT_ERROR, "No handler for document type 'type3'"), + EXPECT_EQUAL(Result(Result::ErrorType::PERMANENT_ERROR, "No handler for document type 'type3'"), f.engine.put(bucket1, tstamp1, doc3, context)); } @@ -477,7 +477,7 @@ TEST_F("require that puts are routed to handler", SimpleFixture) TEST_F("require that puts with old id scheme are rejected", SimpleFixture) { storage::spi::LoadType loadType(0, "default"); Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); - EXPECT_EQUAL(Result(Result::PERMANENT_ERROR, "Old id scheme not supported in elastic mode (doc:old:id-scheme)"), + EXPECT_EQUAL(Result(Result::ErrorType::PERMANENT_ERROR, "Old id scheme not supported in elastic mode (doc:old:id-scheme)"), f.engine.put(bucket1, tstamp1, old_doc, context)); } @@ -490,7 +490,7 @@ TEST_F("require that put is rejected if resource limit is reached", SimpleFixtur storage::spi::LoadType loadType(0, "default"); Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); EXPECT_EQUAL( - Result(Result::RESOURCE_EXHAUSTED, + Result(Result::ErrorType::RESOURCE_EXHAUSTED, "Put operation rejected for document 'doc:old:id-scheme': 'Disk is full'"), f.engine.put(bucket1, tstamp1, old_doc, context)); } @@ -512,7 +512,7 @@ TEST_F("require that updates are routed to handler", SimpleFixture) assertHandler(bucket1, tstamp1, docId2, f.hset.handler2); EXPECT_EQUAL(tstamp3, ur.getExistingTimestamp()); - EXPECT_EQUAL(Result(Result::PERMANENT_ERROR, "No handler for document type 'type3'"), + EXPECT_EQUAL(Result(Result::ErrorType::PERMANENT_ERROR, "No handler for document type 'type3'"), f.engine.update(bucket1, tstamp1, upd3, context)); } @@ -522,7 +522,7 @@ TEST_F("require that updates with old id scheme are rejected", SimpleFixture) storage::spi::LoadType loadType(0, "default"); Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); - EXPECT_EQUAL(UpdateResult(Result::PERMANENT_ERROR, "Old id scheme not supported in elastic mode (doc:old:id-scheme)"), + EXPECT_EQUAL(UpdateResult(Result::ErrorType::PERMANENT_ERROR, "Old id scheme not supported in elastic mode (doc:old:id-scheme)"), f.engine.update(bucket1, tstamp1, old_upd, context)); } @@ -531,7 +531,7 @@ TEST_F("require that updates with bad ids are rejected", SimpleFixture) storage::spi::LoadType loadType(0, "default"); Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); - EXPECT_EQUAL(UpdateResult(Result::PERMANENT_ERROR, "Update operation rejected due to bad id (id:type2:type2::1, type1)"), + EXPECT_EQUAL(UpdateResult(Result::ErrorType::PERMANENT_ERROR, "Update operation rejected due to bad id (id:type2:type2::1, type1)"), f.engine.update(bucket1, tstamp1, bad_id_upd, context)); } @@ -544,7 +544,7 @@ TEST_F("require that update is rejected if resource limit is reached", SimpleFix Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); EXPECT_EQUAL( - Result(Result::RESOURCE_EXHAUSTED, + Result(Result::ErrorType::RESOURCE_EXHAUSTED, "Update operation rejected for document 'id:type1:type1::1': 'Disk is full'"), f.engine.update(bucket1, tstamp1, upd1, context)); } @@ -559,7 +559,7 @@ TEST_F("require that removes are routed to handlers", SimpleFixture) assertHandler(bucket0, tstamp0, docId0, f.hset.handler2); EXPECT_FALSE(rr.wasFound()); EXPECT_TRUE(rr.hasError()); - EXPECT_EQUAL(Result(Result::PERMANENT_ERROR, "No handler for document type 'type3'"), rr); + EXPECT_EQUAL(Result(Result::ErrorType::PERMANENT_ERROR, "No handler for document type 'type3'"), rr); f.hset.handler1.setExistingTimestamp(tstamp2); rr = f.engine.remove(bucket1, tstamp1, docId1, context); @@ -590,7 +590,7 @@ TEST_F("require that removes with old id scheme are rejected", SimpleFixture) storage::spi::LoadType loadType(0, "default"); Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); - EXPECT_EQUAL(RemoveResult(Result::PERMANENT_ERROR, "Old id scheme not supported in elastic mode (doc:old:id-scheme)"), + EXPECT_EQUAL(RemoveResult(Result::ErrorType::PERMANENT_ERROR, "Old id scheme not supported in elastic mode (doc:old:id-scheme)"), f.engine.remove(bucket1, tstamp1, old_docId, context)); } @@ -626,11 +626,11 @@ TEST_F("require that setClusterState() is routed to handlers", SimpleFixture) TEST_F("require that setActiveState() is routed to handlers and merged", SimpleFixture) { - f.hset.handler1.bucketStateResult = Result(Result::TRANSIENT_ERROR, "err1"); - f.hset.handler2.bucketStateResult = Result(Result::PERMANENT_ERROR, "err2"); + f.hset.handler1.bucketStateResult = Result(Result::ErrorType::TRANSIENT_ERROR, "err1"); + f.hset.handler2.bucketStateResult = Result(Result::ErrorType::PERMANENT_ERROR, "err2"); Result result = f.engine.setActiveState(bucket1, storage::spi::BucketInfo::NOT_ACTIVE); - EXPECT_EQUAL(Result::PERMANENT_ERROR, result.getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::PERMANENT_ERROR, result.getErrorCode()); EXPECT_EQUAL("err1, err2", result.getErrorMessage()); EXPECT_EQUAL(storage::spi::BucketInfo::NOT_ACTIVE, f.hset.handler1.lastBucketState); EXPECT_EQUAL(storage::spi::BucketInfo::NOT_ACTIVE, f.hset.handler2.lastBucketState); @@ -655,11 +655,11 @@ TEST_F("require that createBucket() is routed to handlers and merged", SimpleFix { storage::spi::LoadType loadType(0, "default"); Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); - f.hset.handler1._createBucketResult = Result(Result::TRANSIENT_ERROR, "err1a"); - f.hset.handler2._createBucketResult = Result(Result::PERMANENT_ERROR, "err2a"); + f.hset.handler1._createBucketResult = Result(Result::ErrorType::TRANSIENT_ERROR, "err1a"); + f.hset.handler2._createBucketResult = Result(Result::ErrorType::PERMANENT_ERROR, "err2a"); Result result = f.engine.createBucket(bucket1, context); - EXPECT_EQUAL(Result::PERMANENT_ERROR, result.getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::PERMANENT_ERROR, result.getErrorCode()); EXPECT_EQUAL("err1a, err2a", result.getErrorMessage()); } @@ -668,11 +668,11 @@ TEST_F("require that deleteBucket() is routed to handlers and merged", SimpleFix { storage::spi::LoadType loadType(0, "default"); Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); - f.hset.handler1.deleteBucketResult = Result(Result::TRANSIENT_ERROR, "err1"); - f.hset.handler2.deleteBucketResult = Result(Result::PERMANENT_ERROR, "err2"); + f.hset.handler1.deleteBucketResult = Result(Result::ErrorType::TRANSIENT_ERROR, "err1"); + f.hset.handler2.deleteBucketResult = Result(Result::ErrorType::PERMANENT_ERROR, "err2"); Result result = f.engine.deleteBucket(bucket1, context); - EXPECT_EQUAL(Result::PERMANENT_ERROR, result.getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::PERMANENT_ERROR, result.getErrorCode()); EXPECT_EQUAL("err1, err2", result.getErrorMessage()); } @@ -754,7 +754,7 @@ TEST_F("require that iterate requires valid iterator", SimpleFixture) { Context context(loadType, storage::spi::Priority(0), storage::spi::Trace::TraceLevel(0)); IterateResult it_result = f.engine.iterate(IteratorId(1), max_size, context); EXPECT_TRUE(it_result.hasError()); - EXPECT_EQUAL(Result::PERMANENT_ERROR, it_result.getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::PERMANENT_ERROR, it_result.getErrorCode()); EXPECT_EQUAL("Unknown iterator with id 1", it_result.getErrorMessage()); CreateIteratorResult result = @@ -799,7 +799,7 @@ TEST_F("require that destroyIterator prevents iteration", SimpleFixture) { uint64_t max_size = 1024; IterateResult it_result = f.engine.iterate(create_result.getIteratorId(), max_size, context); EXPECT_TRUE(it_result.hasError()); - EXPECT_EQUAL(Result::PERMANENT_ERROR, it_result.getErrorCode()); + EXPECT_EQUAL(Result::ErrorType::PERMANENT_ERROR, it_result.getErrorCode()); string msg_prefix = "Unknown iterator with id"; EXPECT_EQUAL(msg_prefix, it_result.getErrorMessage().substr(0, msg_prefix.size())); } diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp index 57e26f77cca..1f862b07048 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp @@ -325,7 +325,7 @@ PersistenceEngine::put(const Bucket& b, Timestamp t, const document::Document::S if (!_writeFilter.acceptWriteOperation()) { IResourceWriteFilter::State state = _writeFilter.getAcceptState(); if (!state.acceptWriteOperation()) { - return Result(Result::RESOURCE_EXHAUSTED, + return Result(Result::ErrorType::RESOURCE_EXHAUSTED, make_string("Put operation rejected for document '%s': '%s'", doc->getId().toString().c_str(), state.message().c_str())); } @@ -335,12 +335,12 @@ PersistenceEngine::put(const Bucket& b, Timestamp t, const document::Document::S LOG(spam, "put(%s, %" PRIu64 ", (\"%s\", \"%s\"))", b.toString().c_str(), static_cast(t.getValue()), docType.toString().c_str(), doc->getId().toString().c_str()); if (!doc->getId().hasDocType()) { - return Result(Result::PERMANENT_ERROR, + return Result(Result::ErrorType::PERMANENT_ERROR, make_string("Old id scheme not supported in elastic mode (%s)", doc->getId().toString().c_str())); } IPersistenceHandler::SP handler = getHandler(b.getBucketSpace(), docType); if (!handler) { - return Result(Result::PERMANENT_ERROR, + return Result(Result::ErrorType::PERMANENT_ERROR, make_string("No handler for document type '%s'", docType.toString().c_str())); } TransportLatch latch(1); @@ -356,13 +356,13 @@ PersistenceEngine::remove(const Bucket& b, Timestamp t, const DocumentId& did, C LOG(spam, "remove(%s, %" PRIu64 ", \"%s\")", b.toString().c_str(), static_cast(t.getValue()), did.toString().c_str()); if (!did.hasDocType()) { - return RemoveResult(Result::PERMANENT_ERROR, + return RemoveResult(Result::ErrorType::PERMANENT_ERROR, make_string("Old id scheme not supported in elastic mode (%s)", did.toString().c_str())); } DocTypeName docType(did.getDocType()); IPersistenceHandler::SP handler = getHandler(b.getBucketSpace(), docType); if (!handler) { - return RemoveResult(Result::PERMANENT_ERROR, + return RemoveResult(Result::ErrorType::PERMANENT_ERROR, make_string("No handler for document type '%s'", docType.toString().c_str())); } TransportLatch latch(1); @@ -378,7 +378,7 @@ PersistenceEngine::update(const Bucket& b, Timestamp t, const DocumentUpdate::SP if (!_writeFilter.acceptWriteOperation()) { IResourceWriteFilter::State state = _writeFilter.getAcceptState(); if (!state.acceptWriteOperation()) { - return UpdateResult(Result::RESOURCE_EXHAUSTED, + return UpdateResult(Result::ErrorType::RESOURCE_EXHAUSTED, make_string("Update operation rejected for document '%s': '%s'", upd->getId().toString().c_str(), state.message().c_str())); } @@ -386,16 +386,16 @@ PersistenceEngine::update(const Bucket& b, Timestamp t, const DocumentUpdate::SP try { upd->eagerDeserialize(); } catch (document::FieldNotFoundException & e) { - return UpdateResult(Result::TRANSIENT_ERROR, + return UpdateResult(Result::ErrorType::TRANSIENT_ERROR, make_string("Update operation rejected for document '%s' of type '%s': 'Field not found'", upd->getId().toString().c_str(), upd->getType().getName().c_str())); } catch (document::DocumentTypeNotFoundException & e) { - return UpdateResult(Result::TRANSIENT_ERROR, + return UpdateResult(Result::ErrorType::TRANSIENT_ERROR, make_string("Update operation rejected for document '%s' of type '%s'.", upd->getId().toString().c_str(), e.getDocumentTypeName().c_str())); } catch (document::WrongTensorTypeException &e) { - return UpdateResult(Result::TRANSIENT_ERROR, + return UpdateResult(Result::ErrorType::TRANSIENT_ERROR, make_string("Update operation rejected for document '%s' of type '%s': 'Wrong tensor type: %s'", upd->getId().toString().c_str(), upd->getType().getName().c_str(), @@ -407,11 +407,11 @@ PersistenceEngine::update(const Bucket& b, Timestamp t, const DocumentUpdate::SP b.toString().c_str(), static_cast(t.getValue()), docType.toString().c_str(), upd->getId().toString().c_str(), (upd->getCreateIfNonExistent() ? "true" : "false")); if (!upd->getId().hasDocType()) { - return UpdateResult(Result::PERMANENT_ERROR, + return UpdateResult(Result::ErrorType::PERMANENT_ERROR, make_string("Old id scheme not supported in elastic mode (%s)", upd->getId().toString().c_str())); } if (upd->getId().getDocType() != docType.getName()) { - return UpdateResult(Result::PERMANENT_ERROR, + return UpdateResult(Result::ErrorType::PERMANENT_ERROR, make_string("Update operation rejected due to bad id (%s, %s)", upd->getId().toString().c_str(), docType.getName().c_str())); } IPersistenceHandler::SP handler = getHandler(b.getBucketSpace(), docType); @@ -423,7 +423,7 @@ PersistenceEngine::update(const Bucket& b, Timestamp t, const DocumentUpdate::SP latch.await(); return latch.getUpdateResult(); } else { - return UpdateResult(Result::PERMANENT_ERROR, make_string("No handler for document type '%s'", docType.toString().c_str())); + return UpdateResult(Result::ErrorType::PERMANENT_ERROR, make_string("No handler for document type '%s'", docType.toString().c_str())); } } @@ -493,11 +493,11 @@ PersistenceEngine::iterate(IteratorId id, uint64_t maxByteSize, Context&) const std::lock_guard guard(_iterators_lock); auto it = _iterators.find(id); if (it == _iterators.end()) { - return IterateResult(Result::PERMANENT_ERROR, make_string("Unknown iterator with id %" PRIu64, id.getValue())); + return IterateResult(Result::ErrorType::PERMANENT_ERROR, make_string("Unknown iterator with id %" PRIu64, id.getValue())); } iteratorEntry = it->second; if (iteratorEntry->in_use) { - return IterateResult(Result::TRANSIENT_ERROR, make_string("Iterator with id %" PRIu64 " is already in use", id.getValue())); + return IterateResult(Result::ErrorType::TRANSIENT_ERROR, make_string("Iterator with id %" PRIu64 " is already in use", id.getValue())); } iteratorEntry->in_use = true; } @@ -509,7 +509,7 @@ PersistenceEngine::iterate(IteratorId id, uint64_t maxByteSize, Context&) const iteratorEntry->in_use = false; return result; } catch (const std::exception & e) { - IterateResult result(Result::PERMANENT_ERROR, make_string("Caught exception during visitor iterator.iterate() = '%s'", e.what())); + IterateResult result(Result::ErrorType::PERMANENT_ERROR, make_string("Caught exception during visitor iterator.iterate() = '%s'", e.what())); LOG(warning, "Caught exception during visitor iterator.iterate() = '%s'", e.what()); std::lock_guard guard(_iterators_lock); iteratorEntry->in_use = false; @@ -528,7 +528,7 @@ PersistenceEngine::destroyIterator(IteratorId id, Context&) return Result(); } if (it->second->in_use) { - return Result(Result::TRANSIENT_ERROR, make_string("Iterator with id %" PRIu64 " is currently in use", id.getValue())); + return Result(Result::ErrorType::TRANSIENT_ERROR, make_string("Iterator with id %" PRIu64 " is currently in use", id.getValue())); } delete it->second; _iterators.erase(it); diff --git a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp index af9038cba66..1d3b2165c80 100644 --- a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp @@ -26,7 +26,7 @@ BucketHandler::performSetCurrentState(BucketId bucketId, IGenericResultHandler *resultHandler) { if (!_nodeUp) { - Result result(Result::TRANSIENT_ERROR, + Result result(Result::ErrorType::TRANSIENT_ERROR, "Cannot set bucket active state when node is down"); resultHandler->handle(result); return; diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp index fd38b74f584..338fc738040 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp @@ -476,7 +476,7 @@ void feedOperationRejected(FeedToken & token, const vespalib::string &opType, co if (token) { auto message = make_string("%s operation rejected for document '%s' of type '%s': '%s'", opType.c_str(), docId.c_str(), docTypeName.toString().c_str(), rejectMessage.c_str()); - token->setResult(make_unique(Result::RESOURCE_EXHAUSTED, message), false); + token->setResult(make_unique(Result::ErrorType::RESOURCE_EXHAUSTED, message), false); token->fail(); } } @@ -527,7 +527,7 @@ FeedHandler::considerUpdateOperationForRejection(FeedToken &token, UpdateOperati if (token) { auto message = make_string("Update operation rejected for document '%s' of type '%s': 'Field not found'", update.getId().toString().c_str(), _docTypeName.toString().c_str()); - token->setResult(make_unique(Result::TRANSIENT_ERROR, message), false); + token->setResult(make_unique(Result::ErrorType::TRANSIENT_ERROR, message), false); token->fail(); } return true; @@ -536,7 +536,7 @@ FeedHandler::considerUpdateOperationForRejection(FeedToken &token, UpdateOperati update.getId().toString().c_str(), e.getDocumentTypeName().c_str(), _docTypeName.toString().c_str()); - token->setResult(make_unique(Result::TRANSIENT_ERROR, message), false); + token->setResult(make_unique(Result::ErrorType::TRANSIENT_ERROR, message), false); token->fail(); return true; } catch (document::WrongTensorTypeException &e) { @@ -544,7 +544,7 @@ FeedHandler::considerUpdateOperationForRejection(FeedToken &token, UpdateOperati update.getId().toString().c_str(), _docTypeName.toString().c_str(), e.getMessage().c_str()); - token->setResult(make_unique(Result::TRANSIENT_ERROR, message), false); + token->setResult(make_unique(Result::ErrorType::TRANSIENT_ERROR, message), false); token->fail(); return true; } diff --git a/storage/src/tests/persistence/common/persistenceproviderwrapper.cpp b/storage/src/tests/persistence/common/persistenceproviderwrapper.cpp index c804354b0ee..05e51993f49 100644 --- a/storage/src/tests/persistence/common/persistenceproviderwrapper.cpp +++ b/storage/src/tests/persistence/common/persistenceproviderwrapper.cpp @@ -14,7 +14,7 @@ #define CHECK_ERROR(className, failType) \ { \ - if (_result.getErrorCode() != spi::Result::NONE && (_failureMask & (failType))) { \ + if (_result.getErrorCode() != spi::Result::ErrorType::NONE && (_failureMask & (failType))) { \ return className(_result.getErrorCode(), _result.getErrorMessage()); \ } \ } @@ -41,7 +41,7 @@ includedVersionsToString(spi::IncludedVersions versions) PersistenceProviderWrapper::PersistenceProviderWrapper(spi::PersistenceProvider& spi) : _spi(spi), - _result(spi::Result(spi::Result::NONE, "")), + _result(spi::Result(spi::Result::ErrorType::NONE, "")), _log(), _failureMask(0) { } diff --git a/storage/src/tests/persistence/common/persistenceproviderwrapper.h b/storage/src/tests/persistence/common/persistenceproviderwrapper.h index 1f0dc93c44c..511ced02118 100644 --- a/storage/src/tests/persistence/common/persistenceproviderwrapper.h +++ b/storage/src/tests/persistence/common/persistenceproviderwrapper.h @@ -65,7 +65,7 @@ public: _result = result; } void clearResult() { - _result = spi::Result(spi::Result::NONE, ""); + _result = spi::Result(spi::Result::ErrorType::NONE, ""); } const spi::Result& getResult() const { return _result; } /** diff --git a/storage/src/tests/persistence/mergehandlertest.cpp b/storage/src/tests/persistence/mergehandlertest.cpp index 8dedf3f18df..0b2baab5652 100644 --- a/storage/src/tests/persistence/mergehandlertest.cpp +++ b/storage/src/tests/persistence/mergehandlertest.cpp @@ -631,7 +631,7 @@ TEST_F(MergeHandlerTest, spi_flush_guard) { MergeHandler handler(providerWrapper, getEnv()); providerWrapper.setResult( - spi::Result(spi::Result::PERMANENT_ERROR, "who you gonna call?")); + spi::Result(spi::Result::ErrorType::PERMANENT_ERROR, "who you gonna call?")); setUpChain(MIDDLE); // Fail applying unrevertable remove @@ -826,7 +826,7 @@ TEST_F(MergeHandlerTest, merge_bucket_spi_failures) { PersistenceProviderWrapper providerWrapper(getPersistenceProvider()); MergeHandler handler(providerWrapper, getEnv()); providerWrapper.setResult( - spi::Result(spi::Result::PERMANENT_ERROR, "who you gonna call?")); + spi::Result(spi::Result::ErrorType::PERMANENT_ERROR, "who you gonna call?")); setUpChain(MIDDLE); ExpectedExceptionSpec exceptions[] = { @@ -858,7 +858,7 @@ TEST_F(MergeHandlerTest, get_bucket_diff_spi_failures) { PersistenceProviderWrapper providerWrapper(getPersistenceProvider()); MergeHandler handler(providerWrapper, getEnv()); providerWrapper.setResult( - spi::Result(spi::Result::PERMANENT_ERROR, "who you gonna call?")); + spi::Result(spi::Result::ErrorType::PERMANENT_ERROR, "who you gonna call?")); setUpChain(MIDDLE); ExpectedExceptionSpec exceptions[] = { @@ -893,7 +893,7 @@ TEST_F(MergeHandlerTest, apply_bucket_diff_spi_failures) { PersistenceProviderWrapper providerWrapper(getPersistenceProvider()); MergeHandler handler(providerWrapper, getEnv()); providerWrapper.setResult( - spi::Result(spi::Result::PERMANENT_ERROR, "who you gonna call?")); + spi::Result(spi::Result::ErrorType::PERMANENT_ERROR, "who you gonna call?")); setUpChain(MIDDLE); ExpectedExceptionSpec exceptions[] = { @@ -960,7 +960,7 @@ TEST_F(MergeHandlerTest, get_bucket_diff_reply_spi_failures) { PersistenceProviderWrapper providerWrapper(getPersistenceProvider()); MergeHandler handler(providerWrapper, getEnv()); providerWrapper.setResult( - spi::Result(spi::Result::PERMANENT_ERROR, "who you gonna call?")); + spi::Result(spi::Result::ErrorType::PERMANENT_ERROR, "who you gonna call?")); HandleGetBucketDiffReplyInvoker invoker; setUpChain(FRONT); @@ -1051,7 +1051,7 @@ TEST_F(MergeHandlerTest, apply_bucket_diff_reply_spi_failures) { invoker.setChainPos(pos); MergeHandler handler(providerWrapper, getEnv()); providerWrapper.setResult( - spi::Result(spi::Result::PERMANENT_ERROR, "who you gonna call?")); + spi::Result(spi::Result::ErrorType::PERMANENT_ERROR, "who you gonna call?")); ExpectedExceptionSpec exceptions[] = { { PersistenceProviderWrapper::FAIL_CREATE_ITERATOR, "create iterator" }, diff --git a/storage/src/tests/persistence/provider_error_wrapper_test.cpp b/storage/src/tests/persistence/provider_error_wrapper_test.cpp index 36238abb238..2ba5218003b 100644 --- a/storage/src/tests/persistence/provider_error_wrapper_test.cpp +++ b/storage/src/tests/persistence/provider_error_wrapper_test.cpp @@ -64,7 +64,7 @@ TEST_F(ProviderErrorWrapperTest, fatal_error_invokes_listener) { Fixture f(getPersistenceProvider()); auto listener = std::make_shared(); f.errorWrapper.register_error_listener(listener); - f.providerWrapper.setResult(spi::Result(spi::Result::FATAL_ERROR, "eject! eject!")); + f.providerWrapper.setResult(spi::Result(spi::Result::ErrorType::FATAL_ERROR, "eject! eject!")); EXPECT_FALSE(listener->_seen_fatal_error); f.perform_spi_operation(); @@ -78,7 +78,7 @@ TEST_F(ProviderErrorWrapperTest, resource_exhaustion_error_invokes_listener) { Fixture f(getPersistenceProvider()); auto listener = std::make_shared(); f.errorWrapper.register_error_listener(listener); - f.providerWrapper.setResult(spi::Result(spi::Result::RESOURCE_EXHAUSTED, "out of juice")); + f.providerWrapper.setResult(spi::Result(spi::Result::ErrorType::RESOURCE_EXHAUSTED, "out of juice")); EXPECT_FALSE(listener->_seen_resource_exhaustion_error); f.perform_spi_operation(); @@ -103,8 +103,8 @@ TEST_F(ProviderErrorWrapperTest, listener_not_invoked_on_regular_errors) { auto listener = std::make_shared(); f.errorWrapper.register_error_listener(listener); - EXPECT_NO_FATAL_FAILURE(f.check_no_listener_invoked_for_error(*listener, spi::Result::TRANSIENT_ERROR)); - EXPECT_NO_FATAL_FAILURE(f.check_no_listener_invoked_for_error(*listener, spi::Result::PERMANENT_ERROR)); + EXPECT_NO_FATAL_FAILURE(f.check_no_listener_invoked_for_error(*listener, spi::Result::ErrorType::TRANSIENT_ERROR)); + EXPECT_NO_FATAL_FAILURE(f.check_no_listener_invoked_for_error(*listener, spi::Result::ErrorType::PERMANENT_ERROR)); } TEST_F(ProviderErrorWrapperTest, multiple_listeners_can_be_registered) { @@ -114,7 +114,7 @@ TEST_F(ProviderErrorWrapperTest, multiple_listeners_can_be_registered) { f.errorWrapper.register_error_listener(listener1); f.errorWrapper.register_error_listener(listener2); - f.providerWrapper.setResult(spi::Result(spi::Result::RESOURCE_EXHAUSTED, "out of juice")); + f.providerWrapper.setResult(spi::Result(spi::Result::ErrorType::RESOURCE_EXHAUSTED, "out of juice")); f.perform_spi_operation(); EXPECT_TRUE(listener1->_seen_resource_exhaustion_error); diff --git a/storage/src/vespa/storage/persistence/bucketprocessor.cpp b/storage/src/vespa/storage/persistence/bucketprocessor.cpp index c512cdd461a..d4a570ee062 100644 --- a/storage/src/vespa/storage/persistence/bucketprocessor.cpp +++ b/storage/src/vespa/storage/persistence/bucketprocessor.cpp @@ -52,7 +52,7 @@ BucketProcessor::iterateAll(spi::PersistenceProvider& provider, versions, context)); - if (createIterResult.getErrorCode() != spi::Result::NONE) { + if (createIterResult.getErrorCode() != spi::Result::ErrorType::NONE) { vespalib::asciistream ss; ss << "Failed to create iterator: " << createIterResult.getErrorMessage(); @@ -65,7 +65,7 @@ BucketProcessor::iterateAll(spi::PersistenceProvider& provider, while (true) { spi::IterateResult result( provider.iterate(iteratorId, UINT64_MAX, context)); - if (result.getErrorCode() != spi::Result::NONE) { + if (result.getErrorCode() != spi::Result::ErrorType::NONE) { vespalib::asciistream ss; ss << "Failed: " << result.getErrorMessage(); throw std::runtime_error(ss.str()); diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp index f5d7bc57354..37e1d818bb8 100644 --- a/storage/src/vespa/storage/persistence/mergehandler.cpp +++ b/storage/src/vespa/storage/persistence/mergehandler.cpp @@ -169,7 +169,7 @@ MergeHandler::populateMetaData( spi::ALL_VERSIONS, context)); - if (createIterResult.getErrorCode() != spi::Result::NONE) { + if (createIterResult.getErrorCode() != spi::Result::ErrorType::NONE) { std::ostringstream ss; ss << "Failed to create iterator for " << bucket @@ -183,7 +183,7 @@ MergeHandler::populateMetaData( while (true) { spi::IterateResult result( _spi.iterate(iteratorId, UINT64_MAX, context)); - if (result.getErrorCode() != spi::Result::NONE) { + if (result.getErrorCode() != spi::Result::ErrorType::NONE) { std::ostringstream ss; ss << "Failed to iterate for " << bucket @@ -226,7 +226,7 @@ MergeHandler::buildBucketInfoList( if (entry.exist()) { spi::BucketInfoResult infoResult(_spi.getBucketInfo(bucket)); - if (infoResult.getErrorCode() != spi::Result::NONE) { + if (infoResult.getErrorCode() != spi::Result::ErrorType::NONE) { std::ostringstream ss; ss << "Failed to get bucket info for " << bucket << ": " @@ -432,7 +432,7 @@ MergeHandler::fetchLocalData( spi::NEWEST_DOCUMENT_OR_REMOVE, context)); - if (createIterResult.getErrorCode() != spi::Result::NONE) { + if (createIterResult.getErrorCode() != spi::Result::ErrorType::NONE) { std::ostringstream ss; ss << "Failed to create iterator for " << bucket.toString() @@ -451,7 +451,7 @@ MergeHandler::fetchLocalData( while (true) { spi::IterateResult result( _spi.iterate(iteratorId, remainingSize, context)); - if (result.getErrorCode() != spi::Result::NONE) { + if (result.getErrorCode() != spi::Result::ErrorType::NONE) { std::ostringstream ss; ss << "Failed to iterate for " << bucket.toString() @@ -712,7 +712,7 @@ MergeHandler::applyDiffLocally( flushGuard.flush(); spi::BucketInfoResult infoResult(_spi.getBucketInfo(bucket)); - if (infoResult.getErrorCode() != spi::Result::NONE) { + if (infoResult.getErrorCode() != spi::Result::ErrorType::NONE) { LOG(warning, "Failed to get bucket info for %s: %s", bucket.toString().c_str(), infoResult.getErrorMessage().c_str()); diff --git a/storage/src/vespa/storage/persistence/persistenceutil.cpp b/storage/src/vespa/storage/persistence/persistenceutil.cpp index 4bee5df4d04..9cea0e6c5d7 100644 --- a/storage/src/vespa/storage/persistence/persistenceutil.cpp +++ b/storage/src/vespa/storage/persistence/persistenceutil.cpp @@ -182,16 +182,16 @@ uint32_t PersistenceUtil::convertErrorCode(const spi::Result& response) { switch (response.getErrorCode()) { - case spi::Result::NONE: + case spi::Result::ErrorType::NONE: return 0; - case spi::Result::TIMESTAMP_EXISTS: + case spi::Result::ErrorType::TIMESTAMP_EXISTS: return api::ReturnCode::TIMESTAMP_EXIST; - case spi::Result::TRANSIENT_ERROR: - case spi::Result::FATAL_ERROR: + case spi::Result::ErrorType::TRANSIENT_ERROR: + case spi::Result::ErrorType::FATAL_ERROR: return mbus::ErrorCode::APP_TRANSIENT_ERROR; - case spi::Result::RESOURCE_EXHAUSTED: + case spi::Result::ErrorType::RESOURCE_EXHAUSTED: return api::ReturnCode::NO_SPACE; - case spi::Result::PERMANENT_ERROR: + case spi::Result::ErrorType::PERMANENT_ERROR: default: return mbus::ErrorCode::APP_FATAL_ERROR; } diff --git a/storage/src/vespa/storage/persistence/processallhandler.cpp b/storage/src/vespa/storage/persistence/processallhandler.cpp index 51ef67dc7ac..7cb373279a6 100644 --- a/storage/src/vespa/storage/persistence/processallhandler.cpp +++ b/storage/src/vespa/storage/persistence/processallhandler.cpp @@ -39,7 +39,7 @@ public: *entry.getDocumentId(), _context); - if (removeResult.getErrorCode() != spi::Result::NONE) { + if (removeResult.getErrorCode() != spi::Result::ErrorType::NONE) { std::ostringstream ss; ss << "Failed to do remove for removelocation: " << removeResult.getErrorMessage(); diff --git a/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp b/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp index 056561e8e21..fe947bff4d5 100644 --- a/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp +++ b/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp @@ -9,9 +9,9 @@ template ResultType ProviderErrorWrapper::checkResult(ResultType&& result) const { - if (result.getErrorCode() == spi::Result::FATAL_ERROR) { + if (result.getErrorCode() == spi::Result::ErrorType::FATAL_ERROR) { trigger_shutdown_listeners(result.getErrorMessage()); - } else if (result.getErrorCode() == spi::Result::RESOURCE_EXHAUSTED) { + } else if (result.getErrorCode() == spi::Result::ErrorType::RESOURCE_EXHAUSTED) { trigger_resource_exhaustion_listeners(result.getErrorMessage()); } return std::forward(result); -- cgit v1.2.3