From 16b048927c7133b2a9f40ec26dd9c5433c91be2f Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Sat, 23 Mar 2024 10:56:58 +0100 Subject: use batch request for checking existing blocks as Jupiter is now fixed (#20) --- .../projectstore/jupiterremoteprojectstore.cpp | 51 +++++----------------- 1 file changed, 10 insertions(+), 41 deletions(-) (limited to 'src/zenserver') diff --git a/src/zenserver/projectstore/jupiterremoteprojectstore.cpp b/src/zenserver/projectstore/jupiterremoteprojectstore.cpp index b288a667c..1508dbc3f 100644 --- a/src/zenserver/projectstore/jupiterremoteprojectstore.cpp +++ b/src/zenserver/projectstore/jupiterremoteprojectstore.cpp @@ -134,49 +134,18 @@ public: virtual HasAttachmentsResult HasAttachments(const std::span RawHashes) override { - CloudCacheSession Session(m_CloudClient.Get()); - const bool UseBatchRequest = - false; // The batch request API in Jupiter is currently broken so we have to resort to individual cheks - - if (UseBatchRequest) + CloudCacheSession Session(m_CloudClient.Get()); + CloudCacheExistsResult ExistsResult = Session.BlobExists(m_Namespace, std::set(RawHashes.begin(), RawHashes.end())); + HasAttachmentsResult Result{ConvertResult(ExistsResult), + std::unordered_set(ExistsResult.Needs.begin(), ExistsResult.Needs.end())}; + if (ExistsResult.ErrorCode) { - CloudCacheExistsResult ExistsResult = Session.BlobExists(m_Namespace, std::set(RawHashes.begin(), RawHashes.end())); - HasAttachmentsResult Result{ConvertResult(ExistsResult), - std::unordered_set(ExistsResult.Needs.begin(), ExistsResult.Needs.end())}; - if (ExistsResult.ErrorCode) - { - Result.Reason = fmt::format("Failed checking attachment existance in {}/{}. Reason: '{}'", - m_CloudClient->ServiceUrl(), - m_Namespace, - Result.Reason); - } - return Result; - } - else - { - Stopwatch Timer; - HasAttachmentsResult Result; - for (const IoHash& RawHash : RawHashes) - { - CloudCacheResult ExistsResult = Session.CompressedBlobExists(m_Namespace, RawHash); - if (ExistsResult.ErrorCode) - { - Result = {ConvertResult(ExistsResult)}; - Result.Reason = fmt::format("Failed checking oplog attachment existance {}/{}/{}. Reason: '{}'", - m_CloudClient->ServiceUrl(), - m_Namespace, - RawHash, - Result.Reason); - return Result; - } - if (!ExistsResult.Success) - { - Result.Needs.insert(RawHash); - } - } - Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0; - return Result; + Result.Reason = fmt::format("Failed checking attachment existance in {}/{}. Reason: '{}'", + m_CloudClient->ServiceUrl(), + m_Namespace, + Result.Reason); } + return Result; } virtual LoadAttachmentResult LoadAttachment(const IoHash& RawHash) override -- cgit v1.2.3