41                                               uint64_t startTimestamp, uint64_t endTimestamp, 
bool verbose)
 
   43  std::set<uint64_t> tsChanges{startTimestamp};
 
   45  std::cout << std::endl;
 
   52    std::cout << fmt::format(
"\nlist of {} files potentially valid in the range {} - {}:\n", 
source, startTimestamp, endTimestamp);
 
   54  std::istringstream fileInfo(api.
list(
source, 
false, 
"text/plain"));
 
   59  uint64_t creation = 0;
 
   61  for (std::string line; std::getline(fileInfo, line);) {
 
   62    if (line.find(
"Validity:") == 0) {
 
   63      std::istringstream in(line);
 
   64      in >> dummy >> begin >> dummy >> 
end;
 
   65      if (begin < endTimestamp && end > startTimestamp) {
 
   66        if (begin >= startTimestamp) {
 
   67          tsChanges.emplace(begin);
 
   69        if (
end < endTimestamp) {
 
   70          tsChanges.emplace(
end);
 
   75      if (line.find(
"ID:") == 0) {
 
   76        std::istringstream in(line);
 
   78      } 
else if (inRange && line.find(
"Created:") == 0) {
 
   79        std::istringstream in(line);
 
   80        in >> dummy >> creation;
 
   81        std::cout << fmt::format(
"- {}\n", 
path);
 
   82        std::cout << fmt::format(
"  validity range: {} - {}\n", begin, 
end);
 
   83        std::cout << fmt::format(
"  creation time: {}\n", creation);
 
   89    std::cout << fmt::format(
"\nlist of timestamps when the bad channels potentially change:\n");
 
   90    for (
auto ts : tsChanges) {
 
   91      std::cout << fmt::format(
"  {}\n", ts);
 
   97    std::cout << fmt::format(
"\nlist of {} files actually valid in the range {} - {}:\n", 
source, startTimestamp, endTimestamp);
 
   99  std::map<std::string, std::string> metadata{};
 
  100  std::string currentETag{};
 
  101  for (
auto itTS = tsChanges.begin(); itTS != tsChanges.end();) {
 
  103    if (headers[
"ETag"].
empty()) {
 
  104      std::cout << 
"- Warning: missing file" << std::endl;
 
  105      auto validUntil = (std::next(itTS) != tsChanges.end()) ? *std::next(itTS) : endTimestamp;
 
  106      std::cout << fmt::format(
"  validity range: {} - {}\n", *itTS, validUntil);
 
  108    } 
else if (headers[
"ETag"] == currentETag) {
 
  109      itTS = tsChanges.erase(itTS);
 
  112        std::cout << fmt::format(
"- {}\n", headers[
"Location"]);
 
  113        std::cout << fmt::format(
"  validity range: {} - {}\n", headers[
"Valid-From"], headers[
"Valid-Until"]);
 
  114        std::cout << fmt::format(
"  creation time: {}\n", headers[
"Created"]);
 
  116      currentETag = headers[
"ETag"];
 
  120  std::cout << fmt::format(
"\nlist of timestamps when the bad channels actually change:\n");
 
  121  for (
auto ts : tsChanges) {
 
  122    std::cout << fmt::format(
"  {}\n", ts);
 
 
  228                       const std::string badChannelType,
 
  229                       uint64_t startTimestamp,
 
  230                       uint64_t endTimestamp,
 
  234  std::sort(bv.begin(), bv.end());
 
  235  bv.erase(std::unique(bv.begin(), bv.end()), bv.end());
 
  237  std::cout << std::endl;
 
  240  std::map<std::string, std::string> md;
 
  241  auto dest = 
ccdbPath(badChannelType);
 
  242  std::cout << fmt::format(
"storing {} {}bad channels (valid from {} to {}) to {}\n", bv.size(),
 
  243                           makeDefault ? 
"default " : 
"", startTimestamp, endTimestamp, dest);
 
  246    md[
"default"] = 
"true";
 
 
  254  po::variables_map vm;
 
  255  po::options_description 
usage(
"Usage");
 
  258  std::string ccdbRefUrl;
 
  259  std::string dpConfName;
 
  260  std::string badChannelType;
 
  261  uint64_t startTimestamp;
 
  262  uint64_t endTimestamp;
 
  269  auto tnow = std::chrono::system_clock::now().time_since_epoch();
 
  270  using namespace std::chrono_literals;
 
  271  auto tend = tnow + 24
h;
 
  273  uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(tnow).count();
 
  274  uint64_t 
end = std::chrono::duration_cast<std::chrono::milliseconds>(tend).count();
 
  278      (
"help,h", 
"produce help message")
 
  279      (
"ccdb,c",po::value<std::string>(&
ccdbUrl)->default_value(
"http://localhost:6464"),
"ccdb url")
 
  280      (
"starttimestamp",po::value<uint64_t>(&startTimestamp)->default_value(now),
"timestamp for query or put - (default=now)")
 
  281      (
"endtimestamp", po::value<uint64_t>(&endTimestamp)->default_value(
end), 
"end of validity (for put) - default=1 day from now")
 
  282      (
"list,l", po::bool_switch(&
list),
"list timestamps, within the given range, when the bad channels change")
 
  283      (
"put,p",po::bool_switch(&put),
"upload bad channel object")
 
  284      (
"referenceccdb,r",po::value<std::string>(&ccdbRefUrl)->default_value(
"http://alice-ccdb.cern.ch"),
"reference ccdb url")
 
  285      (
"upload-default-values,u",po::bool_switch(&uploadDefault),
"upload default values")
 
  286      (
"type,t",po::value<std::string>(&badChannelType)->default_value(
"BadChannel"),
"type of bad channel (BadChannel or RejectList)")
 
  287      (
"query,q",po::bool_switch(&query),
"dump bad channel object from CCDB")
 
  288      (
"verbose,v",po::bool_switch(&verbose),
"verbose output")
 
  289      (
"solar,s",po::value<std::vector<uint16_t>>()->multitoken(),
"solar ids to reject")
 
  290      (
"ds,d", po::value<std::vector<uint16_t>>()->multitoken(), 
"dual sampas indices to reject")
 
  291      (
"de,e", po::value<std::vector<uint16_t>>()->multitoken(), 
"DE ids to reject")
 
  292      (
"alias,a", po::value<std::vector<std::string>>()->multitoken(), 
"DCS alias (HV or LV) to reject")
 
  296  po::options_description cmdline;
 
  299  po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
 
  301  if (vm.count(
"help")) {
 
  302    std::cout << 
"This program get/set MCH bad channels CCDB object\n";
 
  303    std::cout << 
usage << 
"\n";
 
  309  } 
catch (boost::program_options::error& e) {
 
  310    std::cout << 
"Error: " << e.what() << 
"\n";
 
  314  if (badChannelType != 
"BadChannel" && badChannelType != 
"RejectList") {
 
  315    std::cout << 
"Error: badChannelType " << badChannelType << 
" is invalid. Only BadChannel or RejectList are legit\n";
 
  329    if (vm.count(
"solar")) {
 
  330      rejectSolars(vm[
"solar"].as<std::vector<uint16_t>>(), bv);
 
  332    if (vm.count(
"ds")) {
 
  333      rejectDSs(vm[
"ds"].as<std::vector<uint16_t>>(), bv);
 
  335    if (vm.count(
"de")) {
 
  336      rejectDEs(vm[
"de"].as<std::vector<uint16_t>>(), bv);
 
  338    if (vm.count(
"alias")) {
 
  339      rejectHVLVs(vm[
"alias"].as<std::vector<std::string>>(), bv);
 
  347      std::cout << fmt::format(
"\n{} object{} valid in the reference CCDB ({}) for this time range. What do you want to do?\n",
 
  348                               tsChanges.size(), (tsChanges.size() > 1) ? 
"s are" : 
" is", ccdbRefUrl);
 
  349      std::cout << fmt::format(
"[a] abort: do nothing\n");
 
  350      std::cout << fmt::format(
"[o] overwrite: create 1 new object for the whole time range to supersede the existing one{}\n",
 
  351                               (tsChanges.size() > 1) ? 
"s" : 
"");
 
  352      std::cout << fmt::format(
"[u] update: create {} new object{} within the time range adding new bad channels to existing ones\n",
 
  353                               tsChanges.size(), (tsChanges.size() > 1) ? 
"s" : 
"");
 
  354      std::string response{};
 
  355      std::cin >> response;
 
  357      if (response == 
"a" || response == 
"abort") {
 
  359      } 
else if (response == 
"o" || response == 
"overwrite") {
 
  361      } 
else if (response == 
"u" || response == 
"update") {
 
  362        tsChanges.emplace(endTimestamp);
 
  363        auto itStartTS = tsChanges.begin();
 
  364        for (
auto itStopTS = std::next(itStartTS); itStopTS != tsChanges.end(); ++itStartTS, ++itStopTS) {
 
  366          bv2.insert(bv2.end(), bv.begin(), bv.end());
 
  370        std::cout << 
"invalid response (must be a, o or u) --> abort\n";
 
 
std::enable_if<!std::is_base_of< o2::conf::ConfigurableParam, T >::value, T * >::type retrieveFromTFileAny(std::string const &path, std::map< std::string, std::string > const &metadata, long timestamp=-1, std::map< std::string, std::string > *headers=nullptr, std::string const &etag="", const std::string &createdNotAfter="", const std::string &createdNotBefore="") const