22#include <boost/program_options.hpp>
26bool initOptionsAndParse(bpo::options_description& options,
int argc,
char* argv[], bpo::variables_map& vm)
28 options.add_options()(
29 "host", bpo::value<std::string>()->default_value(
"ccdb-test.cern.ch:8080"),
"CCDB server")(
30 "path,p", bpo::value<std::string>()->required(),
"CCDB path")(
31 "file,f", bpo::value<std::string>()->required(),
"ROOT file")(
32 "key,k", bpo::value<std::string>()->required(),
"Key of object to upload")(
33 "meta,m", bpo::value<std::string>()->default_value(
""),
"List of key=value pairs for meta-information (k1=v1;k2=v2;k3=v3)")(
34 "starttimestamp,st", bpo::value<long>()->default_value(-1),
"timestamp - default -1 = now")(
35 "endtimestamp,et", bpo::value<long>()->default_value(-1),
"end of validity - default -1 = 1 day from now")(
36 "help,h",
"Produce help message.");
39 bpo::store(parse_command_line(argc, argv, options), vm);
42 if (vm.count(
"help")) {
43 std::cout << options << std::endl;
48 }
catch (
const bpo::error&
e) {
49 std::cerr <<
e.what() <<
"\n\n";
50 std::cerr <<
"Error parsing command line arguments; Available options:\n";
52 std::cerr << options << std::endl;
61 return src.erase(0,
src.find_first_not_of(
' '));
67 return src.erase(
src.find_last_not_of(
' ') + 1);
78std::vector<std::string>
splitString(
const std::string&
src,
char delim,
bool trim =
false)
80 std::stringstream ss(
src);
82 std::vector<std::string> tokens;
84 while (std::getline(ss, token, delim)) {
85 token = (trim ?
trimSpace(token) : token);
87 tokens.push_back(std::move(token));
96int main(
int argc,
char* argv[])
98 bpo::options_description options(
"Allowed options");
99 bpo::variables_map vm;
105 auto host = vm[
"host"].as<std::string>();
108 std::map<std::string, std::string>
filter;
109 long starttimestamp = vm[
"starttimestamp"].as<
long>();
110 if (starttimestamp == -1) {
113 long endtimestamp = vm[
"endtimestamp"].as<
long>();
114 if (endtimestamp == -1) {
115 constexpr long SECONDSPERDAY = 1 * 24 * 60 * 60;
119 auto filename = vm[
"file"].as<std::string>();
120 auto path = vm[
"path"].as<std::string>();
121 auto keyname = vm[
"key"].as<std::string>();
125 auto toKeyValPairs = [](std::vector<std::string>
const& tokens) {
126 std::vector<std::pair<std::string, std::string>> pairs;
128 for (
auto& token : tokens) {
130 if (keyval.size() != 2) {
135 std::pair<std::string, std::string> pair = std::make_pair(keyval[0],
trimSpace(keyval[1]));
136 pairs.push_back(pair);
141 auto metastring = vm[
"meta"].as<std::string>();
142 auto keyvalues = toKeyValPairs(
splitString(metastring,
';',
true));
145 std::map<std::string, std::string> meta;
146 for (
auto& p : keyvalues) {
147 meta[p.first] = p.second;
151 auto ent = meta.find(
"Redirect");
152 std::cout <<
" Uploading a headers-only object to path " <<
path <<
" with timestamp validity from " << starttimestamp <<
" to " << endtimestamp
153 <<
" Redirection to: " << ((ent != meta.end()) ? ent->second : std::string{
"none"}) <<
"\n";
155 if (!api.
isSnapshotMode() && meta.find(
"adjustableEOV") != meta.end() && meta.find(
"default") == meta.end()) {
161 auto key =
f.GetKey(keyname.c_str());
164 auto classname =
key->GetClassName();
165 auto tcl = TClass::GetClass(classname);
166 auto object =
f.Get<
void>(keyname.c_str());
167 if (tcl->InheritsFrom(
"TTree")) {
169 tree->LoadBaskets(0x1L << 32);
170 tree->SetDirectory(
nullptr);
174 auto ti = tcl->GetTypeInfo();
176 std::cout <<
" Uploading an object of type " <<
key->GetClassName()
177 <<
" to path " <<
path <<
" with timestamp validity from " << starttimestamp
178 <<
" to " << endtimestamp <<
"\n";
181 if (!api.
isSnapshotMode() && meta.find(
"adjustableEOV") != meta.end() && meta.find(
"default") == meta.end()) {
186 std::cerr <<
"Key " << keyname <<
" does not exist\n";
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
int storeAsTFile_impl(const void *obj1, std::type_info const &info, std::string const &path, std::map< std::string, std::string > const &metadata, long startValidityTimestamp=-1, long endValidityTimestamp=-1, std::vector< char >::size_type maxSize=0) const
void init(std::string const &hosts)
bool isSnapshotMode() const
int storeAsBinaryFile(const char *buffer, size_t size, const std::string &fileName, const std::string &objectType, const std::string &path, const std::map< std::string, std::string > &metadata, long startValidityTimestamp, long endValidityTimestamp, std::vector< char >::size_type maxSize=0) const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei const GLchar *const * path
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
int adjustOverriddenEOV(CcdbApi &api, const CcdbObjectInfo &infoNew)
set EOV of overriden objects to SOV-1 of overriding one if it is allowed
long getFutureTimestamp(int secondsInFuture)
returns the timestamp in long corresponding to "now + secondsInFuture"
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))