aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-12-05 16:03:27 +0100
committerPer Larsson <[email protected]>2021-12-05 16:03:27 +0100
commit9eb0876ab1f35317eb04dd8a74f0394e853f4f56 (patch)
tree1dfd11024baea97b01c69b40153086511987f361 /zenserver/zenserver.cpp
parentMerge branch 'gc' of https://github.com/EpicGames/zen into gc (diff)
downloadzen-9eb0876ab1f35317eb04dd8a74f0394e853f4f56.tar.xz
zen-9eb0876ab1f35317eb04dd8a74f0394e853f4f56.zip
Added simple GC interval scheduling.
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index 47c79526b..5b5cfb3b7 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -198,15 +198,15 @@ public:
m_AdminService.RegisterGcHandler({.Trigger =
[this]() {
CbObjectWriter Writer;
- const bool Started = m_Gc.Trigger();
+ const bool Started = m_GcScheduler.ScheduleNow();
Writer << "Status"sv << (Started ? "Started"sv : "Running"sv);
return Writer.Save();
},
.Status =
[this]() {
- CbObjectWriter Writer;
- const GcStatus Status = m_Gc.Status();
- Writer << "Status"sv << (GcStatus::kIdle == Status ? "Idle"sv : "Running"sv);
+ CbObjectWriter Writer;
+ const GcSchedulerStatus Status = m_GcScheduler.Status();
+ Writer << "Status"sv << (GcSchedulerStatus::kIdle == Status ? "Idle"sv : "Running"sv);
return Writer.Save();
}});
@@ -229,11 +229,11 @@ public:
m_CasStore->Initialize(Config);
m_CidStore = std::make_unique<zen::CidStore>(*m_CasStore, m_DataRoot / "cid");
- m_Gc.Cas().SetCidStore(m_CidStore.get());
+ m_CasGc.SetCidStore(m_CidStore.get());
ZEN_INFO("instantiating project service");
- m_ProjectStore = new zen::ProjectStore(*m_CidStore, m_DataRoot / "projects", m_Gc.Cas());
+ m_ProjectStore = new zen::ProjectStore(*m_CidStore, m_DataRoot / "projects", m_CasGc);
m_HttpProjectService.reset(new zen::HttpProjectService{*m_CidStore, m_ProjectStore});
#if ZEN_USE_NAMED_PIPES
@@ -306,6 +306,14 @@ public:
{
m_Http->RegisterService(*m_FrontendService);
}
+
+ ZEN_INFO("initializing GC, enabled '{}', interval {}s", ServerOptions.GcConfig.Enabled, ServerOptions.GcConfig.IntervalSeconds);
+ zen::GcSchedulerConfig GcConfig{
+ .RootDirectory = m_DataRoot / "gc",
+ .Interval = std::chrono::seconds(ServerOptions.GcConfig.IntervalSeconds),
+ .Enabled = ServerOptions.GcConfig.Enabled,
+ };
+ m_GcScheduler.Initialize(GcConfig);
}
void InitializeState(const ZenServerOptions& ServerOptions);
@@ -518,8 +526,9 @@ private:
zen::Ref<zen::HttpServer> m_Http;
zen::HttpStatusService m_StatusService;
zen::HttpStatsService m_StatsService;
- zen::Gc m_Gc;
- std::unique_ptr<zen::CasStore> m_CasStore{zen::CreateCasStore(m_Gc.Cas())};
+ zen::CasGc m_CasGc;
+ zen::GcScheduler m_GcScheduler{m_CasGc};
+ std::unique_ptr<zen::CasStore> m_CasStore{zen::CreateCasStore(m_CasGc)};
std::unique_ptr<zen::CidStore> m_CidStore;
std::unique_ptr<zen::ZenCacheStore> m_CacheStore;
zen::CasScrubber m_Scrubber{*m_CasStore};
@@ -661,7 +670,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
auto ValueOrDefault = [](std::string_view Value, std::string_view Default) { return Value.empty() ? Default : Value; };
ZEN_INFO("instantiating structured cache service");
- m_CacheStore = std::make_unique<ZenCacheStore>(m_Gc.Cas(), m_DataRoot / "cache");
+ m_CacheStore = std::make_unique<ZenCacheStore>(m_CasGc, m_DataRoot / "cache");
std::unique_ptr<zen::UpstreamCache> UpstreamCache;
if (ServerOptions.UpstreamCacheConfig.CachePolicy != UpstreamCachePolicy::Disabled)