Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#include "params.h" |
6 |
|
|
|
7 |
|
|
#include <vector> |
8 |
|
|
|
9 |
|
|
#include "options.h" |
10 |
|
|
#include "util/string.h" |
11 |
|
|
|
12 |
|
|
namespace receiver { |
13 |
|
|
|
14 |
|
✗ |
std::string GetSpoolerTempDir(const std::string& spooler_config) { |
15 |
|
✗ |
const std::vector<std::string> tokens = SplitString(spooler_config, ','); |
16 |
|
✗ |
assert(tokens.size() == 3); |
17 |
|
✗ |
return tokens[1]; |
18 |
|
|
} |
19 |
|
|
|
20 |
|
✗ |
bool GetParamsFromFile(const std::string& repo_name, Params* params) { |
21 |
|
|
const std::string repo_config_file = |
22 |
|
✗ |
"/etc/cvmfs/repositories.d/" + repo_name + "/server.conf"; |
23 |
|
|
|
24 |
|
|
SimpleOptionsParser parser = SimpleOptionsParser( |
25 |
|
✗ |
new DefaultOptionsTemplateManager(repo_name)); |
26 |
|
✗ |
if (!parser.TryParsePath(repo_config_file)) { |
27 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
28 |
|
|
"Could not parse repository configuration: %s.", |
29 |
|
|
repo_config_file.c_str()); |
30 |
|
✗ |
return false; |
31 |
|
|
} |
32 |
|
|
|
33 |
|
✗ |
if (!parser.GetValue("CVMFS_STRATUM0", ¶ms->stratum0)) { |
34 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
35 |
|
|
"Missing parameter %s in repository configuration file.", |
36 |
|
|
"CVMFS_STRATUM0"); |
37 |
|
✗ |
return false; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
✗ |
if (parser.IsDefined("CVMFS_SERVER_PROXY")) { |
41 |
|
✗ |
parser.GetValue("CVMFS_SERVER_PROXY", ¶ms->proxy); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
// Note: TEST_CVMFS_RECEIVER_UPSTREAM_STORAGE is used to provide an |
45 |
|
|
// an overriding value for CVMFS_UPSTREAM_STORAGE, to be used |
46 |
|
|
// only by the cvmfs_receiver application. Useful for testing |
47 |
|
|
// when the release manager and the repository gateway are |
48 |
|
|
// running on the same machine. |
49 |
|
✗ |
if (parser.IsDefined("TEST_CVMFS_RECEIVER_UPSTREAM_STORAGE")) { |
50 |
|
✗ |
parser.GetValue("TEST_CVMFS_RECEIVER_UPSTREAM_STORAGE", |
51 |
|
|
¶ms->spooler_configuration); |
52 |
|
|
} else { |
53 |
|
✗ |
if (!parser.GetValue("CVMFS_UPSTREAM_STORAGE", |
54 |
|
|
¶ms->spooler_configuration)) { |
55 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
56 |
|
|
"Missing parameter %s in repository configuration file.", |
57 |
|
|
"CVMFS_UPSTREAM_STORAGE"); |
58 |
|
✗ |
return false; |
59 |
|
|
} |
60 |
|
|
} |
61 |
|
|
|
62 |
|
✗ |
std::string use_local_cache_str; |
63 |
|
✗ |
if (parser.GetValue("CVMFS_SERVER_USE_CATALOG_CACHE", &use_local_cache_str)) { |
64 |
|
✗ |
params->use_local_cache = parser.IsOn(use_local_cache_str); |
65 |
|
|
} else { |
66 |
|
✗ |
params->use_local_cache = false; |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
|
70 |
|
✗ |
std::string hash_algorithm_str; |
71 |
|
✗ |
if (!parser.GetValue("CVMFS_HASH_ALGORITHM", &hash_algorithm_str)) { |
72 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
73 |
|
|
"Missing parameter %s in repository configuration file.", |
74 |
|
|
"CVMFS_HASH_ALGORITHM"); |
75 |
|
✗ |
return false; |
76 |
|
|
} |
77 |
|
✗ |
params->hash_alg = shash::ParseHashAlgorithm(hash_algorithm_str); |
78 |
|
✗ |
params->hash_alg_str = hash_algorithm_str; |
79 |
|
|
|
80 |
|
|
// The receiver does not store files, only catalogs. |
81 |
|
|
// We can safely hard-code the following options |
82 |
|
✗ |
params->generate_legacy_bulk_chunks = false; |
83 |
|
✗ |
params->compression_alg = zlib::kZlibDefault; |
84 |
|
|
|
85 |
|
✗ |
std::string use_chunking_str; |
86 |
|
✗ |
if (!parser.GetValue("CVMFS_USE_FILE_CHUNKING", &use_chunking_str)) { |
87 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
88 |
|
|
"Missing parameter %s in repository configuration file.", |
89 |
|
|
"CVMFS_USE_FILE_CHUNKING"); |
90 |
|
✗ |
return false; |
91 |
|
|
} |
92 |
|
✗ |
params->use_file_chunking = parser.IsOn(use_chunking_str); |
93 |
|
|
|
94 |
|
✗ |
std::string min_chunk_size_str; |
95 |
|
✗ |
if (!parser.GetValue("CVMFS_MIN_CHUNK_SIZE", &min_chunk_size_str)) { |
96 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
97 |
|
|
"Missing parameter %s in repository configuration file.", |
98 |
|
|
"CVMFS_MIN_CHUNK_SIZE"); |
99 |
|
✗ |
return false; |
100 |
|
|
} |
101 |
|
✗ |
params->min_chunk_size = String2Uint64(min_chunk_size_str); |
102 |
|
|
|
103 |
|
✗ |
std::string avg_chunk_size_str; |
104 |
|
✗ |
if (!parser.GetValue("CVMFS_AVG_CHUNK_SIZE", &avg_chunk_size_str)) { |
105 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
106 |
|
|
"Missing parameter %s in repository configuration file.", |
107 |
|
|
"CVMFS_AVG_CHUNK_SIZE"); |
108 |
|
✗ |
return false; |
109 |
|
|
} |
110 |
|
✗ |
params->avg_chunk_size = String2Uint64(avg_chunk_size_str); |
111 |
|
|
|
112 |
|
✗ |
std::string max_chunk_size_str; |
113 |
|
✗ |
if (!parser.GetValue("CVMFS_MAX_CHUNK_SIZE", &max_chunk_size_str)) { |
114 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
115 |
|
|
"Missing parameter %s in repository configuration file.", |
116 |
|
|
"CVMFS_MAX_CHUNK_SIZE"); |
117 |
|
✗ |
return false; |
118 |
|
|
} |
119 |
|
✗ |
params->max_chunk_size = String2Uint64(max_chunk_size_str); |
120 |
|
|
|
121 |
|
✗ |
std::string garbage_collection_str; |
122 |
|
✗ |
if (!parser.GetValue("CVMFS_GARBAGE_COLLECTION", &garbage_collection_str)) { |
123 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
124 |
|
|
"Missing parameter %s in repository configuration file.", |
125 |
|
|
"CVMFS_GARBAGE_COLLECTION"); |
126 |
|
✗ |
return false; |
127 |
|
|
} |
128 |
|
✗ |
params->garbage_collection = parser.IsOn(garbage_collection_str); |
129 |
|
|
|
130 |
|
✗ |
std::string use_autocatalogs_str; |
131 |
|
✗ |
if (!parser.GetValue("CVMFS_AUTOCATALOGS", &use_autocatalogs_str)) { |
132 |
|
✗ |
LogCvmfs(kLogReceiver, kLogSyslogErr, |
133 |
|
|
"Missing parameter %s in repository configuration file.", |
134 |
|
|
"CVMFS_AUTOCATALOGS"); |
135 |
|
✗ |
return false; |
136 |
|
|
} |
137 |
|
✗ |
params->use_autocatalogs = parser.IsOn(use_autocatalogs_str); |
138 |
|
|
|
139 |
|
✗ |
std::string max_weight_str; |
140 |
|
✗ |
if (parser.GetValue("CVMFS_AUTOCATALOGS_MAX_WEIGHT", &max_weight_str)) { |
141 |
|
✗ |
params->max_weight = String2Uint64(max_weight_str); |
142 |
|
|
} |
143 |
|
|
|
144 |
|
✗ |
std::string min_weight_str; |
145 |
|
✗ |
if (parser.GetValue("CVMFS_AUTOCATALOGS_MIN_WEIGHT", &min_weight_str)) { |
146 |
|
✗ |
params->min_weight = String2Uint64(min_weight_str); |
147 |
|
|
} |
148 |
|
|
|
149 |
|
✗ |
std::string enforce_limits_str; |
150 |
|
✗ |
if (parser.GetValue("CVMFS_ENFORCE_LIMITS", &enforce_limits_str)) { |
151 |
|
✗ |
params->enforce_limits = parser.IsOn(enforce_limits_str); |
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
// TODO(dwd): the next 3 limit variables should take defaults from |
155 |
|
|
// SyncParameters |
156 |
|
✗ |
params->nested_kcatalog_limit = 0; |
157 |
|
✗ |
std::string nested_kcatalog_limit_str; |
158 |
|
✗ |
if (parser.GetValue("CVMFS_NESTED_KCATALOG_LIMIT", |
159 |
|
|
&nested_kcatalog_limit_str)) { |
160 |
|
✗ |
params->nested_kcatalog_limit = String2Uint64(nested_kcatalog_limit_str); |
161 |
|
|
} |
162 |
|
|
|
163 |
|
✗ |
params->root_kcatalog_limit = 0; |
164 |
|
✗ |
std::string root_kcatalog_limit_str; |
165 |
|
✗ |
if (parser.GetValue("CVMFS_ROOT_KCATALOG_LIMIT", &root_kcatalog_limit_str)) { |
166 |
|
✗ |
params->root_kcatalog_limit = String2Uint64(root_kcatalog_limit_str); |
167 |
|
|
} |
168 |
|
|
|
169 |
|
✗ |
params->file_mbyte_limit = 0; |
170 |
|
✗ |
std::string file_mbyte_limit_str; |
171 |
|
✗ |
if (parser.GetValue("CVMFS_FILE_MBYTE_LIMIT", &file_mbyte_limit_str)) { |
172 |
|
✗ |
params->file_mbyte_limit = String2Uint64(file_mbyte_limit_str); |
173 |
|
|
} |
174 |
|
|
|
175 |
|
✗ |
std::string upload_stats_db_str; |
176 |
|
✗ |
if (parser.GetValue("CVMFS_UPLOAD_STATS_DB", &upload_stats_db_str)) { |
177 |
|
✗ |
params->upload_stats_db = parser.IsOn(upload_stats_db_str); |
178 |
|
|
} else { |
179 |
|
✗ |
params->upload_stats_db = false; |
180 |
|
|
} |
181 |
|
|
|
182 |
|
✗ |
return true; |
183 |
|
|
} |
184 |
|
|
|
185 |
|
|
} // namespace receiver |
186 |
|
|
|