|
ATLAS Offline Software
|
#include <CrestApi.h>
|
| CrestClient (const std::string &host, const std::string &port, bool checkVersion=false) |
| CrestClient constructor. More...
|
|
| CrestClient (std::string_view url, bool checkVersion=false) |
| CrestClient constructor. More...
|
|
| ~CrestClient () |
| CrestClient destructor. More...
|
|
void | checkCrestVersion () |
| This method is a CREST version test. More...
|
|
void | createGlobalTag (GlobalTagDto &globalTag) override |
| This method creates a global tag on CREST server. More...
|
|
GlobalTagDto | findGlobalTag (const std::string &name) override |
| This method finds a global tag by name on the CREST server. More...
|
|
GlobalTagSetDto | listGlobalTags (const std::string &name, int size, int page, const std::string &sort) override |
| This method finds the global tags on the CREST server. More...
|
|
void | removeGlobalTag (const std::string &name) override |
| This method removes a global tag on the CREST server. More...
|
|
void | createTag (TagDto &tag) override |
| This method creates a tag on the CREST server. More...
|
|
TagDto | findTag (const std::string &name) override |
| This method finds a tag by the name on the CREST server. More...
|
|
TagSetDto | listTags (const std::string &name, int size, int page, const std::string &sort) override |
| This method returns the tag list as TagSetDto from the CREST server. More...
|
|
void | removeTag (const std::string &name) override |
| This method removes a tag from the CREST server. More...
|
|
int | getSize (const std::string &tagname) override |
| This method gets the number of IOVs for the given tag. More...
|
|
void | createTagMeta (TagMetaDto &tag) override |
| This method creates a tag meta info on the CREST server. More...
|
|
void | updateTagMeta (TagMetaDto &tag) override |
| This method updates a tag meta info on the CREST server. More...
|
|
TagMetaDto | findTagMeta (const std::string &name) override |
| This method reads a tag meta info by the tag name from the CREST server. More...
|
|
void | createGlobalTagMap (GlobalTagMapDto &globalTagMap) override |
| This method creates a global tag map on the CREST server. More...
|
|
GlobalTagMapSetDto | findGlobalTagMap (const std::string &name, const std::string &xCrestMapMode) override |
| This method searches for tag mappings using the global tag name or tag name on the CREST server. More...
|
|
void | removeGlobalTagMap (const std::string &name, const std::string &record, const std::string &label, const std::string &tagname) override |
| This method removes a global tag map on the CREST server. More...
|
|
IovSetDto | selectIovs (const std::string &name, uint64_t since, uint64_t until, long snapshot, int size, int page, const std::string &sort) override |
| This method selects IOVs for a given tagname on the CREST server. More...
|
|
IovSetDto | selectGroups (const std::string &name, long snapshot, int size, int page, const std::string &sort) override |
| This method returns IOV groups for a given tagname on CREST server. More...
|
|
void | storeData (const std::string &tag, const StoreSetDto &storeSetJson, const std::string &payloadFormat="JSON", const std::string &objectType="none", const std::string &compressionType="none", const std::string &version="1.0", uint64_t endTime=-1) override |
| This method stores several payloads in batch mode on the CREST server. More...
|
|
std::string | getPayload (const std::string &hash) override |
| This method finds a payload resource associated to the hash on the CREST server. More...
|
|
PayloadDto | getPayloadMeta (const std::string &hash) override |
| This method finds a payload meta info for the hash on the CREST server. More...
|
|
Definition at line 32 of file CrestApi.h.
◆ CrestClient() [1/2]
Crest::CrestClient::CrestClient |
( |
const std::string & |
_host, |
|
|
const std::string & |
_port, |
|
|
bool |
check_version = false |
|
) |
| |
CrestClient constructor.
CrestClient constructor for Internet mode.
- Parameters
-
host | - host name of the CREST Server. |
port | - port of the CREST Server. |
check_version | - the parameter to switch CREST version checking, if this parameter is true, the CREST version test will be executed. |
If CrestClient is created with this method the data will be sent to the CREST Server.
- Parameters
-
_host | - host name of the CREST Server. |
_port | - port of the CREST Server. |
check_version | - the parameter to switch CREST version checking, if this parameter is true, the CREST version test will be executed. |
Definition at line 36 of file CrestApi.cxx.
38 if (check_version ==
true)
◆ CrestClient() [2/2]
Crest::CrestClient::CrestClient |
( |
std::string_view |
url, |
|
|
bool |
check_version = false |
|
) |
| |
CrestClient constructor.
CrestClient constructor for Internet mode.
- Parameters
-
url | - URL address of the CREST Server (with port). |
check_version | - the parameter to switch CREST version checking, if this parameter is true, the CREST version test will be executed.
|
Example:
std::string url = "http://mvg-test-pc-03.cern.ch:8090";
CrestClient myCrestClient = CrestClient(url);
If CrestClient is created with this method the data will be sent to the CREST Server.
- Parameters
-
url | - URL address of the CREST Server (with port). |
check_version | - the parameter to switch CREST version checking, if this parameter is true, the CREST version test will be executed.
Example:
std::string url = "http://mvg-test-pc-03.cern.ch:8090";
CrestClient myCrestClient = CrestClient(url);
|
Definition at line 61 of file CrestApi.cxx.
63 size_t found =
url.find_first_of(
':');
64 size_t n =
url.size();
66 std::string_view url_new =
url.substr(
found + 3);
69 size_t found1 = url_new.find_first_of(
':');
70 size_t found2 = url_new.find_first_of(
'/');
72 std::string_view host;
73 std::string_view port;
74 std::string_view resources;
75 if (found1 != std::string::npos && found2 != std::string::npos) {
76 host = url_new.substr(0, found1);
77 port = url_new.substr(found1 + 1, found2 - found1 - 1);
78 }
else if (found1 != std::string::npos) {
79 host = url_new.substr(0, found1);
80 port = url_new.substr(found1 + 1);
81 }
else if (found2 != std::string::npos) {
86 host = url_new.substr(0, found2);
97 resources = url_new.substr(found2,
n - 1);
101 m_port = std::string(port);
102 m_host = std::string(host);
107 if (check_version ==
true)
111 std::cout <<
"CrestClient::CrestClient: host = " <<
m_host <<
", port = " <<
m_port <<
", path = " <<
m_PATH << std::endl;
◆ ~CrestClient()
Crest::CrestClient::~CrestClient |
( |
| ) |
|
◆ checkCrestVersion()
void Crest::CrestClient::checkCrestVersion |
( |
| ) |
|
This method is a CREST version test.
It checks if the major CREST server is equal to the major CrestApi vesrion. If the versions are different an error is thrown.
- Exceptions
-
std::runtime_error | - error, if the versions are different. |
Definition at line 259 of file CrestApi.cxx.
267 if (clientVersion != serverVersion)
269 throw CrestException(
"ERROR in CrestClient::checkCrestVersion: CrestApi version \"" +
client +
"\" does not correspond to the server version \"" +
server +
"\".");
◆ checkHash()
void Crest::CrestClient::checkHash |
( |
const std::string & |
hash, |
|
|
const std::string & |
str, |
|
|
const char * |
method_name |
|
) |
| |
|
private |
This checks the hash of payload from IOV (hash) with the hash calculated for the payload in the std::string (str) (It is an auxiliary method to check the payload.)
- Parameters
-
hash | - the hash from an IOV. |
str | - the payload in std::string. |
Definition at line 795 of file CrestApi.cxx.
798 if (
hash != calculatedHash) {
799 throw CrestException(
"ERROR in " + (std::string)method_name +
": payload is corrupted.");
◆ createGlobalTag()
void Crest::CrestClient::createGlobalTag |
( |
GlobalTagDto & |
globalTag | ) |
|
|
overridevirtual |
This method creates a global tag on CREST server.
- Parameters
-
Example:
nlohmann::json js =
{
{"name", tagname},
{"validity", 0},
{"description", "test"},
{"release", "1"},
{"insertionTime", "2018-12-18T11:32:58.081+0000"},
{"snapshotTime", "2018-12-18T11:32:57.952+0000"},
{"scenario", "test"},
{"workflow", "M"},
{"type", "t"},
};
GlobalTagDto dto = GlobalTagDto();
dto = dto.from_json(js);
myCrestClient.createGlobalTag(dto);
Implements Crest::CrestApiBase.
Definition at line 284 of file CrestApi.cxx.
286 const char *method_name =
"CrestClient::createGlobalTag";
288 std::string current_path =
m_PATH;
◆ createGlobalTagMap()
void Crest::CrestClient::createGlobalTagMap |
( |
GlobalTagMapDto & |
globalTagMap | ) |
|
|
overridevirtual |
This method creates a global tag map on the CREST server.
- Parameters
-
Example:
nlohmann::json js =
{
{"globalTagName", globaltag},
{"record", "testing2"},
{"label", "test2"},
{"tagName", tagname}
};
GlobalTagMapDto globalTagMap = GlobalTagMapDto();
globalTagMap = globalTagMap.from_json(js);
myCrestClient.createGlobalTagMap(globalTagMap);
Implements Crest::CrestApiBase.
Definition at line 554 of file CrestApi.cxx.
556 const char *method_name =
"CrestClient::createGlobalTagMap";
558 std::string current_path =
m_PATH;
◆ createTag()
void Crest::CrestClient::createTag |
( |
TagDto & |
tag | ) |
|
|
overridevirtual |
This method creates a tag on the CREST server.
- Parameters
-
Example:
nlohmann::json js =
{
{"name", tagname},
{"timeType", "time"},
{"description", "test"},
{"synchronization", "none"},
{"insertionTime", "2018-12-18T11:32:58.081+0000"},
{"modificationTime", "2018-12-18T11:32:57.952+0000"},
{"payloadSpec", "JSON"},
{"lastValidatedTime", 0.},
{"endOfValidity", 0.},
};
TagDto dto = TagDto();
dto = dto.from_json(js);
myCrestClient.createTag(dto);
Implements Crest::CrestApiBase.
Definition at line 374 of file CrestApi.cxx.
376 const char *method_name =
"CrestClient::createTag";
378 std::string current_path =
m_PATH;
◆ createTagMeta()
void Crest::CrestClient::createTagMeta |
( |
TagMetaDto & |
tag | ) |
|
|
overridevirtual |
This method creates a tag meta info on the CREST server.
- Parameters
-
Example:
nlohmann::json channel = {{"0", "ATLAS_PREFERRED"}};
nlohmann::json chanList = nlohmann::json::array({channel});
nlohmann::json tagInfo =
{
{"channel_list", chanList},
{"node_description", "description of the node"},
{"payload_spec", "stave:Int32, eta:Int32, mag:Float, base:Float, free:Float"}};
nlohmann::json js =
{
{"tagName", tagname},
{"description", "none"},
{"chansize", 1},
{"colsize", 6},
{"tagInfo", tagInfo.dump()},
{"insertionTime", "2020-12-04"}};
TagMetaDto dto = TagMetaDto();
dto = dto.from_json(js);
myCrestClient.createTagMeta(dto);
Implements Crest::CrestApiBase.
Definition at line 464 of file CrestApi.cxx.
466 const char *method_name =
"CrestClient::createTagMeta";
468 std::string current_path =
m_PATH;
471 current_path += dto.tagName;
◆ findGlobalTag()
This method finds a global tag by name on the CREST server.
Only one global tag should be returned. (This method is an analogue of the find_global_tag method in Python)
- Parameters
-
- Returns
- global tag as GlobalTagDto.
Implements Crest::CrestApiBase.
Definition at line 295 of file CrestApi.cxx.
297 const char *method_name =
"CrestClient::findGlobalTag";
299 std::string current_path =
m_PATH;
302 current_path +=
name;
◆ findGlobalTagMap()
This method searches for tag mappings using the global tag name or tag name on the CREST server.
(This method is an analogue of the find_global_tag_map method in Python)
- Parameters
-
name | - name of a global tag or a tag |
xCrestMapMode | - search mode (Trace or BackTrace). If it is set as "Trace" the global tag name will be used for searching, otherwise - the tag name. |
- Returns
- global tag map list as GlobalTagMapSetDto.
Implements Crest::CrestApiBase.
Definition at line 565 of file CrestApi.cxx.
567 const char *method_name =
"CrestClient::findGlobalTagMap";
569 std::string current_path =
m_PATH;
572 current_path +=
name;
573 std::string headers_params =
"";
575 if (xCrestMapMode !=
"")
577 headers_params +=
"X-Crest-MapMode: ";
578 headers_params += xCrestMapMode;
582 headers_params +=
"X-Crest-MapMode: ";
583 headers_params +=
"Trace";
◆ findTag()
TagDto Crest::CrestClient::findTag |
( |
const std::string & |
name | ) |
|
|
overridevirtual |
This method finds a tag by the name on the CREST server.
(This method is an analogue of the find_tag method in Python)
- Parameters
-
- Returns
- tag as TagDto object.
Implements Crest::CrestApiBase.
Definition at line 386 of file CrestApi.cxx.
388 const char *method_name =
"CrestClient::findTag";
390 std::string current_path =
m_PATH;
393 current_path +=
name;
◆ findTagMeta()
This method reads a tag meta info by the tag name from the CREST server.
- Parameters
-
- Returns
- tag meta info as a TagMetaDto.
Implements Crest::CrestApiBase.
Definition at line 494 of file CrestApi.cxx.
496 const char *method_name =
"CrestClient::findTagMeta";
498 std::string current_path =
m_PATH;
501 current_path +=
name;
◆ getClientVersion()
const std::string & Crest::CrestApiBase::getClientVersion |
( |
| ) |
|
|
protectedinherited |
This method returns the full CrestApi version.
- Returns
- CrestApi library version.
Definition at line 38 of file CrestApiBase.cxx.
◆ getCrestVersion()
std::string Crest::CrestClient::getCrestVersion |
( |
| ) |
|
|
overrideprivatevirtual |
This method returns the full CREST Server version.
- Returns
- CREST server version.
Implements Crest::CrestApiBase.
Definition at line 214 of file CrestApi.cxx.
224 buildInfo =
info[
"build"];
225 version = buildInfo[
"version"];
229 throw CrestException(
"ERROR in CrestClient::getCrestVersion: " +
to_string(
info) +
" does not contain version info.");
◆ getHash()
std::string Crest::CrestApiBase::getHash |
( |
std::string_view |
str | ) |
|
|
protectedinherited |
This method method calculates the hash for string.
- Parameters
-
- Returns
- hash for a given string.
Definition at line 32 of file CrestApiBase.cxx.
◆ getHashForFile()
std::string Crest::CrestApiBase::getHashForFile |
( |
const std::string & |
file | ) |
|
|
protectedinherited |
This method method calculates the hash for a file.
- Parameters
-
file | - path to the file with the file name.. |
- Returns
- hash for a given file.
Definition at line 8 of file CrestApiBase.cxx.
10 std::ifstream ifs(
file);
14 "ERROR in CrestFsClient::getHashForFile cannot open file \"" +
file +
"\".");
18 std::vector<char>
buffer(1024 * 1024);
19 while (ifs.read(
buffer.data(),
static_cast<std::streamsize
>(
buffer.size())))
◆ getJson()
Auxiliary method to convert string in to JSON object.
CrestClient::getJson method is used to convert the string to the json object.
- Parameters
-
str | - string (std::string) |
method | - method name, which calls this method. This parameter is used to throw an error exception. |
- Returns
- - JSON object as nlohmann::json
- Parameters
-
str | - string to be converted to the json object. |
method | - name of the method which calls this method. |
- Returns
- json object.
Definition at line 169 of file CrestApi.cxx.
176 catch (nlohmann::json::parse_error &
e)
182 std::string
wh =
e.what();
183 throw CrestException(
"ERROR in JSON conversion: " +
wh +
" | In string: " +
str);
189 throw CrestException(
"ERROR in " + std::string(
method) +
" | CREST Server response : " + str3);
194 throw CrestException(
"ERROR in CrestClient::" + (std::string)
method +
": " +
e.what());
◆ getMajorVersion()
int Crest::CrestClient::getMajorVersion |
( |
std::string & |
str | ) |
|
|
private |
This is an auxiliary method to extract a major version number from full version string.
- Returns
- major version number.
Definition at line 235 of file CrestApi.cxx.
238 int n =
str.find(
'.');
242 throw CrestException(
"ERROR in CrestClient::getMajorVersion: string \"" +
str +
"\" does not contain major version.");
245 std::string vers =
str.substr(0,
n);
253 throw CrestException(
"ERROR in CrestClient::getMajorVersion: string \"" +
str +
"\" does not contain major version.");
◆ getMgmtInfo()
This is an auxiliary method to read the CREST Server properties.
- Returns
- JSON with CREST server properties.
Example:
{
"build":{
"artifact":"crestdb",
"name":"crestdb",
"time":"2023-12-02T15:21:57.045Z",
"version":"4.2.1",
"group":"hep.crest"
}
}
Definition at line 199 of file CrestApi.cxx.
201 const char *method_name =
"getMgmtInfo";
◆ getPayload()
std::string Crest::CrestClient::getPayload |
( |
const std::string & |
hash | ) |
|
|
overridevirtual |
This method finds a payload resource associated to the hash on the CREST server.
The payload returns as a string. (This method is an analogue of the get_payload method in Python)
- Parameters
-
- Returns
- payload as a std::string
Implements Crest::CrestApiBase.
Definition at line 760 of file CrestApi.cxx.
762 const char *method_name =
"CrestClient::getPayload";
764 std::string current_path =
m_PATH;
766 current_path +=
"/data?format=BLOB&hash=";
767 current_path +=
hash;
◆ getPayloadMeta()
This method finds a payload meta info for the hash on the CREST server.
(This method is an analogue of the get_payload_meta method in Python)
- Parameters
-
- Returns
- payload meta info as PayloadDto.
Implements Crest::CrestApiBase.
Definition at line 775 of file CrestApi.cxx.
777 const char *method_name =
"CrestClient::getPayloadMeta";
779 std::string current_path =
m_PATH;
782 current_path +=
hash;
783 current_path +=
"?format=META";
◆ getSize()
int Crest::CrestClient::getSize |
( |
const std::string & |
tagname | ) |
|
|
overridevirtual |
This method gets the number of IOVs for the given tag.
(This method is an analogue of the get_size method in Python)
- Parameters
-
- Returns
- IOV number.
Implements Crest::CrestApiBase.
Definition at line 515 of file CrestApi.cxx.
517 const char *method_name =
"CrestClient::getSize";
519 std::string current_path =
m_PATH;
522 current_path +=
"?tagname=";
531 auto res = respond.find(
"resources");
534 if (
res != respond.end())
536 r = respond[
"resources"][0];
540 if (
r.find(
"niovs") !=
r.end())
546 throw CrestException(
"ERROR in CrestClient::getSize CREST Server JSON response has no \"size\" key.");
◆ listGlobalTags()
GlobalTagSetDto Crest::CrestClient::listGlobalTags |
( |
const std::string & |
name, |
|
|
int |
size, |
|
|
int |
page, |
|
|
const std::string & |
sort |
|
) |
| |
|
overridevirtual |
This method finds the global tags on the CREST server.
- Parameters
-
name | - global tag name pattern, "%" can be used for any symbols, |
size | - page size, |
page | - page number, |
sort | - sorting order (name:ASC or name:DESC), |
- Returns
- global tag list as GlobalTagSetDto.
Implements Crest::CrestApiBase.
Definition at line 315 of file CrestApi.cxx.
317 const char *method_name =
"CrestClient::listGlobalTags";
319 std::string current_path =
m_PATH;
324 current_path +=
"name=";
325 current_path +=
name;
330 current_path +=
"size=";
336 current_path +=
"page=";
342 current_path +=
"sort=";
343 current_path +=
sort;
◆ listTags()
TagSetDto Crest::CrestClient::listTags |
( |
const std::string & |
name, |
|
|
int |
size, |
|
|
int |
page, |
|
|
const std::string & |
sort |
|
) |
| |
|
overridevirtual |
This method returns the tag list as TagSetDto from the CREST server.
(This method is an analogue of the list_tags method in Python)
- Parameters
-
name | - tag name pattern, |
size | - page size, |
page | - page number, |
sort | - sorting order (name:ASC or name:DESC). |
- Returns
- tag list as TagSetDto object.
Implements Crest::CrestApiBase.
Definition at line 405 of file CrestApi.cxx.
407 const char *method_name =
"CrestClient::listTags";
409 std::string current_path =
m_PATH;
414 current_path +=
"name=";
415 current_path +=
name;
420 current_path +=
"size=";
426 current_path +=
"page=";
432 current_path +=
"sort=";
433 current_path +=
sort;
◆ makeUrl()
std::string Crest::CrestClient::makeUrl |
( |
const std::string & |
address | ) |
const |
|
private |
◆ parseXMLOutput()
std::string Crest::CrestClient::parseXMLOutput |
( |
const std::string_view |
xmlBuffer | ) |
const |
|
private |
This method removes all XML/HTML tags from a string.
(It is an auxiliary method to clear the CREST Server response.)
- Parameters
-
xmlBuffer | - the text (a std::string ) to be cleared. |
Definition at line 121 of file CrestApi.cxx.
125 std::string plainString =
"";
128 for (
long unsigned int i = 0;
i < xmlBuffer.length();
i++)
130 char convertc = xmlBuffer[
i];
134 else if (convertc ==
'>')
141 plainString += convertc;
◆ removeCR()
std::string Crest::CrestClient::removeCR |
( |
const std::string & |
str | ) |
const |
|
private |
This method removes all end of line and carriage return symbols from a string.
(It is an auxiliary method to clear the CREST Server response.)
- Parameters
-
str | - the text (a std::string ) to be cleared. |
Definition at line 149 of file CrestApi.cxx.
151 std::string str2 =
str;
155 while ((
pos = str2.find(needle)) != str2.npos)
◆ removeGlobalTag()
void Crest::CrestClient::removeGlobalTag |
( |
const std::string & |
name | ) |
|
|
overridevirtual |
This method removes a global tag on the CREST server.
(This method is an analogue of the remove_global_tag method in Python)
- Parameters
-
Implements Crest::CrestApiBase.
Definition at line 358 of file CrestApi.cxx.
360 const char *method_name =
"CrestClient::removeGlobalTag";
362 std::string current_path =
m_PATH;
366 current_path +=
name;
◆ removeGlobalTagMap()
void Crest::CrestClient::removeGlobalTagMap |
( |
const std::string & |
name, |
|
|
const std::string & |
record, |
|
|
const std::string & |
label, |
|
|
const std::string & |
tagname |
|
) |
| |
|
overridevirtual |
This method removes a global tag map on the CREST server.
- Parameters
-
name | - the global tag name, |
label | - label, |
tagname | - tag name. |
Implements Crest::CrestApiBase.
Definition at line 594 of file CrestApi.cxx.
596 const char *method_name =
"CrestClient::removeGlobalTagMap";
598 std::string current_path =
m_PATH;
601 current_path +=
name;
605 current_path +=
"tagname=";
611 current_path +=
"record=";
612 current_path += record;
617 current_path +=
"label=";
618 current_path +=
label;
◆ removeTag()
void Crest::CrestClient::removeTag |
( |
const std::string & |
name | ) |
|
|
overridevirtual |
This method removes a tag from the CREST server.
(This method is an analogue of the remove_tag method in Python)
- Parameters
-
Implements Crest::CrestApiBase.
Definition at line 448 of file CrestApi.cxx.
450 const char *method_name =
"CrestClient::removeTag";
452 std::string current_path =
m_PATH;
456 current_path +=
name;
◆ selectGroups()
IovSetDto Crest::CrestClient::selectGroups |
( |
const std::string & |
name, |
|
|
long |
snapshot, |
|
|
int |
size, |
|
|
int |
page, |
|
|
const std::string & |
sort |
|
) |
| |
|
overridevirtual |
This method returns IOV groups for a given tagname on CREST server.
The result is an IOV list. (This method is an analogue of the select_groups method in Python)
- Parameters
-
name | - tag name, |
snapshot | - snapshot, |
size | - page size, |
page | - page number, |
sort | - sorting order (id.since:ASC or id.since:DESC) |
- Returns
- an IOV groups as IovSetDto.
Implements Crest::CrestApiBase.
Definition at line 674 of file CrestApi.cxx.
676 const char *method_name =
"CrestClient::selectGroups";
678 std::string current_path =
m_PATH;
681 current_path +=
"?method=";
683 current_path +=
"&tagname=";
685 current_path +=
name;
686 current_path +=
"&snapshot=";
690 current_path +=
"&size=";
692 current_path +=
"&page=";
694 current_path +=
"&sort=";
695 current_path +=
sort;
◆ selectIovs()
IovSetDto Crest::CrestClient::selectIovs |
( |
const std::string & |
name, |
|
|
uint64_t |
since, |
|
|
uint64_t |
until, |
|
|
long |
snapshot, |
|
|
int |
size, |
|
|
int |
page, |
|
|
const std::string & |
sort |
|
) |
| |
|
overridevirtual |
This method selects IOVs for a given tagname on the CREST server.
The result is an IOV list. (This method is an analogue of the select_iovs method in Python)
- Parameters
-
name | - tag name, |
since | - since time (the beginning of the time interval), |
until | - until time (end of the time interval), |
snapshot | - snapshot, |
size | - page size, |
page | - page number, |
sort | - sorting order (id.since:ASC or id.since:DESC) |
- Returns
- an IOV list as IovSetDto.
Implements Crest::CrestApiBase.
Definition at line 629 of file CrestApi.cxx.
631 const char *method_name =
"CrestClient::selectIovs";
633 std::string current_path =
m_PATH;
636 current_path +=
"?method=";
638 current_path +=
"&tagname=";
640 current_path +=
name;
641 current_path +=
"&since=";
643 current_path +=
"&until=";
646 current_path +=
"INF";
652 current_path +=
"&snapshot=";
655 current_path +=
"&size=";
657 current_path +=
"&page=";
659 current_path +=
"&sort=";
660 current_path +=
sort;
◆ storeData()
void Crest::CrestClient::storeData |
( |
const std::string & |
tag, |
|
|
const StoreSetDto & |
storeSetJson, |
|
|
const std::string & |
payloadFormat = "JSON" , |
|
|
const std::string & |
objectType = "none" , |
|
|
const std::string & |
compressionType = "none" , |
|
|
const std::string & |
version = "1.0" , |
|
|
uint64_t |
endTime = -1 |
|
) |
| |
|
overridevirtual |
This method stores several payloads in batch mode on the CREST server.
(This method is an analogue of the store_data method in Python)
- Parameters
-
tag | - tag name. |
storeSetJson | - iov and payload data as a JSON object. |
payloadFormat | - payload format [FILE | JSON]. |
objectType | - object type. |
compressionType | - compression type. |
version | - version. |
endTime | - end time, if endtime = 0, the server does not use this parameter in the internal check. |
Example how to use these parameters:
std::string tag = "test_MvG3a";
uint64_t endtime = 200;
std::string objectType = "test";
std::string compressionType = "none";
std::string version = "1.0";
std::string payloadFormat = "JSON";
std::string jsonString = R"({"size": 1, "datatype": "data", "format": "StoreSetDto", "resources": [{"since": 1000,"data": "Sample data","streamerInfo": "Info123"}]})";
StoreSetDto storeSetJson = StoreSetDto::from_json(jsonString);
Implements Crest::CrestApiBase.
Definition at line 711 of file CrestApi.cxx.
720 std::string current_path =
m_PATH;
722 std::vector<std::string>
files;
725 if (payloadFormat ==
"JSON")
734 auto subjectIdIter1 = js.find(
"resources");
735 if (subjectIdIter1 != js.end())
737 resources = js[
"resources"];
739 int partN = resources.size();
740 for (
int i = 0;
i < partN;
i++)
743 std::string file_param;
745 auto subjectIdIter1 = element.find(
"data");
746 if (subjectIdIter1 != element.end())
748 file_param = element[
"data"];
751 int found_dots = file_param.find_first_of(
':');
752 int word_size = file_param.size();
753 std::string data_file = file_param.substr(found_dots + 3, word_size);
754 files.push_back(data_file);
◆ updateTagMeta()
void Crest::CrestClient::updateTagMeta |
( |
TagMetaDto & |
tag | ) |
|
|
overridevirtual |
This method updates a tag meta info on the CREST server.
- Parameters
-
Implements Crest::CrestApiBase.
Definition at line 479 of file CrestApi.cxx.
481 const char *method_name =
"CrestClient::updateTagMeta";
483 std::string current_path =
m_PATH;
486 current_path += dto.tagName;
◆ m_host
std::string Crest::CrestClient::m_host |
|
private |
◆ m_PATH
◆ m_port
std::string Crest::CrestClient::m_port |
|
private |
◆ m_prefix
std::string Crest::CrestClient::m_prefix = "http://" |
|
private |
◆ m_request
◆ s_ADMIN_PATH
const std::string Crest::CrestClient::s_ADMIN_PATH = "/admin" |
|
inlinestaticprivate |
◆ s_CREST_CLIENT_CHECK
const bool Crest::CrestClient::s_CREST_CLIENT_CHECK = false |
|
inlinestatic |
◆ s_CREST_CLIENT_VERSION
const std::string Crest::CrestClient::s_CREST_CLIENT_VERSION = "5.0" |
|
inlinestaticprivate |
◆ s_DATA_PATH
const std::string Crest::CrestClient::s_DATA_PATH = "/data" |
|
inlinestaticprivate |
◆ s_FOLDER_PATH
const std::string Crest::CrestClient::s_FOLDER_PATH = "/folders" |
|
inlinestaticprivate |
◆ s_GLOBALTAG_MAP_PATH
const std::string Crest::CrestClient::s_GLOBALTAG_MAP_PATH = "/globaltagmaps" |
|
inlinestaticprivate |
◆ s_GLOBALTAG_PATH
const std::string Crest::CrestClient::s_GLOBALTAG_PATH = "/globaltags" |
|
inlinestaticprivate |
◆ s_IOV_PATH
const std::string Crest::CrestClient::s_IOV_PATH = "/iovs" |
|
inlinestaticprivate |
◆ s_IOV_SIZE_PATH
const std::string Crest::CrestClient::s_IOV_SIZE_PATH = "/size" |
|
inlinestaticprivate |
◆ s_META_PATH
const std::string Crest::CrestClient::s_META_PATH = "/meta" |
|
inlinestaticprivate |
◆ s_METHOD_GROUPS
const std::string Crest::CrestClient::s_METHOD_GROUPS = "GROUPS" |
|
inlinestaticprivate |
◆ s_METHOD_IOVS
const std::string Crest::CrestClient::s_METHOD_IOVS = "IOVS" |
|
inlinestaticprivate |
◆ s_MGMT_INFO_PATH
const std::string Crest::CrestClient::s_MGMT_INFO_PATH = "/info" |
|
inlinestaticprivate |
◆ s_MGMT_INFO_PATH_2
const std::string Crest::CrestClient::s_MGMT_INFO_PATH_2 = "/actuator/info" |
|
inlinestaticprivate |
◆ s_MGMT_PATH
const std::string Crest::CrestClient::s_MGMT_PATH = "/mgmt" |
|
inlinestaticprivate |
◆ s_MONITORING_PAYLOAD_PATH
const std::string Crest::CrestClient::s_MONITORING_PAYLOAD_PATH = "/monitoring/payloads" |
|
inlinestaticprivate |
◆ s_PAYLOAD_PATH
const std::string Crest::CrestClient::s_PAYLOAD_PATH = "/payloads" |
|
inlinestaticprivate |
◆ s_RUNINFO_LIST_PATH
const std::string Crest::CrestClient::s_RUNINFO_LIST_PATH = "/list" |
|
inlinestaticprivate |
◆ s_RUNINFO_PATH
const std::string Crest::CrestClient::s_RUNINFO_PATH = "/runinfo" |
|
inlinestaticprivate |
◆ s_TAG_PATH
const std::string Crest::CrestClient::s_TAG_PATH = "/tags" |
|
inlinestaticprivate |
The documentation for this class was generated from the following files:
static GlobalTagMapSetDto from_json(const json &j)
static const std::string s_TAG_PATH
std::string replace(std::string s, const std::string &s2, const std::string &s3)
nlohmann::json getJson(const std::string &str, const char *method) const
Auxiliary method to convert string in to JSON object.
void get_hash_hex_string(const hash256_one_by_one &hasher, std::string &hex_str)
static const std::string s_MGMT_INFO_PATH
static const std::string s_ADMIN_PATH
std::vector< PayloadDto > resources
static const std::string s_IOV_PATH
void hash256_hex_string(InIter first, InIter last, std::string &hex_str)
static const std::string s_METHOD_IOVS
std::string performRequest(const std::string ¤t_path, Action action, nlohmann::json &js, const std::string &header_params="")
General auxiliary method to make request to the CREST Server.
static const std::string s_GLOBALTAG_MAP_PATH
std::string uploadPayload(const std::string ¤t_path, const std::string &tag, uint64_t endtime, const nlohmann::json &js, const std::string &objectType, const std::string &compressionType, const std::string &version, const std::vector< std::string > &files)
void setPrefix(const std::string &prefix)
std::string getHash(std::string_view str)
This method method calculates the hash for string.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void setHost(const std::string &host)
static const std::string s_GLOBALTAG_PATH
static const std::string s_META_PATH
static const std::string s_METHOD_GROUPS
static const std::string s_MGMT_PATH
std::string getCrestVersion() override
This method returns the full CREST Server version.
std::pair< std::vector< unsigned int >, bool > res
static PayloadSetDto from_json(const json &j)
void process(RaIter first, RaIter last)
static const std::string s_PAYLOAD_PATH
std::string to_string(const DetectorType &type)
void checkCrestVersion()
This method is a CREST version test.
nlohmann::json getMgmtInfo()
This is an auxiliary method to read the CREST Server properties.
static IovSetDto from_json(const json &j)
Crest::CrestRequest m_request
std::string parseXMLOutput(const std::string_view xmlBuffer) const
This method removes all XML/HTML tags from a string.
const std::string & getClientVersion()
This method returns the full CrestApi version.
int getMajorVersion(std::string &str)
This is an auxiliary method to extract a major version number from full version string.
void checkHash(const std::string &hash, const std::string &str, const char *method_name)
This checks the hash of payload from IOV (hash) with the hash calculated for the payload in the std::...
std::string removeCR(const std::string &str) const
This method removes all end of line and carriage return symbols from a string.
static const std::string s_CREST_CLIENT_VERSION
void setPort(const std::string &port)
static const std::string s_IOV_SIZE_PATH