blob: 625140b23638ca20d8e2e16ebad3d2a4d3f97ba6 (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "zenserver.h"
#if ZEN_WITH_COMPUTE_SERVICES
# include <zenstore/gc.h>
namespace cxxopts {
class Options;
}
namespace zen::LuaConfig {
struct Options;
}
namespace zen::compute {
class HttpFunctionService;
}
namespace zen {
class CidStore;
class HttpApiService;
class HttpComputeService;
struct ZenComputeServerConfig : public ZenServerConfig
{
std::string UpstreamNotificationEndpoint;
std::string InstanceId; // For use in notifications
};
struct ZenComputeServerConfigurator : public ZenServerConfiguratorBase
{
ZenComputeServerConfigurator(ZenComputeServerConfig& ServerOptions)
: ZenServerConfiguratorBase(ServerOptions)
, m_ServerOptions(ServerOptions)
{
}
~ZenComputeServerConfigurator() = default;
private:
virtual void AddCliOptions(cxxopts::Options& Options) override;
virtual void AddConfigOptions(LuaConfig::Options& Options) override;
virtual void ApplyOptions(cxxopts::Options& Options) override;
virtual void OnConfigFileParsed(LuaConfig::Options& LuaOptions) override;
virtual void ValidateOptions() override;
ZenComputeServerConfig& m_ServerOptions;
};
class ZenComputeServerMain : public ZenServerMain
{
public:
ZenComputeServerMain(ZenComputeServerConfig& ServerOptions);
virtual void DoRun(ZenServerState::ZenServerEntry* Entry) override;
ZenComputeServerMain(const ZenComputeServerMain&) = delete;
ZenComputeServerMain& operator=(const ZenComputeServerMain&) = delete;
typedef ZenComputeServerConfig Config;
typedef ZenComputeServerConfigurator Configurator;
private:
ZenComputeServerConfig& m_ServerOptions;
};
/**
* The compute server handles DDC build function execution requests
* only. It's intended to be used on a pure compute resource and does
* not handle any storage tasks. The actual scheduling happens upstream
* in a storage server instance.
*/
class ZenComputeServer : public ZenServerBase
{
ZenComputeServer& operator=(ZenComputeServer&&) = delete;
ZenComputeServer(ZenComputeServer&&) = delete;
public:
ZenComputeServer();
~ZenComputeServer();
int Initialize(const ZenComputeServerConfig& ServerConfig, ZenServerState::ZenServerEntry* ServerEntry);
void Run();
void Cleanup();
private:
HttpStatsService m_StatsService;
GcManager m_GcManager;
GcScheduler m_GcScheduler{m_GcManager};
std::unique_ptr<CidStore> m_CidStore;
std::unique_ptr<HttpComputeService> m_ComputeService;
std::unique_ptr<HttpApiService> m_ApiService;
std::unique_ptr<zen::compute::HttpFunctionService> m_FunctionService;
void InitializeState(const ZenComputeServerConfig& ServerConfig);
void InitializeServices(const ZenComputeServerConfig& ServerConfig);
void RegisterServices(const ZenComputeServerConfig& ServerConfig);
};
} // namespace zen
#endif // ZEN_WITH_COMPUTE_SERVICES
|