aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-10-03 14:17:07 +0200
committerGitHub Enterprise <[email protected]>2025-10-03 14:17:07 +0200
commit158d4d50392ff1d416828ca2a17d4c3f4b877bd9 (patch)
tree2c4a84bd3c6e9bce22567895a6e213a6e43bcd48 /src
parentfix missing chunk (#548) (diff)
downloadzen-158d4d50392ff1d416828ca2a17d4c3f4b877bd9.tar.xz
zen-158d4d50392ff1d416828ca2a17d4c3f4b877bd9.zip
move zen vfs implementation to zenstore (#549)
* move zen vfs implementation to zenstore
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/vfs/vfsservice.cpp59
-rw-r--r--src/zenserver/vfs/vfsservice.h13
-rw-r--r--src/zenserver/zenserver.cpp10
-rw-r--r--src/zenserver/zenserver.h1
-rw-r--r--src/zenstore/include/zenstore/vfsimpl.h (renamed from src/zenserver/vfs/vfsimpl.h)31
-rw-r--r--src/zenstore/vfsimpl.cpp (renamed from src/zenserver/vfs/vfsimpl.cpp)22
-rw-r--r--src/zenstore/xmake.lua2
7 files changed, 45 insertions, 93 deletions
diff --git a/src/zenserver/vfs/vfsservice.cpp b/src/zenserver/vfs/vfsservice.cpp
index bf761f8d1..863ec348a 100644
--- a/src/zenserver/vfs/vfsservice.cpp
+++ b/src/zenserver/vfs/vfsservice.cpp
@@ -1,7 +1,8 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "vfsservice.h"
-#include "vfsimpl.h"
+
+#include <zenstore/vfsimpl.h>
#include <zencore/compactbinarybuilder.h>
@@ -61,10 +62,8 @@ GetContentAsCbObject(HttpServerRequest& HttpReq, CbObject& Cb)
// echo {"method": "mount", "params": {"path": "d:\\VFS_ROOT"}} | curl.exe http://localhost:8558/vfs --data-binary @-
// echo {"method": "unmount"} | curl.exe http://localhost:8558/vfs --data-binary @-
-VfsService::VfsService(HttpStatusService& StatusService) : m_StatusService(StatusService)
+VfsService::VfsService(HttpStatusService& StatusService, VfsServiceImpl* ServiceImpl) : m_StatusService(StatusService), m_Impl(ServiceImpl)
{
- m_Impl = new Impl;
-
m_Router.RegisterRoute(
"info",
[&](HttpRouterRequest& Request) {
@@ -142,67 +141,19 @@ VfsService::VfsService(HttpStatusService& StatusService) : m_StatusService(Statu
VfsService::~VfsService()
{
m_StatusService.UnregisterHandler("vfs", *this);
- delete m_Impl;
-}
-
-void
-VfsService::Mount(std::string_view MountPoint)
-{
- m_Impl->Mount(MountPoint);
-}
-
-void
-VfsService::Unmount()
-{
- m_Impl->Unmount();
-}
-
-void
-VfsService::AddService(Ref<ProjectStore>&& Ps)
-{
- m_Impl->AddService(std::move(Ps));
-}
-
-void
-VfsService::AddService(Ref<ZenCacheStore>&& Z$)
-{
- m_Impl->AddService(std::move(Z$));
}
#else
-VfsService::VfsService(HttpStatusService& StatusService) : m_StatusService(StatusService)
+VfsService::VfsService(HttpStatusService& StatusService, VfsServiceImpl* ServiceImpl) : m_StatusService(StatusService)
{
- ZEN_UNUSED(StatusService);
+ ZEN_UNUSED(ServiceImpl);
}
VfsService::~VfsService()
{
}
-void
-VfsService::Mount(std::string_view MountPoint)
-{
- ZEN_UNUSED(MountPoint);
-}
-
-void
-VfsService::Unmount()
-{
-}
-
-void
-VfsService::AddService(Ref<ProjectStore>&& Ps)
-{
- ZEN_UNUSED(Ps);
-}
-
-void
-VfsService::AddService(Ref<ZenCacheStore>&& Z$)
-{
- ZEN_UNUSED(Z$);
-}
-
#endif
const char*
diff --git a/src/zenserver/vfs/vfsservice.h b/src/zenserver/vfs/vfsservice.h
index 0d0168e23..4e06da878 100644
--- a/src/zenserver/vfs/vfsservice.h
+++ b/src/zenserver/vfs/vfsservice.h
@@ -5,7 +5,6 @@
#include <zenbase/refcount.h>
#include <zenhttp/httpserver.h>
#include <zenhttp/httpstatus.h>
-#include <zenvfs/vfs.h>
#include <memory>
@@ -13,6 +12,7 @@ namespace zen {
class ProjectStore;
class ZenCacheStore;
+struct VfsServiceImpl;
/** Virtual File System service
@@ -28,23 +28,16 @@ class ZenCacheStore;
class VfsService : public HttpService, public IHttpStatusProvider
{
public:
- explicit VfsService(HttpStatusService& StatusService);
+ explicit VfsService(HttpStatusService& StatusService, VfsServiceImpl* ServiceImpl);
~VfsService();
- void Mount(std::string_view MountPoint);
- void Unmount();
-
- void AddService(Ref<ProjectStore>&&);
- void AddService(Ref<ZenCacheStore>&&);
-
protected:
virtual const char* BaseUri() const override;
virtual void HandleRequest(HttpServerRequest& HttpServiceRequest) override;
virtual void HandleStatusRequest(HttpServerRequest& Request) override;
private:
- struct Impl;
- Impl* m_Impl = nullptr;
+ VfsServiceImpl* m_Impl = nullptr;
HttpStatusService& m_StatusService;
HttpRequestRouter m_Router;
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index c1199c1a7..29581b192 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -26,6 +26,7 @@
#include <zenstore/buildstore/buildstore.h>
#include <zenstore/cidstore.h>
#include <zenstore/scrubcontext.h>
+#include <zenstore/vfsimpl.h>
#include <zenstore/workspaces.h>
#include <zenutil/workerpools.h>
#include <zenutil/zenserverprocess.h>
@@ -313,9 +314,11 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen
}
#if ZEN_WITH_VFS
- m_VfsService = std::make_unique<VfsService>(m_StatusService);
- m_VfsService->AddService(Ref<ProjectStore>(m_ProjectStore));
- m_VfsService->AddService(Ref<ZenCacheStore>(m_CacheStore));
+ m_VfsServiceImpl = std::make_unique<VfsServiceImpl>();
+ m_VfsServiceImpl->AddService(Ref<ProjectStore>(m_ProjectStore));
+ m_VfsServiceImpl->AddService(Ref<ZenCacheStore>(m_CacheStore));
+
+ m_VfsService = std::make_unique<VfsService>(m_StatusService, m_VfsServiceImpl.get());
#endif // ZEN_WITH_VFS
ZEN_INFO("initializing GC, enabled '{}', interval {}, lightweight interval {}",
@@ -876,6 +879,7 @@ ZenServer::Cleanup()
m_AdminService.reset();
m_VfsService.reset();
+ m_VfsServiceImpl.reset();
m_ObjStoreService.reset();
m_FrontendService.reset();
diff --git a/src/zenserver/zenserver.h b/src/zenserver/zenserver.h
index 8b786ed22..ba76c5fff 100644
--- a/src/zenserver/zenserver.h
+++ b/src/zenserver/zenserver.h
@@ -134,6 +134,7 @@ private:
HttpTestingService m_TestingService;
#endif
RefPtr<ProjectStore> m_ProjectStore;
+ std::unique_ptr<VfsServiceImpl> m_VfsServiceImpl;
std::unique_ptr<HttpProjectService> m_HttpProjectService;
std::unique_ptr<Workspaces> m_Workspaces;
std::unique_ptr<HttpWorkspacesService> m_HttpWorkspacesService;
diff --git a/src/zenserver/vfs/vfsimpl.h b/src/zenstore/include/zenstore/vfsimpl.h
index 0dabf2c67..22ca07a27 100644
--- a/src/zenserver/vfs/vfsimpl.h
+++ b/src/zenstore/include/zenstore/vfsimpl.h
@@ -2,19 +2,20 @@
#pragma once
-#include "vfsservice.h"
-
#include <zencore/logging.h>
-#include <zenstore/projectstore.h>
#include <zenvfs/vfs.h>
-#if ZEN_WITH_VFS
-
-# include <memory>
-# include <unordered_map>
+#include <memory>
+#include <unordered_map>
namespace zen {
+#if ZEN_WITH_VFS
+
+class ProjectStore;
+class ZenCacheStore;
+struct VfsServiceImpl;
+
struct VfsOplogDataSource : public VfsTreeDataSource
{
VfsOplogDataSource(std::string_view ProjectId, std::string_view OplogId, Ref<ProjectStore> InProjectStore);
@@ -46,14 +47,14 @@ private:
struct VfsServiceDataSource : public VfsTreeDataSource
{
- VfsServiceDataSource(VfsService::Impl* VfsImpl) : m_VfsImpl(VfsImpl) {}
+ VfsServiceDataSource(VfsServiceImpl* VfsImpl) : m_VfsImpl(VfsImpl) {}
virtual void ReadNamedData(std::string_view Path, void* Buffer, uint64_t ByteOffset, uint64_t ByteCount) override;
virtual void ReadChunkData(const Oid& ChunkId, void* Buffer, uint64_t ByteOffset, uint64_t ByteCount) override;
virtual void PopulateDirectory(std::string NodePath, VfsTreeNode& DirNode) override;
private:
- VfsService::Impl* m_VfsImpl = nullptr;
+ VfsServiceImpl* m_VfsImpl = nullptr;
RwLock m_Lock;
std::unordered_map<std::string, Ref<VfsOplogDataSource>> m_OplogSourceMap;
@@ -63,12 +64,15 @@ private:
Ref<VfsCacheDataSource> GetCacheDataSource(std::string_view NamespaceId, std::string_view BucketId);
};
+#endif // ZEN_WITH_VFS
+
//////////////////////////////////////////////////////////////////////////
-struct VfsService::Impl
+struct VfsServiceImpl
{
- Impl();
- ~Impl();
+#if ZEN_WITH_VFS
+ VfsServiceImpl();
+ ~VfsServiceImpl();
void Mount(std::string_view MountPoint);
void Unmount();
@@ -93,8 +97,7 @@ private:
void VfsThread();
friend struct VfsServiceDataSource;
+#endif // ZEN_WITH_VFS
};
} // namespace zen
-
-#endif
diff --git a/src/zenserver/vfs/vfsimpl.cpp b/src/zenstore/vfsimpl.cpp
index d22738827..0a918d452 100644
--- a/src/zenserver/vfs/vfsimpl.cpp
+++ b/src/zenstore/vfsimpl.cpp
@@ -1,11 +1,11 @@
// Copyright Epic Games, Inc. All Rights Reserved.
-#include "vfsimpl.h"
-#include "vfsservice.h"
+#include <zenstore/vfsimpl.h>
#include <zencore/fmtutils.h>
#include <zencore/logging.h>
#include <zenstore/cache/structuredcachestore.h>
+#include <zenstore/projectstore.h>
#include <zenvfs/projfs.h>
#include <zenvfs/vfs.h>
@@ -104,17 +104,17 @@ VfsCacheDataSource::PopulateDirectory(std::string NodePath, VfsTreeNode& DirNode
//////////////////////////////////////////////////////////////////////////
-VfsService::Impl::Impl()
+VfsServiceImpl::VfsServiceImpl()
{
}
-VfsService::Impl::~Impl()
+VfsServiceImpl::~VfsServiceImpl()
{
Unmount();
}
void
-VfsService::Impl::Mount(std::string_view MountPoint)
+VfsServiceImpl::Mount(std::string_view MountPoint)
{
ZEN_INFO("VFS mount requested at '{}'", MountPoint);
@@ -136,7 +136,7 @@ VfsService::Impl::Mount(std::string_view MountPoint)
}
void
-VfsService::Impl::Unmount()
+VfsServiceImpl::Unmount()
{
if (m_MountpointPath.empty())
{
@@ -151,7 +151,7 @@ VfsService::Impl::Unmount()
}
void
-VfsService::Impl::AddService(Ref<ProjectStore>&& Ps)
+VfsServiceImpl::AddService(Ref<ProjectStore>&& Ps)
{
m_ProjectStore = std::move(Ps);
@@ -159,7 +159,7 @@ VfsService::Impl::AddService(Ref<ProjectStore>&& Ps)
}
void
-VfsService::Impl::AddService(Ref<ZenCacheStore>&& Z$)
+VfsServiceImpl::AddService(Ref<ZenCacheStore>&& Z$)
{
m_ZenCacheStore = std::move(Z$);
@@ -167,7 +167,7 @@ VfsService::Impl::AddService(Ref<ZenCacheStore>&& Z$)
}
void
-VfsService::Impl::RefreshVfs()
+VfsServiceImpl::RefreshVfs()
{
if (m_VfsHost && m_MountpointPath.empty())
{
@@ -182,7 +182,7 @@ VfsService::Impl::RefreshVfs()
if (!m_VfsHost && !m_MountpointPath.empty())
{
- m_VfsThread = std::thread(&VfsService::Impl::VfsThread, this);
+ m_VfsThread = std::thread(&VfsServiceImpl::VfsThread, this);
m_VfsThreadRunning.Wait();
// At this stage, m_VfsHost should be initialized
@@ -212,7 +212,7 @@ VfsService::Impl::RefreshVfs()
}
void
-VfsService::Impl::VfsThread()
+VfsServiceImpl::VfsThread()
{
SetCurrentThreadName("VFS");
diff --git a/src/zenstore/xmake.lua b/src/zenstore/xmake.lua
index 031a66829..cf5f30d09 100644
--- a/src/zenstore/xmake.lua
+++ b/src/zenstore/xmake.lua
@@ -6,6 +6,6 @@ target('zenstore')
add_headerfiles("**.h")
add_files("**.cpp")
add_includedirs("include", {public=true})
- add_deps("zencore", "zenutil")
+ add_deps("zencore", "zenutil", "zenvfs")
add_packages("vcpkg::robin-map")
add_packages("vcpkg::eastl", {public=true});