35 std::string abs_path = lease_path.
ToString();
36 std::string::const_iterator it =
37 std::find(abs_path.begin(), abs_path.end(),
'/');
38 if (it != abs_path.end()) {
39 size_t idx = it - abs_path.begin() + 1;
40 return lease_path.
Suffix(idx);
48 const std::string& manifest_path,
49 const std::string& public_key_path,
50 const std::string& proxy) {
53 args[
'w'].Reset(
new std::string(params.
stratum0));
54 args[
't'].Reset(
new std::string(temp_dir));
55 args[
'm'].Reset(
new std::string(manifest_path));
56 args[
'p'].Reset(
new std::string(public_key_path));
57 args[
'f'].Reset(
new std::string(repo_name));
59 args[
'a'].Reset(
new std::string(repo_tag.
name()));
60 args[
'D'].Reset(
new std::string(repo_tag.
description()));
61 args[
'x'].Reset(
new std::string());
62 args[
'@'].Reset(
new std::string(proxy));
66 const int ret = edit_cmd->
Main(args);
70 repo_tag.
name().c_str());
102 const std::string& lease_path,
const shash::Any& old_root_hash,
104 uint64_t *final_revision) {
112 "CommitProcessor - lease_path: %s, old hash: %s, new hash: %s, "
113 "tag_name: %s, tag_description: %s",
114 lease_path.c_str(), old_root_hash.
ToString(
true).c_str(),
115 new_root_hash.
ToString(
true).c_str(), final_tag.
name().c_str(),
118 const std::vector<std::string> lease_path_tokens =
121 const std::string repo_name = lease_path_tokens.front();
127 "CommitProcessor - error: Could not get configuration parameters.");
136 "CommitProcessor - error: Could not initialize the download manager");
140 const std::string public_key =
"/etc/cvmfs/keys/" + repo_name +
".pub";
141 const std::string certificate =
"/etc/cvmfs/keys/" + repo_name +
".crt";
142 const std::string private_key =
"/etc/cvmfs/keys/" + repo_name +
".key";
147 "CommitProcessor - error: Could not initialize the signature manager");
154 params.
stratum0, repo_name, manifest_base_hash));
157 if (!manifest_tgt.IsValid()) {
159 "CommitProcessor - error: Could not open repository manifest");
164 "CommitProcessor - lease_path: %s, target root hash: %s",
166 manifest_tgt->catalog_hash().ToString(
false).c_str());
169 std::string cache_dir_;
171 cache_dir_ =
"/var/spool/cvmfs/" + repo_name +
"/cache.server";
174 const std::string spooler_temp_dir =
176 assert(!spooler_temp_dir.empty());
178 const std::string temp_dir_root =
179 spooler_temp_dir +
"/receiver/commit_processor";
184 "CommitProcessor - lease_path: %s, merging catalogs",
189 merge_tool(params.
stratum0, old_root_hash, new_root_hash,
190 relative_lease_path, temp_dir_root,
193 if (!merge_tool.Init()) {
195 "Error: Could not initialize the catalog merge tool");
199 std::string new_manifest_path;
201 if (!merge_tool.Run(params, &new_manifest_path, &new_manifest_hash, final_revision)) {
203 "CommitProcessor - error: Catalog merge failed");
208 const std::string
temp_dir = raii_temp_dir->dir();
210 if (!
CreateNewTag(final_tag, repo_name, params, temp_dir, new_manifest_path,
211 public_key, params.
proxy)) {
213 final_tag.
name().c_str());
218 "CommitProcessor - lease_path: %s, signing manifest",
223 std::vector<shash::Any> reflog_catalogs;
224 reflog_catalogs.push_back(new_root_hash);
229 temp_dir, certificate, private_key, repo_name,
"",
"",
230 "/var/spool/cvmfs/" + repo_name +
"/reflog.chksum", params.
proxy,
235 "CommitProcessor - error: missing reflog.chksum");
239 "CommitProcessor - error: missing reflog");
244 "CommitProcessor - error: signing manifest");
248 "CommitProcessor - lease_path: %s, success.",
253 "CommitProcessor - lease_path: %s, new root hash: %s",
255 new_manifest_hash.
ToString(
false).c_str());
259 const std::string fname =
"/var/spool/cvmfs/" + repo_name +
"/client.local";
260 if (truncate(fname.c_str(), 0) < 0) {
267 if (stats_db != NULL) {
270 "Could not store publish statistics");
274 upload::Spooler *
spooler = upload::Spooler::Construct(sd);
277 "Could not upload statistics DB to upstream storage");
291 const std::string &start_time)
Counter * Register(const std::string &name, const std::string &desc)
SharedPtr< string > temp_dir
std::string description() const
std::string spooler_configuration
bool UploadStatistics(upload::Spooler *spooler, std::string local_path="")
ShortString Suffix(const unsigned start_at) const
perf::Statistics * statistics_
std::string ToString(const bool with_suffix=false) const
int Main(const ArgumentList &args)
bool GetParamsFromFile(const std::string &repo_name, Params *params)
perf::Statistics * statistics_
assert((mem||(size==0))&&"Out Of Memory")
std::string GetSpoolerTempDir(const std::string &spooler_config)
upload::Spooler * spooler
bool CreateNewTag(const RepositoryTag &repo_tag, const std::string &repo_name, const receiver::Params ¶ms, const std::string &temp_dir, const std::string &manifest_path, const std::string &public_key_path, const std::string &proxy)
vector< string > SplitString(const string &str, char delim)
static RaiiTempDir * Create(const std::string &prefix)
bool MkdirDeep(const std::string &path, const mode_t mode, bool verify_writable)
PathString RemoveRepoName(const PathString &lease_path)
static StatisticsDatabase * OpenStandardDB(const std::string repo_name)
void SetStatistics(perf::Statistics *st, const std::string &start_time)
bool StorePublishStatistics(const perf::Statistics *statistics, const std::string &start_time, const bool success)
std::string ToString() const
virtual ~CommitProcessor()
std::map< char, SharedPtr< std::string > > ArgumentList
ShortString< kDefaultMaxPath, 0 > PathString
Result Process(const std::string &lease_path, const shash::Any &old_root_hash, const shash::Any &new_root_hash, const RepositoryTag &tag, uint64_t *final_revision)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)