2021-09-03 02:57:01 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-10-25 20:05:28 -04:00
|
|
|
#include "IVirtualizationBackend.h"
|
2021-09-03 02:57:01 -04:00
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
#include "DerivedDataCacheKey.h"
|
|
|
|
|
|
2021-09-21 01:10:55 -04:00
|
|
|
namespace UE::DerivedData { enum class ECachePolicy : uint32; }
|
2021-09-03 02:57:01 -04:00
|
|
|
|
|
|
|
|
namespace UE::Virtualization
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* A backend that uses the DDC2 as it's storage mechanism. It is intended to be used as a local caching
|
|
|
|
|
* system to speed up operations rather than for use as persistent storage.
|
|
|
|
|
*
|
|
|
|
|
* Ini file setup:
|
|
|
|
|
* 'Name'=(Type=DDCBackend, Bucket="XXX", LocalStorage=True/False, RemoteStorage=True/False)
|
|
|
|
|
*
|
|
|
|
|
* Required Values:
|
|
|
|
|
* 'Name': The backend name in the hierarchy.
|
|
|
|
|
*
|
|
|
|
|
* Optional Values:
|
|
|
|
|
* Bucket: An alphanumeric identifier used to group the payloads together in storage. [Default="BulkData"]
|
|
|
|
|
* LocalStorage: When set to true, the payloads can be stored locally. [Default=true]
|
|
|
|
|
* RemoteStorage: When set to true, the payloads can be stored remotely. [Default=true]
|
|
|
|
|
*/
|
2021-12-02 06:21:36 -05:00
|
|
|
class FDDCBackend final : public IVirtualizationBackend
|
2021-09-03 02:57:01 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2022-03-08 11:22:45 -05:00
|
|
|
explicit FDDCBackend(FStringView ProjectName, FStringView ConfigName, FStringView InDebugName);
|
2021-09-03 02:57:01 -04:00
|
|
|
virtual ~FDDCBackend() = default;
|
|
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
private:
|
|
|
|
|
/* IVirtualizationBackend implementation */
|
2021-09-03 02:57:01 -04:00
|
|
|
|
|
|
|
|
virtual bool Initialize(const FString& ConfigEntry) override;
|
|
|
|
|
|
Add a number of ways for the VA backend connections to be changed to lazy initialize on first use.
#rb Devin.Doucette
#jira UE-161599
#rnx
#preflight 6303c8d65a5d4e4624e7bf52
- There are some use cases that require the VA system to be initialized and configured correctly but would prefer that the backend connections only run if absolutely needed (usually when a payload is pulled or pushed for the first time), this change provides four different ways of doing this:
-- Setting [Core.VirtualizationModule]LazyInitConnections=true in the Engine ini file
-- Setting the define 'UE_VIRTUALIZATION_CONNECTION_LAZY_INIT' to 1 in a programs .target.cs
-- Running with the commandline option -VA-LazyInitConnections
-- Setting the cvar 'VA.LazyInitConnections' to 1 (only works if it is set before the VA system is initialized, changing it mid editor via the console does nothing)
--- Note that after the config file, each setting there only opts into lazy initializing the connections, setting the cvar to 0 for example will not prevent the cmdline from opting in etc.
- In the future we will allow the connection code to run async, so the latency can be hidden behind the editor loading, but for the current use case we are taking the minimal approach.
-- This means we only support the backend being in 3 states. No connection has been made yet, the connection is broken and the connection is working.
-- To keep things simple we only record if we have attempted to connect the backends or not. We don't check individual backends nor do we try to reconnect failed ones etc. This is all scheduled for a future work item.
- If the connections are not initialized when the VA system is, we wait until the first time someone calls one of the virtualization methods that will actually use a connection: Push/Pull/Query
-- We try connecting all of the backends at once, even if they won't be used in the call to keep things simple.
- Only the source control backend makes use of the connection system. The horde storage (http) backend could take advantage too, but it is currently unused and most likely going to just be deleted so there seemed little point updating it.
- If we try to run an operation on an unconnected backend we only log to verbose. This is to maintain existing behaviour where a failed backend would not be mounted at all. This logging will likely be revisited in a future work item.
[CL 21511855 by paul chipchase in ue5-main branch]
2022-08-23 13:01:15 -04:00
|
|
|
virtual EConnectionStatus OnConnect() override;
|
|
|
|
|
|
2022-06-02 09:04:45 -04:00
|
|
|
virtual bool PushData(TArrayView<FPushRequest> Requests) override;
|
2022-10-21 22:27:40 -04:00
|
|
|
virtual bool PullData(TArrayView<FPullRequest> Requests) override;
|
2021-12-01 11:13:31 -05:00
|
|
|
|
2022-02-02 02:21:24 -05:00
|
|
|
virtual bool DoesPayloadExist(const FIoHash& Id) override;
|
2021-12-02 06:21:36 -05:00
|
|
|
|
|
|
|
|
private:
|
2021-09-03 02:57:01 -04:00
|
|
|
/** The bucket being used to group together the virtualized payloads in storage */
|
|
|
|
|
FString BucketName;
|
|
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
/** The FCacheBucket used with the DDC, cached to avoid recreating it for each request */
|
2021-09-13 07:00:55 -04:00
|
|
|
UE::DerivedData::FCacheBucket Bucket;
|
|
|
|
|
|
2021-09-03 02:57:01 -04:00
|
|
|
/** The policy to use when uploading or downloading data from the cache */
|
|
|
|
|
UE::DerivedData::ECachePolicy TransferPolicy;
|
|
|
|
|
/** The policy to use when querying the cache for information */
|
|
|
|
|
UE::DerivedData::ECachePolicy QueryPolicy;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace UE::Virtualization
|