From d38a000ffd19d404d9f93a0f56a6c8be04ef258d Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 18 May 2021 22:49:45 +0200 Subject: Partial implementation of Jupiter chunk filtering, pending more information about response format Also implemented compact binary PUT --- zenserver/upstream/jupiter.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'zenserver/upstream/jupiter.cpp') diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index 6b54f3d01..523ee61f4 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -3,6 +3,7 @@ #include "jupiter.h" #include +#include #include #include #include @@ -108,6 +109,45 @@ CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, IoBuffer } } +void +CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, CbObjectView Data) +{ + ExtendableStringBuilder<256> Uri; + Uri << m_CacheClient->ServiceUrl(); + Uri << "/api/v1/c/ddc/" << m_CacheClient->Namespace() << "/" << BucketId << "/" TESTING_PREFIX << Key; + + auto& Session = m_SessionState->Session; + + IoHash Hash = Data.GetHash(); + MemoryView DataView = Data.GetView(); + + std::string Auth; + m_CacheClient->AcquireAccessToken(Auth); + Session.SetOption(cpr::Url{Uri.c_str()}); + Session.SetOption( + cpr::Header{{"Authorization", Auth}, {"X-Jupiter-IoHash", Hash.ToHexString()}, {"Content-Type", "application/x-ue-cb"}}); + Session.SetOption(cpr::Body{(const char*)DataView.GetData(), DataView.GetSize()}); + + cpr::Response Response = Session.Put(); + + if (Response.error) + { + spdlog::warn("PUT failed: '{}'", Response.error.message); + } +} + +std::vector +CloudCacheSession::Filter(std::string_view BucketId, const std::vector& ChunkHashes) +{ + ExtendableStringBuilder<256> Uri; + Uri << m_CacheClient->ServiceUrl(); + Uri << "/api/v1/s/" << m_CacheClient->Namespace(); + + ZEN_UNUSED(BucketId, ChunkHashes); + + return {}; +} + ////////////////////////////////////////////////////////////////////////// std::string -- cgit v1.2.3 From a8f2f071c8240d761b9d9d4fa17f6e48986388aa Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 20 May 2021 15:12:26 +0200 Subject: Fixed mis-merge --- zenserver/upstream/jupiter.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'zenserver/upstream/jupiter.cpp') diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index 1078e5240..363ebcd61 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -159,17 +159,6 @@ CloudCacheSession::Get(std::string_view BucketId, const IoHash& Key) return Get(BucketId, KeyString); } -void -CloudCacheSession::Put(std::string_view BucketId, const IoHash& Key, IoBuffer Data, HttpContentType ContentType) -{ - ZEN_UNUSED(ContentType); - - StringBuilder<64> KeyString; - Key.ToHexString(KeyString); - - return Put(BucketId, KeyString, Data); -} - ////////////////////////////////////////////////////////////////////////// std::string -- cgit v1.2.3