You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#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]
98 lines
3.7 KiB
C++
98 lines
3.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "IVirtualizationBackend.h"
|
|
|
|
namespace UE::Utility { struct FRequestPool; }
|
|
namespace UE::Utility { struct FAccessToken; }
|
|
|
|
namespace UE::Virtualization
|
|
{
|
|
/**
|
|
* NOTE: Although this backend can be used to store data directly in Horde storage, it is much better to use
|
|
* UE::Virtualization::FDDCBackend with a Zen enabled DDC instead. Due to this reason FHttpBackend will most
|
|
* likely be deprecated in UE 5.1 and is only provided for experimentation purposes.
|
|
*
|
|
* This backend allows data to be stored in and retrieved from the Horde storage service.
|
|
*
|
|
* Ini file setup:
|
|
* 'Name'=(Type=HordeStorage, Host="", Namespace="", ChunkSize=, OAuthProvider="", OAuthClientId="", OAuthSecret="")
|
|
* Host: The URL of the service, use http://localhost if hosted locally.
|
|
* Namespace: Horde storage is divided into a number of namespaces allowing projects to keep their data separate
|
|
* while using the same service. This value controls which name space will be used.
|
|
* ChunkSize: Each payload can be divided into a number of chunks when being uploaded to Horde to improve upload
|
|
* performance, this value sets the max size (in bytes) of each chunk. To disable and attempt to upload
|
|
* each payload as a single data blob, set this to -1.
|
|
* OAuthProvider: Url of the OAuth authorization server.
|
|
* OAuthClientId: Public identifier for use with the OAuth authorization server.
|
|
* OAuthSecret: Password for the OAuthClientId
|
|
* (Note that the OAuth entries are not required if hosting locally)
|
|
*/
|
|
class FHttpBackend final : public IVirtualizationBackend
|
|
{
|
|
public:
|
|
explicit FHttpBackend(FStringView ProjectName, FStringView ConfigName, FStringView DebugName);
|
|
virtual ~FHttpBackend() = default;
|
|
|
|
private:
|
|
/* IVirtualizationBackend implementation */
|
|
|
|
virtual bool Initialize(const FString& ConfigEntry) override;
|
|
|
|
virtual EConnectionStatus OnConnect() override;
|
|
|
|
virtual EPushResult PushData(const FIoHash& Id, const FCompressedBuffer& CompressedPayload, const FString& PackageContext) override;
|
|
|
|
virtual FCompressedBuffer PullData(const FIoHash& Id) override;
|
|
|
|
virtual bool DoesPayloadExist(const FIoHash& Id) override;
|
|
|
|
private:
|
|
|
|
bool IsUsingLocalHost() const;
|
|
bool IsServiceReady() const;
|
|
bool AcquireAccessToken();
|
|
|
|
/**
|
|
* Request the status of the service that we are connected to and make sure that it supports the
|
|
* feature set we need and meets our minimum version requirements.
|
|
*/
|
|
bool ValidateServiceVersion();
|
|
|
|
bool ShouldRetryOnError(int64 ResponseCode);
|
|
|
|
bool PostChunk(const TArrayView<const uint8>& ChunkData, const FIoHash& PayloadId, FString& OutHashAsString);
|
|
bool PullChunk(const FString& Hash, const FIoHash& PayloadId, uint8* DataPtr, int64 BufferSize);
|
|
bool DoesChunkExist(const FString& Hash);
|
|
|
|
/** Address of the service*/
|
|
FString HostAddress;
|
|
/** Namespace to connect to */
|
|
FString Namespace;
|
|
/** Europa allows us to organize the payloads by bucket. Currently this is not exposed and just set to 'default' */
|
|
FString Bucket;
|
|
|
|
/** The max size of each payload chunk */
|
|
uint64 ChunkSize;
|
|
|
|
/** Url of the OAuth authorization server */
|
|
FString OAuthProvider;
|
|
/** Public identifier for use with the OAuth authorization server */
|
|
FString OAuthClientId;
|
|
/** Password for the OAuthClientId */
|
|
FString OAuthSecret;
|
|
|
|
/** The pool of FRequest objects that can be recycled */
|
|
TUniquePtr<Utility::FRequestPool> RequestPool;
|
|
|
|
/** Critical section used to protect the creation of new access tokens */
|
|
FCriticalSection AccessCs;
|
|
/** The access token used with service authorization */
|
|
TUniquePtr<Utility::FAccessToken> AccessToken;
|
|
/** Count how many times a login has failed since the last successful login */
|
|
uint32 FailedLoginAttempts;
|
|
};
|
|
|
|
} // namespace UE::Virtualization
|