25 const std::string prefix1 =
"http://";
26 const std::string prefix2 =
"https://";
27 if (crest_path.starts_with(prefix1) || crest_path.starts_with(prefix2)){
50 std::string_view signature=
"payloadHash\":\"";
51 auto signaturePosition=jsonReply.rfind(signature);
52 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
53 auto startOfHash=signaturePosition + signature.size();
54 auto endOfHash=jsonReply.find(
'\"',startOfHash);
55 auto len=endOfHash-startOfHash;
56 if (startOfHash > jsonReply.size())
throw std::runtime_error(
"Hash start is beyond end of string");
57 hash=jsonReply.substr(startOfHash, len);
59 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the hash in "<<jsonReply<<std::endl;
69 std::string reply =
"";
76 reply = iov_list.dump();
78 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;
87 std::string reply =
"";
92 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the payload"<<std::endl;
104 const std::string_view signature=
"node_description\\\":\\\"";
105 const auto signaturePosition = jsonReply.find(signature);
106 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
107 const auto startOfDescription= signaturePosition + signature.size();
108 const std::string_view endSignature =
"\\\",\\\"payload_spec";
109 const auto endOfDescription=jsonReply.find(endSignature);
110 if (endOfDescription == std::string::npos)
throw std::runtime_error(
"end signature "+std::string(endSignature)+
" not found");
111 const auto len=endOfDescription-startOfDescription;
112 description=jsonReply.substr(startOfDescription, len);
114 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the description in "<<jsonReply<<std::endl;
124 std::string jsonReply =
"";
132 std::map<std::string, std::string>
134 std::map<std::string, std::string> tagmap;
140 for (
int i = 0;
i <
n;
i++ ){
142 if (j_item.contains(
"label") && j_item.contains(
"tagName") ){
143 tagmap[j_item[
"label"]] = j_item[
"tagName"];
147 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a global tag map for " <<
globaltag << std::endl;
159 if (meta_info.contains(
"tagInfo")){
160 std::string metainf = meta_info[
"tagInfo"];
166 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a tag meta info " <<
tag << std::endl;
177 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a tag Properties of " <<
tag << std::endl;
184 if (tag_info.contains(
key)){
185 if (
key ==
"channel_list"){
186 return tag_info[
key].dump();
187 }
else if (
key==
"node_description"){
189 tag_info[
key].get_to(
v);
198 std::pair<std::vector<cool::ChannelId> , std::vector<std::string>>
200 std::vector<cool::ChannelId>
list;
201 std::vector<std::string>
names;
205 for (
int i = 0;
i <=
n;
i++) {
207 for (
auto& [
key,
val] : j_object.items()){
208 list.push_back(std::stoll(
key));
214 auto isEmpty=[](
const std::string &
s){
return s.empty();};
216 return std::make_pair(std::move(
list), std::move(
names));
226 std::vector<uint64_t>
228 std::vector<uint64_t>
v;
233 v.emplace_back(item_iov.since);
236 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;
243 std::pair<uint64_t,uint64_t>
247 std::pair<uint64_t,uint64_t> answer = std::make_pair(0,0);
250 std::cerr <<
"Wrong since/until." << std::endl;
255 for (
int i = 0;
i <
N;
i++) {
262 for (
int i = 0;
i <
N;
i++) {
269 answer = std::make_pair(new_since,new_until);
279 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get the tag size for " <<
tagname << std::endl;
284 std::pair<uint64_t,uint64_t>
292 std::vector<IovHashPair>
294 std::vector<IovHashPair> iovHashPairs;
298 if (iovNumber <=1000) {
299 dto =
m_crestCl->selectIovs(
tag, 0, -1, 0, 10000, 0,
"id.since:ASC");
302 if (s_time == 0 && u_time == 0){
305 dto =
m_crestCl->selectIovs(
tag, s_time, u_time, 0, 10000, 0,
"id.since:ASC");
309 std::map<uint64_t, std::string> hashmap;
311 hashmap[
item.since] =
item.payloadHash;
313 for (
auto&
t : hashmap){
317 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;