diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-11-17 16:35:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 16:35:32 +0100 |
commit | 65fe0e9b45b10e9b3663a729969473d84f3b5edd (patch) | |
tree | 3d61004927e0a8d5670a759ccb3a41e654b288c4 | |
parent | 49fa6c448b8bf830cf89316cd6055f5f3f1cddfb (diff) | |
parent | baeeb8e93c830b9644218db154606e400a160deb (diff) |
Merge pull request #20063 from vespa-engine/balder/misc-cleanup
Some cleanup.
-rw-r--r-- | searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp | 7 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp | 45 |
2 files changed, 21 insertions, 31 deletions
diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index c252c89a2f8..ce0b09a48b8 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -18,7 +18,6 @@ #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/vespalib/testkit/testapp.h> -#include <algorithm> #include <set> using document::BucketId; @@ -287,12 +286,6 @@ struct MyHandler : public IPersistenceHandler, IBucketFreezer { ASSERT_TRUE(it != frozen.end()); frozen.erase(it); } - bool isFrozen(const Bucket &bucket) { - return frozen.find(bucket.getBucketId().getId()) != frozen.end(); - } - bool wasFrozen(const Bucket &bucket) { - return was_frozen.find(bucket.getBucketId().getId()) != was_frozen.end(); - } }; diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp index 04d91b9c028..9d9e1e0a344 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp @@ -29,7 +29,7 @@ using storage::spi::Result; using storage::spi::OperationComplete; using vespalib::IllegalStateException; using vespalib::Sequence; -using vespalib::make_string; +using vespalib::make_string_short::fmt; using std::make_unique; using namespace std::chrono_literals; @@ -347,8 +347,7 @@ PersistenceEngine::putAsync(const Bucket &bucket, Timestamp ts, storage::spi::Do IResourceWriteFilter::State state = _writeFilter.getAcceptState(); if (!state.acceptWriteOperation()) { return onComplete->onComplete(std::make_unique<Result>(Result::ErrorType::RESOURCE_EXHAUSTED, - make_string("Put operation rejected for document '%s': '%s'", - doc->getId().toString().c_str(), state.message().c_str()))); + fmt("Put operation rejected for document '%s': '%s'", doc->getId().toString().c_str(), state.message().c_str()))); } } ReadGuard rguard(_rwMutex); @@ -357,12 +356,12 @@ PersistenceEngine::putAsync(const Bucket &bucket, Timestamp ts, storage::spi::Do docType.toString().c_str(), doc->getId().toString().c_str()); if (!doc->getId().hasDocType()) { return onComplete->onComplete(std::make_unique<Result>(Result::ErrorType::PERMANENT_ERROR, - make_string("Old id scheme not supported in elastic mode (%s)", doc->getId().toString().c_str()))); + fmt("Old id scheme not supported in elastic mode (%s)", doc->getId().toString().c_str()))); } IPersistenceHandler * handler = getHandler(rguard, bucket.getBucketSpace(), docType); if (!handler) { return onComplete->onComplete(std::make_unique<Result>(Result::ErrorType::PERMANENT_ERROR, - make_string("No handler for document type '%s'", docType.toString().c_str()))); + fmt("No handler for document type '%s'", docType.toString().c_str()))); } auto transportContext = std::make_shared<AsyncTransportContext>(1, std::move(onComplete)); handler->handlePut(feedtoken::make(std::move(transportContext)), bucket, ts, std::move(doc)); @@ -376,13 +375,13 @@ PersistenceEngine::removeAsync(const Bucket& b, Timestamp t, const DocumentId& d static_cast<uint64_t>(t.getValue()), did.toString().c_str()); if (!did.hasDocType()) { return onComplete->onComplete(std::make_unique<RemoveResult>(Result::ErrorType::PERMANENT_ERROR, - make_string("Old id scheme not supported in elastic mode (%s)", did.toString().c_str()))); + fmt("Old id scheme not supported in elastic mode (%s)", did.toString().c_str()))); } DocTypeName docType(did.getDocType()); IPersistenceHandler * handler = getHandler(rguard, b.getBucketSpace(), docType); if (!handler) { return onComplete->onComplete(std::make_unique<RemoveResult>(Result::ErrorType::PERMANENT_ERROR, - make_string("No handler for document type '%s'", docType.toString().c_str()))); + fmt("No handler for document type '%s'", docType.toString().c_str()))); } auto transportContext = std::make_shared<AsyncTransportContext>(1, std::move(onComplete)); handler->handleRemove(feedtoken::make(std::move(transportContext)), b, t, did); @@ -396,27 +395,24 @@ PersistenceEngine::updateAsync(const Bucket& b, Timestamp t, DocumentUpdate::SP IResourceWriteFilter::State state = _writeFilter.getAcceptState(); if (!state.acceptWriteOperation() && document::FeedRejectHelper::mustReject(*upd)) { return onComplete->onComplete(std::make_unique<UpdateResult>(Result::ErrorType::RESOURCE_EXHAUSTED, - make_string("Update operation rejected for document '%s': '%s'", - upd->getId().toString().c_str(), state.message().c_str()))); + fmt("Update operation rejected for document '%s': '%s'", upd->getId().toString().c_str(), state.message().c_str()))); } } try { upd->eagerDeserialize(); } catch (document::FieldNotFoundException & e) { return onComplete->onComplete(std::make_unique<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()))); + fmt("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 onComplete->onComplete(std::make_unique<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()))); + fmt("Update operation rejected for document '%s' of type '%s'.", + upd->getId().toString().c_str(), e.getDocumentTypeName().c_str()))); } catch (document::WrongTensorTypeException &e) { return onComplete->onComplete(std::make_unique<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(), - e.getMessage().c_str()))); + fmt("Update operation rejected for document '%s' of type '%s': 'Wrong tensor type: %s'", + upd->getId().toString().c_str(), upd->getType().getName().c_str(), e.getMessage().c_str()))); } ReadGuard rguard(_rwMutex); DocTypeName docType(upd->getType()); @@ -425,16 +421,17 @@ PersistenceEngine::updateAsync(const Bucket& b, Timestamp t, DocumentUpdate::SP upd->getId().toString().c_str(), (upd->getCreateIfNonExistent() ? "true" : "false")); if (!upd->getId().hasDocType()) { return onComplete->onComplete(std::make_unique<UpdateResult>(Result::ErrorType::PERMANENT_ERROR, - make_string("Old id scheme not supported in elastic mode (%s)", upd->getId().toString().c_str()))); + fmt("Old id scheme not supported in elastic mode (%s)", upd->getId().toString().c_str()))); } if (upd->getId().getDocType() != docType.getName()) { return onComplete->onComplete(std::make_unique<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()))); + fmt("Update operation rejected due to bad id (%s, %s)", upd->getId().toString().c_str(), docType.getName().c_str()))); } IPersistenceHandler * handler = getHandler(rguard, b.getBucketSpace(), docType); if (handler == nullptr) { - return onComplete->onComplete(std::make_unique<UpdateResult>(Result::ErrorType::PERMANENT_ERROR, make_string("No handler for document type '%s'", docType.toString().c_str()))); + return onComplete->onComplete(std::make_unique<UpdateResult>(Result::ErrorType::PERMANENT_ERROR, + fmt("No handler for document type '%s'", docType.toString().c_str()))); } auto transportContext = std::make_shared<AsyncTransportContext>(1, std::move(onComplete)); handler->handleUpdate(feedtoken::make(std::move(transportContext)), b, t, std::move(upd)); @@ -505,11 +502,11 @@ PersistenceEngine::iterate(IteratorId id, uint64_t maxByteSize, Context&) const std::lock_guard<std::mutex> guard(_iterators_lock); auto it = _iterators.find(id); if (it == _iterators.end()) { - return IterateResult(Result::ErrorType::PERMANENT_ERROR, make_string("Unknown iterator with id %" PRIu64, id.getValue())); + return IterateResult(Result::ErrorType::PERMANENT_ERROR, fmt("Unknown iterator with id %" PRIu64, id.getValue())); } iteratorEntry = it->second; if (iteratorEntry->in_use) { - return IterateResult(Result::ErrorType::TRANSIENT_ERROR, make_string("Iterator with id %" PRIu64 " is already in use", id.getValue())); + return IterateResult(Result::ErrorType::TRANSIENT_ERROR, fmt("Iterator with id %" PRIu64 " is already in use", id.getValue())); } iteratorEntry->in_use = true; } @@ -521,7 +518,7 @@ PersistenceEngine::iterate(IteratorId id, uint64_t maxByteSize, Context&) const iteratorEntry->in_use = false; return result; } catch (const std::exception & e) { - IterateResult result(Result::ErrorType::PERMANENT_ERROR, make_string("Caught exception during visitor iterator.iterate() = '%s'", e.what())); + IterateResult result(Result::ErrorType::PERMANENT_ERROR, fmt("Caught exception during visitor iterator.iterate() = '%s'", e.what())); LOG(warning, "Caught exception during visitor iterator.iterate() = '%s'", e.what()); std::lock_guard<std::mutex> guard(_iterators_lock); iteratorEntry->in_use = false; @@ -540,7 +537,7 @@ PersistenceEngine::destroyIterator(IteratorId id, Context&) return Result(); } if (it->second->in_use) { - return Result(Result::ErrorType::TRANSIENT_ERROR, make_string("Iterator with id %" PRIu64 " is currently in use", id.getValue())); + return Result(Result::ErrorType::TRANSIENT_ERROR, fmt("Iterator with id %" PRIu64 " is currently in use", id.getValue())); } delete it->second; _iterators.erase(it); |