Files
UnrealEngineUWP/Engine/Source/Developer/Virtualization/Private/VirtualizationFileBackend.h
paul chipchase c65eb35e8c Add bitflag enums to IVirtualizationBackend::PullData and IVirtualizationBackend::PushData so that it is easier to specialize behavior in the future.
#rb Per.Larsson
#jira UE-182205
#preflight 643932b2211b661dc4f594c6

- The enums don't contain any entries at the moment, the goal of this change is to reduce the friction that future API changes might have.
- The older versions of PullData/PushData have been deprecated but this won't flag compiler warnings if people have derived their own implementations of IVirtualizationBackend, so in addition to deprecating the methods have been set to 'final' and have checkNoEntry implementations which is the best we can do at the moment.
-- It is unlikely that people have actually done this as the documentation on adding new backend types will only go out in 5.3.

[CL 25039959 by paul chipchase in ue5-main branch]
2023-04-14 10:13:46 -04:00

67 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "IVirtualizationBackend.h"
namespace UE::Virtualization
{
/**
* A basic backend based on the file system. This can be used to access/store virtualization
* data either on a local disk or a network share. It is intended to be used as a caching system
* to speed up operations (running a local cache or a shared cache for a site) rather than as the
* proper backend solution.
*
* Ini file setup:
* 'Name'=(Type=FileSystem, Path="XXX", RetryCount=X, RetryWaitTime=X)
*
* Required Values:
* 'Name': The backend name in the hierarchy.
* 'Type': The backend will be of type 'FFileSystemBackend'.
* 'Path': The root directory where the files are stored.
*
* Optional Values:
* RetryCount: How many times we should try to open a payload file for read before giving up with
* an error. Useful when many threads/processes can be pushing/pulling from the same
* path/ [Default=10]
* RetryWaitTime: The length of time the process should wait between each read attempt in milliseconds.
* Remember that the max length of time that the process can stall attempting to read
* a payload file is RetryCount * RetryWaitTime; [Default=100ms]
* EnvPathOverride: The name of the environment variable that the user can set to override 'Path'. This
* should only ever be set if you wish for the users to be able to choose where the
* payloads are being stored and do not rely on 'Path' always being used. [Default=""]
*/
class FFileSystemBackend final : public IVirtualizationBackend
{
public:
explicit FFileSystemBackend(FStringView ProjectName, FStringView ConfigName, FStringView DebugName);
virtual ~FFileSystemBackend() = default;
private:
/* IVirtualizationBackend implementation */
virtual bool Initialize(const FString& ConfigEntry) override;
virtual EConnectionStatus OnConnect() override;
virtual bool PushData(TArrayView<FPushRequest> Requests, EPushFlags Flags) override;
virtual bool PullData(TArrayView<FPullRequest> Requests, EPullFlags Flags) override;
virtual bool DoesPayloadExist(const FIoHash& Id) override;
private:
void CreateFilePath(const FIoHash& PayloadId, FStringBuilderBase& OutPath);
TUniquePtr<FArchive> OpenFileForReading(const TCHAR* FilePath);
/** The root directory where the payload files should be located. */
FString RootDirectory;
/** The number of times to retry opening a payload file for read */
int32 RetryCount = 10;
/** The length of time (in milliseconds) to wait after each attempt before retrying. */
int32 RetryWaitTimeMS = 100;
};
} // namespace UE::Virtualization