2021-08-31 06:30:26 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-10-25 20:05:28 -04:00
|
|
|
#include "IVirtualizationBackend.h"
|
2021-08-31 06:30:26 -04:00
|
|
|
|
|
|
|
|
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:
|
2021-09-17 06:03:03 -04:00
|
|
|
* '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]
|
2021-08-31 06:30:26 -04:00
|
|
|
*/
|
2021-12-02 06:21:36 -05:00
|
|
|
class FFileSystemBackend final : public IVirtualizationBackend
|
2021-08-31 06:30:26 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-02 06:21:36 -05:00
|
|
|
explicit FFileSystemBackend(FStringView ConfigName, FStringView DebugName);
|
2021-08-31 06:30:26 -04:00
|
|
|
virtual ~FFileSystemBackend() = default;
|
|
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
private:
|
|
|
|
|
/* IVirtualizationBackend implementation */
|
2021-08-31 06:30:26 -04:00
|
|
|
|
|
|
|
|
virtual bool Initialize(const FString& ConfigEntry) override;
|
|
|
|
|
|
2021-12-08 02:19:42 -05:00
|
|
|
virtual EPushResult PushData(const FPayloadId& Id, const FCompressedBuffer& Payload, const FString& PackageContext) override;
|
2021-08-31 06:30:26 -04:00
|
|
|
|
|
|
|
|
virtual FCompressedBuffer PullData(const FPayloadId& Id) override;
|
|
|
|
|
|
2021-12-01 11:13:31 -05:00
|
|
|
virtual bool DoesPayloadExist(const FPayloadId& Id) override;
|
2021-09-17 06:03:03 -04:00
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
private:
|
|
|
|
|
|
2021-08-31 06:30:26 -04:00
|
|
|
void CreateFilePath(const FPayloadId& PayloadId, FStringBuilderBase& OutPath);
|
|
|
|
|
|
2021-09-17 06:03:03 -04:00
|
|
|
TUniquePtr<FArchive> OpenFileForReading(const TCHAR* FilePath);
|
2021-11-18 14:37:34 -05:00
|
|
|
|
2021-09-17 06:03:03 -04:00
|
|
|
/** The root directory where the payload files should be located. */
|
2021-08-31 06:30:26 -04:00
|
|
|
FString RootDirectory;
|
2021-09-17 06:03:03 -04:00
|
|
|
|
|
|
|
|
/** 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;
|
2021-08-31 06:30:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace UE::Virtualization
|