aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/hub/storageserverinstance.h
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-03-10 09:40:21 +0100
committerGitHub Enterprise <[email protected]>2026-03-10 09:40:21 +0100
commit7a54bc0af3423923e30faf632c0862162e9af62d (patch)
tree50328fc2ed5de0ac1dd6fc8649dfcef730a56681 /src/zenserver/hub/storageserverinstance.h
parentMerge pull request #752 from ue-foundation/lm/restrict-content-type (diff)
downloadzen-7a54bc0af3423923e30faf632c0862162e9af62d.tar.xz
zen-7a54bc0af3423923e30faf632c0862162e9af62d.zip
hubservice refactor (#819)
* move Hub to separate class * move StorageServerInstance to separate files * refactor HttpHubService to not own Hub instance
Diffstat (limited to 'src/zenserver/hub/storageserverinstance.h')
-rw-r--r--src/zenserver/hub/storageserverinstance.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/zenserver/hub/storageserverinstance.h b/src/zenserver/hub/storageserverinstance.h
new file mode 100644
index 000000000..a2f3d25d7
--- /dev/null
+++ b/src/zenserver/hub/storageserverinstance.h
@@ -0,0 +1,68 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include "resourcemetrics.h"
+
+#include <zenutil/zenserverprocess.h>
+
+#include <atomic>
+#include <filesystem>
+
+namespace zen {
+
+/**
+ * Storage Server Instance
+ *
+ * This class manages the lifecycle of a storage server instance, and
+ * provides functions to query its state. There should be one instance
+ * per module ID.
+ */
+class StorageServerInstance
+{
+public:
+ StorageServerInstance(ZenServerEnvironment& RunEnvironment,
+ std::string_view ModuleId,
+ std::filesystem::path FileHydrationPath,
+ std::filesystem::path HydrationTempPath);
+ ~StorageServerInstance();
+
+ void Provision();
+ void Deprovision();
+
+ void Hibernate();
+ void Wake();
+
+ const ResourceMetrics& GetResourceMetrics() const { return m_ResourceMetrics; }
+
+ inline std::string_view GetModuleId() const { return m_ModuleId; }
+ inline bool IsProvisioned() const { return m_IsProvisioned.load(); }
+
+ inline uint16_t GetBasePort() const { return m_ServerInstance.GetBasePort(); }
+
+#if ZEN_PLATFORM_WINDOWS
+ void SetJobObject(JobObject* InJobObject) { m_JobObject = InJobObject; }
+#endif
+
+private:
+ void WakeLocked();
+ RwLock m_Lock;
+ std::string m_ModuleId;
+ std::atomic<bool> m_IsProvisioned{false};
+ std::atomic<bool> m_IsHibernated{false};
+ ZenServerInstance m_ServerInstance;
+ std::filesystem::path m_BaseDir;
+ std::filesystem::path m_TempDir;
+ std::filesystem::path m_HydrationPath;
+ ResourceMetrics m_ResourceMetrics;
+#if ZEN_PLATFORM_WINDOWS
+ JobObject* m_JobObject = nullptr;
+#endif
+
+ void SpawnServerProcess();
+
+ void Hydrate();
+ void Dehydrate();
+};
+
+} // namespace zen