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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include "config/config.h"
namespace zen {
struct ZenUpstreamJupiterConfig
{
std::string Name;
std::string Url;
std::string OAuthUrl;
std::string OAuthClientId;
std::string OAuthClientSecret;
std::string OpenIdProvider;
std::string AccessToken;
std::string Namespace;
std::string DdcNamespace;
};
struct ZenUpstreamZenConfig
{
std::string Name;
std::vector<std::string> Urls;
std::vector<std::string> Dns;
};
enum class UpstreamCachePolicy : uint8_t
{
Disabled = 0,
Read = 1 << 0,
Write = 1 << 1,
ReadWrite = Read | Write
};
struct ZenUpstreamCacheConfig
{
ZenUpstreamJupiterConfig JupiterConfig;
ZenUpstreamZenConfig ZenConfig;
int32_t UpstreamThreadCount = 4;
int32_t ConnectTimeoutMilliseconds = 5000;
int32_t TimeoutMilliseconds = 0;
UpstreamCachePolicy CachePolicy = UpstreamCachePolicy::ReadWrite;
};
struct ZenCacheEvictionPolicy
{
int32_t MaxDurationSeconds = 24 * 60 * 60;
};
struct ZenProjectStoreEvictionPolicy
{
int32_t MaxDurationSeconds = 7 * 24 * 60 * 60;
};
struct ZenBuildStoreEvictionPolicy
{
int32_t MaxDurationSeconds = 3 * 24 * 60 * 60;
};
struct ZenGcConfig
{
// ZenCasEvictionPolicy Cas;
ZenCacheEvictionPolicy Cache;
ZenProjectStoreEvictionPolicy ProjectStore;
ZenBuildStoreEvictionPolicy BuildStore;
int32_t MonitorIntervalSeconds = 30;
int32_t IntervalSeconds = 0;
bool CollectSmallObjects = true;
bool Enabled = true;
uint64_t DiskReserveSize = 1ul << 28;
uint64_t DiskSizeSoftLimit = 0;
int32_t LightweightIntervalSeconds = 0;
uint64_t MinimumFreeDiskSpaceToAllowWrites = 1ul << 28;
bool UseGCV2 = false;
uint32_t CompactBlockUsageThresholdPercent = 90;
bool Verbose = false;
bool SingleThreaded = false;
static constexpr uint16_t GcMaxAttachmentPassCount = 256;
uint16_t AttachmentPassCount = 1;
bool StoreCacheAttachmentMetaData = false;
bool StoreProjectAttachmentMetaData = false;
bool EnableValidation = true;
};
struct ZenOpenIdProviderConfig
{
std::string Name;
std::string Url;
std::string ClientId;
};
struct ZenAuthConfig
{
std::vector<ZenOpenIdProviderConfig> OpenIdProviders;
};
struct ZenObjectStoreConfig
{
struct BucketConfig
{
std::string Name;
std::filesystem::path Directory;
};
std::vector<BucketConfig> Buckets;
};
struct ZenStructuredCacheBucketConfig
{
uint64_t MaxBlockSize = 1ull << 30;
uint32_t PayloadAlignment = 1u << 4;
uint64_t MemCacheSizeThreshold = 1 * 1024;
uint64_t LargeObjectThreshold = 128 * 1024;
bool LimitOverwrites = true;
};
struct ZenStructuredCacheConfig
{
bool Enabled = true;
bool WriteLogEnabled = false;
bool AccessLogEnabled = false;
std::vector<std::pair<std::string, ZenStructuredCacheBucketConfig>> PerBucketConfigs;
ZenStructuredCacheBucketConfig BucketConfig;
uint64_t MemTargetFootprintBytes = 512 * 1024 * 1024;
uint64_t MemTrimIntervalSeconds = 60;
uint64_t MemMaxAgeSeconds = gsl::narrow<uint64_t>(std::chrono::seconds(std::chrono::days(1)).count());
};
struct ZenProjectStoreConfig
{
bool StoreCacheAttachmentMetaData = false;
bool StoreProjectAttachmentMetaData = false;
};
struct ZenBuildStoreConfig
{
bool Enabled = false;
uint64_t MaxDiskSpaceLimit = 1u * 1024u * 1024u * 1024u * 1024u; // 1TB
};
struct ZenWorkspacesConfig
{
bool Enabled = false;
bool AllowConfigurationChanges = false;
};
struct ZenStorageServerConfig : public ZenServerConfig
{
ZenUpstreamCacheConfig UpstreamCacheConfig;
ZenGcConfig GcConfig;
ZenAuthConfig AuthConfig;
ZenObjectStoreConfig ObjectStoreConfig;
ZenStructuredCacheConfig StructuredCacheConfig;
ZenProjectStoreConfig ProjectStoreConfig;
ZenBuildStoreConfig BuildStoreConfig;
ZenWorkspacesConfig WorksSpacesConfig;
std::filesystem::path PluginsConfigFile; // Path to plugins config file
bool ObjectStoreEnabled = false;
bool ComputeEnabled = true;
std::string ScrubOptions;
};
struct ZenStorageServerCmdLineOptions
{
// Note to those adding future options; std::filesystem::path-type options
// must be read into a std::string first. As of cxxopts-3.0.0 it uses a >>
// stream operator to convert argv value into the options type. std::fs::path
// expects paths in streams to be quoted but argv paths are unquoted. By
// going into a std::string first, paths with whitespace parse correctly.
std::string PluginsConfigFile;
void AddCliOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
void ApplyOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
std::string OpenIdProviderName;
std::string OpenIdProviderUrl;
std::string OpenIdClientId;
void AddSecurityOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
std::string UpstreamCachePolicyOptions;
void AddCacheOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
void AddGcOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
std::vector<std::string> BucketConfigs;
void AddObjectStoreOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
void AddBuildStoreOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
void AddWorkspacesOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
};
struct ZenStorageServerConfigurator : public ZenServerConfiguratorBase
{
ZenStorageServerConfigurator(ZenStorageServerConfig& ServerOptions)
: ZenServerConfiguratorBase(ServerOptions)
, m_ServerOptions(ServerOptions)
{
}
~ZenStorageServerConfigurator() = 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;
void ParsePluginsConfigFile(const std::filesystem::path& Path);
ZenStorageServerConfig& m_ServerOptions;
ZenStorageServerCmdLineOptions m_StorageOptions;
};
} // namespace zen
|