diff options
| author | Dan Engelbrecht <[email protected]> | 2022-08-31 09:57:43 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-31 00:57:43 -0700 |
| commit | 1ea0f4d70f9097fd6d8a541274815d3797bd8ad6 (patch) | |
| tree | 46ce5cba07471f0d7923850d4e736a4c0db58036 | |
| parent | update changelog with changes since 0.1.3 (#151) (diff) | |
| download | zen-1ea0f4d70f9097fd6d8a541274815d3797bd8ad6.tar.xz zen-1ea0f4d70f9097fd6d8a541274815d3797bd8ad6.zip | |
remove legacy derived data interface for Jupiter (#152)
* remove legacy derived data interface for Jupiter
| -rw-r--r-- | zenserver/config.cpp | 10 | ||||
| -rw-r--r-- | zenserver/config.h | 1 | ||||
| -rw-r--r-- | zenserver/upstream/jupiter.cpp | 80 | ||||
| -rw-r--r-- | zenserver/upstream/jupiter.h | 5 | ||||
| -rw-r--r-- | zenserver/upstream/upstreamcache.cpp | 26 | ||||
| -rw-r--r-- | zenserver/zenserver.cpp | 3 |
6 files changed, 7 insertions, 118 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index fe6335465..7728ae670 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -305,13 +305,6 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) options.add_option("cache", "", - "upstream-jupiter-use-legacy-ddc", - "Whether to store derived data using the legacy endpoint", - cxxopts::value<bool>(ServerOptions.UpstreamCacheConfig.JupiterConfig.UseLegacyDdc)->default_value("false"), - ""); - - options.add_option("cache", - "", "upstream-zen-url", "URL to remote Zen server. Use a comma separated list to choose the one with the best latency.", cxxopts::value<std::vector<std::string>>(ServerOptions.UpstreamCacheConfig.ZenConfig.Urls), @@ -696,9 +689,6 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio UpdateStringValueFromConfig(JupiterConfig.value(), std::string_view("ddcnamespace"), ServerOptions.UpstreamCacheConfig.JupiterConfig.DdcNamespace); - - ServerOptions.UpstreamCacheConfig.JupiterConfig.UseLegacyDdc = - JupiterConfig->get_or("uselegacyddc", ServerOptions.UpstreamCacheConfig.JupiterConfig.UseLegacyDdc); }; if (auto ZenConfig = UpstreamConfig->get<sol::optional<sol::table>>("zen")) diff --git a/zenserver/config.h b/zenserver/config.h index 2a9f9ace2..c90d92d14 100644 --- a/zenserver/config.h +++ b/zenserver/config.h @@ -22,7 +22,6 @@ struct ZenUpstreamJupiterConfig std::string AccessToken; std::string Namespace; std::string DdcNamespace; - bool UseLegacyDdc = false; }; struct ZenUpstreamHordeConfig diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index ddc6c49d2..65fa1da92 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -83,44 +83,6 @@ CloudCacheSession::Authenticate() } CloudCacheResult -CloudCacheSession::GetDerivedData(std::string_view Namespace, std::string_view BucketId, std::string_view Key) -{ - ZEN_TRACE_CPU("HordeClient::GetDerivedData"); - - ExtendableStringBuilder<256> Uri; - Uri << m_CacheClient->ServiceUrl() << "/api/v1/c/ddc/" << Namespace << "/" << BucketId << "/" << Key; - - cpr::Session& Session = GetSession(); - const CloudCacheAccessToken& AccessToken = GetAccessToken(); - - Session.SetOption(cpr::Url{Uri.c_str()}); - Session.SetOption(cpr::Header{{"Authorization", AccessToken.Value}, {"Accept", "application/octet-stream"}}); - - cpr::Response Response = Session.Get(); - ZEN_DEBUG("GET {}", Response); - - if (Response.error) - { - return {.ErrorCode = static_cast<int32_t>(Response.error.code), .Reason = Response.error.message}; - } - else if (!VerifyAccessToken(Response.status_code)) - { - return {.ErrorCode = 401, .Reason = std::string("Invalid access token")}; - } - - const bool Success = Response.status_code == 200; - const IoBuffer Buffer = Success ? IoBufferBuilder::MakeCloneFromMemory(Response.text.data(), Response.text.size()) : IoBuffer(); - - return {.Response = Buffer, .Bytes = Response.downloaded_bytes, .ElapsedSeconds = Response.elapsed, .Success = Success}; -} - -CloudCacheResult -CloudCacheSession::GetDerivedData(std::string_view Namespace, std::string_view BucketId, const IoHash& Key) -{ - return GetDerivedData(Namespace, BucketId, Key.ToHexString()); -} - -CloudCacheResult CloudCacheSession::GetRef(std::string_view Namespace, std::string_view BucketId, const IoHash& Key, ZenContentType RefType) { const std::string ContentType = RefType == ZenContentType::kCbObject ? "application/x-ue-cb" : "application/octet-stream"; @@ -251,48 +213,6 @@ CloudCacheSession::GetObject(std::string_view Namespace, const IoHash& Key) return {.Response = Buffer, .Bytes = Response.downloaded_bytes, .ElapsedSeconds = Response.elapsed, .Success = Success}; } -CloudCacheResult -CloudCacheSession::PutDerivedData(std::string_view Namespace, std::string_view BucketId, std::string_view Key, IoBuffer DerivedData) -{ - ZEN_TRACE_CPU("HordeClient::PutDerivedData"); - - IoHash Hash = IoHash::HashBuffer(DerivedData.Data(), DerivedData.Size()); - - ExtendableStringBuilder<256> Uri; - Uri << m_CacheClient->ServiceUrl() << "/api/v1/c/ddc/" << Namespace << "/" << BucketId << "/" << Key; - - cpr::Session& Session = GetSession(); - const CloudCacheAccessToken& AccessToken = GetAccessToken(); - - Session.SetOption(cpr::Url{Uri.c_str()}); - Session.SetOption(cpr::Header{{"Authorization", AccessToken.Value}, - {"X-Jupiter-IoHash", Hash.ToHexString()}, - {"Content-Type", "application/octet-stream"}}); - Session.SetBody(cpr::Body{(const char*)DerivedData.Data(), DerivedData.Size()}); - - cpr::Response Response = Session.Put(); - ZEN_DEBUG("PUT {}", Response); - - if (Response.error) - { - return {.ErrorCode = static_cast<int32_t>(Response.error.code), .Reason = Response.error.message}; - } - else if (!VerifyAccessToken(Response.status_code)) - { - return {.ErrorCode = 401, .Reason = std::string("Invalid access token")}; - } - - return {.Bytes = Response.uploaded_bytes, - .ElapsedSeconds = Response.elapsed, - .Success = (Response.status_code == 200 || Response.status_code == 201)}; -} - -CloudCacheResult -CloudCacheSession::PutDerivedData(std::string_view Namespace, std::string_view BucketId, const IoHash& Key, IoBuffer DerivedData) -{ - return PutDerivedData(Namespace, BucketId, Key.ToHexString(), DerivedData); -} - PutRefResult CloudCacheSession::PutRef(std::string_view Namespace, std::string_view BucketId, const IoHash& Key, IoBuffer Ref, ZenContentType RefType) { diff --git a/zenserver/upstream/jupiter.h b/zenserver/upstream/jupiter.h index 3d9e6ea7b..4e5e38d6f 100644 --- a/zenserver/upstream/jupiter.h +++ b/zenserver/upstream/jupiter.h @@ -95,15 +95,11 @@ public: ~CloudCacheSession(); CloudCacheResult Authenticate(); - CloudCacheResult GetDerivedData(std::string_view Namespace, std::string_view BucketId, std::string_view Key); - CloudCacheResult GetDerivedData(std::string_view Namespace, std::string_view BucketId, const IoHash& Key); CloudCacheResult GetRef(std::string_view Namespace, std::string_view BucketId, const IoHash& Key, ZenContentType RefType); CloudCacheResult GetBlob(std::string_view Namespace, const IoHash& Key); CloudCacheResult GetCompressedBlob(std::string_view Namespace, const IoHash& Key); CloudCacheResult GetObject(std::string_view Namespace, const IoHash& Key); - CloudCacheResult PutDerivedData(std::string_view Namespace, std::string_view BucketId, std::string_view Key, IoBuffer DerivedData); - CloudCacheResult PutDerivedData(std::string_view Namespace, std::string_view BucketId, const IoHash& Key, IoBuffer DerivedData); PutRefResult PutRef(std::string_view Namespace, std::string_view BucketId, const IoHash& Key, IoBuffer Ref, ZenContentType RefType); CloudCacheResult PutBlob(std::string_view Namespace, const IoHash& Key, IoBuffer Blob); CloudCacheResult PutCompressedBlob(std::string_view Namespace, const IoHash& Key, IoBuffer Blob); @@ -178,7 +174,6 @@ struct CloudCacheClientOptions std::string_view ComputeCluster; std::chrono::milliseconds ConnectTimeout{5000}; std::chrono::milliseconds Timeout{}; - bool UseLegacyDdc = false; }; /** diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index 40d627862..a897c21fd 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -88,7 +88,6 @@ namespace detail { JupiterUpstreamEndpoint(const CloudCacheClientOptions& Options, const UpstreamAuthConfig& AuthConfig, AuthMgr& Mgr) : m_AuthMgr(Mgr) , m_Log(zen::logging::Get("upstream")) - , m_UseLegacyDdc(Options.UseLegacyDdc) { ZEN_ASSERT(!Options.Name.empty()); m_Info.Name = Options.Name; @@ -192,12 +191,7 @@ namespace detail { std::string_view BlobStoreNamespace = GetActualBlobStoreNamespace(Session, Namespace); - if (m_UseLegacyDdc && Type == ZenContentType::kBinary) - { - std::string_view DdcNamespace = GetActualDdcNamespace(Session, Namespace); - Result = Session.GetDerivedData(DdcNamespace, CacheKey.Bucket, CacheKey.Hash); - } - else if (Type == ZenContentType::kCompressedBinary) + if (Type == ZenContentType::kCompressedBinary) { Result = Session.GetRef(BlobStoreNamespace, CacheKey.Bucket, CacheKey.Hash, ZenContentType::kCbObject); @@ -449,18 +443,11 @@ namespace detail { for (uint32_t Attempt = 0; Attempt < MaxAttempts && !Result.Success; Attempt++) { std::string_view BlobStoreNamespace = GetActualBlobStoreNamespace(Session, CacheRecord.Namespace); - if (m_UseLegacyDdc) - { - Result = Session.PutDerivedData(BlobStoreNamespace, CacheRecord.Key.Bucket, CacheRecord.Key.Hash, RecordValue); - } - else - { - Result = Session.PutRef(BlobStoreNamespace, - CacheRecord.Key.Bucket, - CacheRecord.Key.Hash, - RecordValue, - ZenContentType::kBinary); - } + Result = Session.PutRef(BlobStoreNamespace, + CacheRecord.Key.Bucket, + CacheRecord.Key.Hash, + RecordValue, + ZenContentType::kBinary); } m_Status.SetFromErrorCode(Result.ErrorCode, Result.Reason); @@ -671,7 +658,6 @@ namespace detail { UpstreamEndpointInfo m_Info; UpstreamStatus m_Status; UpstreamEndpointStats m_Stats; - bool m_UseLegacyDdc; RefPtr<CloudCacheClient> m_Client; }; diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index e60c73635..2effa4e68 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -804,8 +804,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) .DdcNamespace = UpstreamConfig.JupiterConfig.DdcNamespace, .BlobStoreNamespace = UpstreamConfig.JupiterConfig.Namespace, .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), - .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), - .UseLegacyDdc = false}; + .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds)}; auto AuthConfig = zen::UpstreamAuthConfig{.OAuthUrl = UpstreamConfig.JupiterConfig.OAuthUrl, .OAuthClientId = UpstreamConfig.JupiterConfig.OAuthClientId, |