Skip to content

Commit 31fc2a3

Browse files
committed
CCDB-download tool: allow downloading batches
for connection sharing and reduced overhead (useful for prefetching lot's of objects from CCDB)
1 parent 2b7d1fa commit 31fc2a3

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

CCDB/src/DownloadCCDBFile.cxx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv
2323
{
2424
options.add_options()(
2525
"host", bpo::value<std::string>()->default_value("ccdb-test.cern.ch:8080"), "CCDB server")(
26-
"path,p", bpo::value<std::string>(), "CCDB path (identifies the object)")(
26+
"path,p", bpo::value<std::vector<std::string>>()->multitoken(), "CCDB path (identifies the object) [or space separated list of paths for batch processing]")(
2727
"dest,d", bpo::value<std::string>()->default_value("./"), "destination path")(
2828
"no-preserve-path", "Do not preserve path structure. If not set, the full path structure -- reflecting the '--path' argument will be put.")(
29-
"outfile,o", bpo::value<std::string>()->default_value("snapshot.root"), "Name of output file. If set to \"\", the name will be determined from the uploaded content.")(
29+
"outfile,o", bpo::value<std::string>()->default_value("snapshot.root"), "Name of output file. If set to \"\", the name will be determined from the uploaded content. (Will be the same in case of batch downloading multiple paths.)")(
3030
"timestamp,t", bpo::value<long>()->default_value(-1), "timestamp in ms - default -1 = now")(
3131
"help,h", "Produce help message.");
3232

@@ -68,13 +68,21 @@ int main(int argc, char* argv[])
6868
if (timestamp == -1) {
6969
timestamp = o2::ccdb::getCurrentTimestamp();
7070
}
71-
auto path = vm["path"].as<std::string>();
71+
auto paths = vm["path"].as<std::vector<std::string>>();
7272
auto dest = vm["dest"].as<std::string>();
73+
if (paths.size() == 0) {
74+
std::cerr << "No path given";
75+
return 1;
76+
}
7377

74-
std::cout << "Querying host " << host << " for path " << path << " and timestamp " << timestamp << "\n";
78+
std::cout << "Querying host " << host << " for path(s) " << paths[0] << " ... and timestamp " << timestamp << "\n";
7579
bool no_preserve_path = vm.count("no-preserve-path") == 0;
7680
auto filename = vm["outfile"].as<std::string>();
77-
auto success = api.retrieveBlob(path, dest, filter, timestamp, no_preserve_path, filename);
7881

82+
bool success = true;
83+
for (auto& p : paths) {
84+
// could even multi-thread this
85+
success |= api.retrieveBlob(p, dest, filter, timestamp, no_preserve_path, filename);
86+
}
7987
return success ? 0 : 1;
8088
}

0 commit comments

Comments
 (0)