diff options
Diffstat (limited to 'zenserver')
| -rw-r--r-- | zenserver/config.cpp | 65 | ||||
| -rw-r--r-- | zenserver/config.h | 8 | ||||
| -rw-r--r-- | zenserver/upstream/upstreamapply.cpp | 17 | ||||
| -rw-r--r-- | zenserver/upstream/upstreamapply.h | 5 | ||||
| -rw-r--r-- | zenserver/zenserver.cpp | 19 |
5 files changed, 96 insertions, 18 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index ac0f863cc..be91ae4f8 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -389,6 +389,49 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) options.add_option("compute", "", + "upstream-horde-storage-url", + "URL to a Horde Storage instance.", + cxxopts::value<std::string>(ServerOptions.UpstreamCacheConfig.HordeConfig.StorageUrl)->default_value(""), + ""); + + options.add_option("compute", + "", + "upstream-horde-storage-oauth-url", + "URL to the OAuth provier", + cxxopts::value<std::string>(ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOAuthUrl)->default_value(""), + ""); + + options.add_option("compute", + "", + "upstream-horde-storage-oauth-clientid", + "The OAuth client ID", + cxxopts::value<std::string>(ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOAuthClientId)->default_value(""), + ""); + + options.add_option( + "compute", + "", + "upstream-horde-storage-oauth-clientsecret", + "The OAuth client secret", + cxxopts::value<std::string>(ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOAuthClientSecret)->default_value(""), + ""); + + options.add_option("compute", + "", + "upstream-horde-storage-openid-provider", + "Name of a registered Open ID provider", + cxxopts::value<std::string>(ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOpenIdProvider)->default_value(""), + ""); + + options.add_option("compute", + "", + "upstream-horde-storage-token", + "A static authentication token", + cxxopts::value<std::string>(ServerOptions.UpstreamCacheConfig.HordeConfig.StorageAccessToken)->default_value(""), + ""); + + options.add_option("compute", + "", "upstream-horde-cluster", "The Horde compute cluster id", cxxopts::value<std::string>(ServerOptions.UpstreamCacheConfig.HordeConfig.Cluster)->default_value(""), @@ -700,6 +743,28 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio std::string_view("namespace"), ServerOptions.UpstreamCacheConfig.HordeConfig.Namespace); }; + + if (auto StorageConfig = UpstreamConfig->get<sol::optional<sol::table>>("storage")) + { + UpdateStringValueFromConfig(StorageConfig.value(), + std::string_view("url"), + ServerOptions.UpstreamCacheConfig.HordeConfig.StorageUrl); + UpdateStringValueFromConfig(StorageConfig.value(), + std::string_view("oauthprovider"), + ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOAuthUrl); + UpdateStringValueFromConfig(StorageConfig.value(), + std::string_view("oauthclientid"), + ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOAuthClientId); + UpdateStringValueFromConfig(StorageConfig.value(), + std::string_view("oauthclientsecret"), + ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOAuthClientSecret); + UpdateStringValueFromConfig(StorageConfig.value(), + std::string_view("openidprovider"), + ServerOptions.UpstreamCacheConfig.HordeConfig.StorageOpenIdProvider); + UpdateStringValueFromConfig(StorageConfig.value(), + std::string_view("token"), + ServerOptions.UpstreamCacheConfig.HordeConfig.StorageAccessToken); + }; } } diff --git a/zenserver/config.h b/zenserver/config.h index 9f1b3645c..49f039d8d 100644 --- a/zenserver/config.h +++ b/zenserver/config.h @@ -38,6 +38,14 @@ struct ZenUpstreamHordeConfig std::string OAuthClientSecret; std::string OpenIdProvider; std::string AccessToken; + + std::string StorageUrl; + std::string StorageOAuthUrl; + std::string StorageOAuthClientId; + std::string StorageOAuthClientSecret; + std::string StorageOpenIdProvider; + std::string StorageAccessToken; + std::string Cluster; std::string Namespace; }; diff --git a/zenserver/upstream/upstreamapply.cpp b/zenserver/upstream/upstreamapply.cpp index 45515067d..9758e7565 100644 --- a/zenserver/upstream/upstreamapply.cpp +++ b/zenserver/upstream/upstreamapply.cpp @@ -83,7 +83,8 @@ public: , m_CasStore(CasStore) , m_CidStore(CidStore) , m_Stats(Options.StatsEnabled) - , m_AsyncWorkPool(Options.ThreadCount) + , m_UpstreamAsyncWorkPool(Options.UpstreamThreadCount) + , m_DownstreamAsyncWorkPool(Options.DownstreamThreadCount) { } @@ -147,7 +148,8 @@ public: } ApplyRecord.Timepoints["zen-queue-added"] = DateTime::NowTicks(); - m_AsyncWorkPool.ScheduleWork([this, ApplyRecord = std::move(ApplyRecord)]() { ProcessApplyRecord(std::move(ApplyRecord)); }); + m_UpstreamAsyncWorkPool.ScheduleWork( + [this, ApplyRecord = std::move(ApplyRecord)]() { ProcessApplyRecord(std::move(ApplyRecord)); }); return {.ApplyId = ActionId, .Success = true}; } @@ -171,8 +173,10 @@ public: virtual void GetStatus(CbObjectWriter& Status) override { - Status << "worker_threads" << m_Options.ThreadCount; - Status << "queue_count" << m_AsyncWorkPool.PendingWork(); + Status << "upstream_worker_threads" << m_Options.UpstreamThreadCount; + Status << "upstream_queue_count" << m_UpstreamAsyncWorkPool.PendingWork(); + Status << "downstream_worker_threads" << m_Options.DownstreamThreadCount; + Status << "downstream_queue_count" << m_DownstreamAsyncWorkPool.PendingWork(); Status.BeginArray("endpoints"); for (const auto& Ep : m_Endpoints) @@ -280,7 +284,7 @@ private: { if (Endpoint->IsHealthy()) { - GetUpstreamApplyUpdatesResult Result = Endpoint->GetUpdates(m_AsyncWorkPool); + GetUpstreamApplyUpdatesResult Result = Endpoint->GetUpdates(m_DownstreamAsyncWorkPool); m_Stats.Add(*Endpoint, Result); if (!Result.Success) @@ -416,7 +420,8 @@ private: std::mutex m_ApplyTasksMutex; std::vector<std::unique_ptr<UpstreamApplyEndpoint>> m_Endpoints; Event m_ShutdownEvent; - WorkerThreadPool m_AsyncWorkPool; + WorkerThreadPool m_UpstreamAsyncWorkPool; + WorkerThreadPool m_DownstreamAsyncWorkPool; std::thread m_UpstreamUpdatesThread; std::thread m_EndpointMonitorThread; RunState m_RunState; diff --git a/zenserver/upstream/upstreamapply.h b/zenserver/upstream/upstreamapply.h index 43586747f..c6e38142c 100644 --- a/zenserver/upstream/upstreamapply.h +++ b/zenserver/upstream/upstreamapply.h @@ -52,8 +52,9 @@ struct UpstreamApplyOptions { std::chrono::seconds HealthCheckInterval{5}; std::chrono::seconds UpdatesInterval{5}; - uint32_t ThreadCount = 4; - bool StatsEnabled = false; + uint32_t UpstreamThreadCount = 4; + uint32_t DownstreamThreadCount = 4; + bool StatsEnabled = false; }; struct UpstreamApplyError diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 3ac5b9992..abaec888a 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -850,7 +850,7 @@ ZenServer::InitializeCompute(const ZenServerOptions& ServerOptions) const ZenUpstreamCacheConfig& UpstreamConfig = ServerOptions.UpstreamCacheConfig; // Horde compute upstream - if (UpstreamConfig.HordeConfig.Url.empty() == false && UpstreamConfig.JupiterConfig.Url.empty() == false) + if (UpstreamConfig.HordeConfig.Url.empty() == false && UpstreamConfig.HordeConfig.StorageUrl.empty() == false) { ZEN_INFO("instantiating compute service"); @@ -861,8 +861,7 @@ ZenServer::InitializeCompute(const ZenServerOptions& ServerOptions) .ServiceUrl = UpstreamConfig.HordeConfig.Url, .ComputeCluster = UpstreamConfig.HordeConfig.Cluster, .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), - .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), - .UseLegacyDdc = false}; + .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds)}; auto ComputeAuthConfig = zen::UpstreamAuthConfig{.OAuthUrl = UpstreamConfig.HordeConfig.OAuthUrl, .OAuthClientId = UpstreamConfig.HordeConfig.OAuthClientId, @@ -872,16 +871,16 @@ ZenServer::InitializeCompute(const ZenServerOptions& ServerOptions) auto StorageOptions = zen::CloudCacheClientOptions{.Name = EndpointName, - .ServiceUrl = UpstreamConfig.JupiterConfig.Url, + .ServiceUrl = UpstreamConfig.HordeConfig.StorageUrl, .BlobStoreNamespace = UpstreamConfig.HordeConfig.Namespace, .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds)}; - auto StorageAuthConfig = zen::UpstreamAuthConfig{.OAuthUrl = UpstreamConfig.JupiterConfig.OAuthUrl, - .OAuthClientId = UpstreamConfig.JupiterConfig.OAuthClientId, - .OAuthClientSecret = UpstreamConfig.JupiterConfig.OAuthClientSecret, - .OpenIdProvider = UpstreamConfig.JupiterConfig.OpenIdProvider, - .AccessToken = UpstreamConfig.JupiterConfig.AccessToken}; + auto StorageAuthConfig = zen::UpstreamAuthConfig{.OAuthUrl = UpstreamConfig.HordeConfig.StorageOAuthUrl, + .OAuthClientId = UpstreamConfig.HordeConfig.StorageOAuthClientId, + .OAuthClientSecret = UpstreamConfig.HordeConfig.StorageOAuthClientSecret, + .OpenIdProvider = UpstreamConfig.HordeConfig.StorageOpenIdProvider, + .AccessToken = UpstreamConfig.HordeConfig.StorageAccessToken}; m_HttpFunctionService = std::make_unique<zen::HttpFunctionService>(*m_CasStore, *m_CidStore, @@ -893,7 +892,7 @@ ZenServer::InitializeCompute(const ZenServerOptions& ServerOptions) } else { - ZEN_INFO("NOT instantiating compute service (missing Horde or Jupiter config)"); + ZEN_INFO("NOT instantiating compute service (missing Horde or Storage config)"); } } #endif // ZEN_WITH_COMPUTE_SERVICES |