blob: 1e885da3d870085a096be034429958a7642332ef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "zencompute/functionservice.h"
#if ZEN_WITH_COMPUTE_SERVICES
# include "functionrunner.h"
# include <zencore/compactbinarypackage.h>
# include <zencore/logging.h>
# include <zencore/zencore.h>
# include <zenhttp/httpclient.h>
# include <atomic>
# include <filesystem>
# include <thread>
namespace zen {
class CidStore;
}
namespace zen::compute {
/** HTTP-based runner
This implements a DDC remote compute execution strategy via REST API
*/
class RemoteHttpRunner : public FunctionRunner
{
RemoteHttpRunner(RemoteHttpRunner&&) = delete;
RemoteHttpRunner& operator=(RemoteHttpRunner&&) = delete;
public:
RemoteHttpRunner(ChunkResolver& InChunkResolver, const std::filesystem::path& BaseDir, std::string_view HostName);
~RemoteHttpRunner();
virtual void Shutdown() override;
virtual void RegisterWorker(const CbPackage& WorkerPackage) override;
[[nodiscard]] virtual SubmitResult SubmitAction(Ref<RunnerAction> Action) override;
[[nodiscard]] virtual bool IsHealthy() override;
[[nodiscard]] virtual size_t GetSubmittedActionCount() override;
[[nodiscard]] virtual size_t QueryCapacity() override;
[[nodiscard]] virtual std::vector<SubmitResult> SubmitActions(const std::vector<Ref<RunnerAction>>& Actions) override;
protected:
LoggerRef Log() { return m_Log; }
private:
LoggerRef m_Log;
ChunkResolver& m_ChunkResolver;
std::string m_BaseUrl;
HttpClient m_Http;
int32_t m_MaxRunningActions = 256; // arbitrary limit for testing
struct HttpRunningAction
{
Ref<RunnerAction> Action;
int RemoteActionLsn = 0; // Remote LSN
bool Success = false;
CbPackage ActionResults;
};
RwLock m_RunningLock;
std::unordered_map<int, HttpRunningAction> m_RemoteRunningMap; // Note that this is keyed on the *REMOTE* lsn
std::thread m_MonitorThread;
std::atomic<bool> m_MonitorThreadEnabled{true};
Event m_MonitorThreadEvent;
void MonitorThreadFunction();
size_t SweepRunningActions();
};
} // namespace zen::compute
#endif
|