|
ATLAS Offline Software
|
#include <CrestApiFs.h>
|
| CrestFsClient (bool rewriteIfExists, const std::string &root_folder) |
| CrestFsClient constructor. More...
|
|
| ~CrestFsClient () |
| CrestClient destructor. More...
|
|
void | createGlobalTag (GlobalTagDto &globalTag) override |
| This method creates a global tag on the file storage. More...
|
|
GlobalTagDto | findGlobalTag (const std::string &name) override |
| This method finds a global tag by name on the file storage. More...
|
|
GlobalTagSetDto | listGlobalTags (const std::string &name, int size, int page, const std::string &sort) override |
| This method finds the global tags on the file storage. More...
|
|
void | removeGlobalTag (const std::string &name) override |
| This method removes a global tag. More...
|
|
void | createTag (TagDto &tag) override |
| This method creates a tag on the file storage. More...
|
|
TagDto | findTag (const std::string &name) override |
| This method finds a tag by the name on the file storage. More...
|
|
TagSetDto | listTags (const std::string &name, int size, int page, const std::string &sort) override |
| This method returns the tag list as TagSetDto. More...
|
|
void | removeTag (const std::string &name) override |
| This method removes a tag from the file storage. 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 file storage. More...
|
|
void | updateTagMeta (TagMetaDto &tag) override |
| This method updates a tag meta info on the file storage. More...
|
|
TagMetaDto | findTagMeta (const std::string &name) override |
| This method gets a tag meta info by the tag name from the file storage. 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 from the file storage. 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. More...
|
|
void | createGlobalTagMap (GlobalTagMapDto &globalTagMap) override |
| This method creates a global tag map on the file storage. 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 file storage. 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 from the file storage. 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 file storage. More...
|
|
std::string | getPayload (const std::string &hash) override |
| This method finds a payload resource associated to the hash on the file storage. More...
|
|
PayloadDto | getPayloadMeta (const std::string &hash) override |
| This method finds a payload meta info for the hash on the file storage. More...
|
|
std::string | getCrestVersion () override |
| This method returns the full CREST Server version. More...
|
|
|
void | checkFsException (const char *method_name) |
| Auxiliary method to check if the CrestApi library initialized to work with the file system. More...
|
|
std::string | getFileString (const std::string &path) |
| Auxiliary method to get a file as a string. More...
|
|
void | getFileList (const std::string &path) |
| Auxiliary method to get a file list in the given directory. More...
|
|
void | flush () |
| Auxiliary method flush the data to the file system. More...
|
|
std::string | getDateAndTime () |
|
std::string | getFirstLetters (const std::string &str) |
| This is an auxillary method extract first letters from the string (hash). More...
|
|
nlohmann::json | getPage (nlohmann::json data, int size, int page) |
|
std::vector< std::string > | getVectorPage (const std::vector< std::string > &data, int size, int page) |
|
std::vector< std::string > | nameList (std::string &folder, bool ascending=true) |
|
std::string | buildPath (const std::string &path, const std::string &file) |
|
nlohmann::json | sortJson (nlohmann::json js, const std::string &par, bool order) |
|
nlohmann::json | sortIOVJson (nlohmann::json js, bool order) |
|
bool | isMatch (const std::string &word, long unsigned int n, const std::string &pattern, long unsigned int m) |
|
bool | isMatch (const std::string &word, const std::string &pattern) |
|
nlohmann::json | findAllIovs (const std::string &tagname) |
| This auxiliary method finds all iovs for a given tag name. More...
|
|
void | storePayloadDump (const std::string &tag, uint64_t since, const std::string &js, const std::string &payloadFormat, const std::string &objectType, const std::string &compressionType, const std::string &version, const std::string &streamerInfo) |
| This auxiliary method stores a single payload (with since time) on the file system. More...
|
|
Definition at line 31 of file CrestApiFs.h.
◆ CrestFsClient()
Crest::CrestFsClient::CrestFsClient |
( |
bool |
rewriteIfExists, |
|
|
const std::string & |
root_folder |
|
) |
| |
CrestFsClient constructor.
CrestFsClient constructor for Internet mode.
- Parameters
-
rewriteIfExist | - this parameter sets if the data can be rewritten. |
root_folder | - the folder where the data have to be stored. |
If CrestClient is created with this method the data will be sent to the CREST Server.
- Parameters
-
rewriteIfExists | - Boolean flag to reinitialize the file system. |
root_folder | - root directory of the CREST storage. |
Definition at line 35 of file CrestApiFs.cxx.
◆ ~CrestFsClient()
Crest::CrestFsClient::~CrestFsClient |
( |
| ) |
|
◆ buildPath()
std::string Crest::CrestFsClient::buildPath |
( |
const std::string & |
path, |
|
|
const std::string & |
file |
|
) |
| |
|
private |
◆ checkFsException()
void Crest::CrestFsClient::checkFsException |
( |
const char * |
method_name | ) |
|
|
private |
Auxiliary method to check if the CrestApi library initialized to work with the file system.
It was used to throw an exception if the library method not implemented for file system.
- Parameters
-
method_name | - method name. |
Definition at line 523 of file CrestApiFs.cxx.
525 throw CrestException(
"ERROR in " + std::string(method_name) +
" This methods is unsupported for FILESYSTEM mode");
◆ createGlobalTag()
void Crest::CrestFsClient::createGlobalTag |
( |
GlobalTagDto & |
globalTag | ) |
|
|
overridevirtual |
This method creates a global tag on the file storage.
- 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 106 of file CrestApiFs.cxx.
108 std::string
name =
"";
115 throw CrestException(
"ERROR in CrestFsClient::createGlobalTag: global tag name is not set.");
130 outFile.open(globalTagFile.c_str());
◆ createGlobalTagMap()
void Crest::CrestFsClient::createGlobalTagMap |
( |
GlobalTagMapDto & |
globalTagMap | ) |
|
|
overridevirtual |
This method creates a global tag map on the file storage.
- 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 431 of file CrestApiFs.cxx.
436 std::string
name =
"";
439 name =
static_cast<std::string
>(js[
"globalTagName"]);
443 throw CrestException(
"ERROR in CrestClient::createGlobalTagMap: cannot get the global tag name from JSON.");
450 tagname =
static_cast<std::string
>(js[
"tagName"]);
454 throw CrestException(
"ERROR in CrestClient::createGlobalTagMap: cannot get the tag name from JSON.");
473 throw CrestException(
"ERROR in CrestFsClient::createGlobalTagMap: global tag map file corrupted.");
479 int m = cathalogue.size();
480 for (
int i = 0;
i <
m;
i++)
482 const std::string &tn = cathalogue[
i][
"tagName"];
494 cathalogue.push_back(js);
506 cathalogue.push_back(js);
◆ createTag()
void Crest::CrestFsClient::createTag |
( |
TagDto & |
tag | ) |
|
|
overridevirtual |
This method creates a tag on the file storage.
- 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 233 of file CrestApiFs.cxx.
◆ createTagMeta()
void Crest::CrestFsClient::createTagMeta |
( |
TagMetaDto & |
tag | ) |
|
|
overridevirtual |
This method creates a tag meta info on the file storage.
- 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 379 of file CrestApiFs.cxx.
381 std::string
name =
tag.tagName;
395 outFile.open(tagMetaFile.c_str());
◆ findAllIovs()
This auxiliary method finds all iovs for a given tag name.
The result is a JSON object.
- Parameters
-
- Returns
- JSON array with the IOV list. Example:
IOV list =
[
{
"tagName": "CaloOflHadDMCorr2-R123-FTFP-BERT-IOVDEP-01",
"since": 0,
"insertionTime": "2023-09-13T12:53:46+0000",
"payloadHash": "ba26ca6b4e17b0c33b008045c5e703bdf049a1546e731ec7c3d2d39789b1ce1f"
},
...
]
IOV JSON parameters:
tagName string tag name
since number since time parameter
insertionTime string($date-time) insertion time
payloadHash string payload hash
Definition at line 621 of file CrestApiFs.cxx.
638 throw CrestException(
"ERROR in CrestFsClient::findAllIovs : cannot get the iov information form file storage ");
◆ findGlobalTag()
This method finds a global tag by name on the file storage.
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 138 of file CrestApiFs.cxx.
154 throw CrestException(
155 "ERROR in CrestFsClient::findGlobalTag: cannot get the global tag " +
name +
" form the file storage.");
◆ findGlobalTagMap()
This method searches for tag mappings using the global tag name or tag name on the file storage.
(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 528 of file CrestApiFs.cxx.
533 if (xCrestMapMode !=
"Trace")
535 throw CrestException(
536 "ERROR in CrestFsClient::getGlobalTagMap: not supported value for the parameter xCrestMapMode = " + xCrestMapMode);
552 throw CrestException(
553 "ERROR in CrestFsClient::getGlobalTagMap: cannot get the global tag map " +
name +
554 " form the file storage.");
◆ findTag()
TagDto Crest::CrestFsClient::findTag |
( |
const std::string & |
name | ) |
|
|
overridevirtual |
This method finds a tag by the name on the file storage.
(This method is an analogue of the find_tag method in Python)
- Parameters
-
- Returns
- tag as TagDto object.
Implements Crest::CrestApiBase.
Definition at line 267 of file CrestApiFs.cxx.
283 throw CrestException(
284 "ERROR in CrestFsClient::findTag: cannot get the tag " +
name +
" form the file storage.");
◆ findTagMeta()
This method gets a tag meta info by the tag name from the file storage.
- Parameters
-
- Returns
- tag meta info as a TagMetaDto.
Implements Crest::CrestApiBase.
Definition at line 406 of file CrestApiFs.cxx.
422 throw CrestException(
423 "ERROR in CrestFsClient::findTagMeta: cannot get the tag " +
name +
" form the file storage.");
◆ flush()
void Crest::CrestFsClient::flush |
( |
| ) |
|
|
private |
Auxiliary method flush the data to the file system.
Definition at line 360 of file CrestApiFs.cxx.
◆ 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::CrestFsClient::getCrestVersion |
( |
| ) |
|
|
overridevirtual |
This method returns the full CREST Server version.
- Returns
- CREST server version.
Implements Crest::CrestApiBase.
Definition at line 1111 of file CrestApiFs.cxx.
1113 throw CrestException(
1114 "ERROR in CrestFsClient::getCrestVersion: cannot get the CREST server version for file storage.");
◆ getDateAndTime()
std::string Crest::CrestFsClient::getDateAndTime |
( |
| ) |
|
|
private |
Definition at line 711 of file CrestApiFs.cxx.
717 localtime_r(&
now, &tstruct);
718 strftime(buf,
sizeof(buf),
"%Y-%m-%d %X", &tstruct);
◆ getFileList()
void Crest::CrestFsClient::getFileList |
( |
const std::string & |
path | ) |
|
|
private |
Auxiliary method to get a file list in the given directory.
(The old method name - get_file_list)
- Parameters
-
path | - path to the directory. |
Definition at line 88 of file CrestApiFs.cxx.
91 for (
auto i = std::filesystem::directory_iterator(
p);
i != std::filesystem::directory_iterator();
i++)
93 std::string
file =
i->path().filename().string();
96 std::cout <<
file << std::endl;
◆ getFileString()
std::string Crest::CrestFsClient::getFileString |
( |
const std::string & |
path | ) |
|
|
private |
Auxiliary method to get a file as a string.
(The old method name - get_file_string)
- Parameters
-
Definition at line 60 of file CrestApiFs.cxx.
61 std::ifstream ifs(
path);
62 std::stringstream
buf;
◆ getFirstLetters()
std::string Crest::CrestFsClient::getFirstLetters |
( |
const std::string & |
str | ) |
|
|
private |
This is an auxillary method extract first letters from the string (hash).
The letter number is in the s_FS_PREFIX_LENGTH variable. This method is used to create a catalogue sub directory in the file storage.
- Parameters
-
str | - string to extract first letters. |
- Returns
- - string with first letters
Definition at line 722 of file CrestApiFs.cxx.
◆ 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())))
◆ getPage()
◆ getPayload()
std::string Crest::CrestFsClient::getPayload |
( |
const std::string & |
hash | ) |
|
|
overridevirtual |
This method finds a payload resource associated to the hash on the file storage.
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 853 of file CrestApiFs.cxx.
860 std::string
filePath = workDir +
"/payload.json";
861 std::string
res =
"";
871 throw CrestException(
"payload with hash " +
hash +
" does not exist.");
877 throw CrestException(
"ERROR in CrestFsClient::getPayload cannot get the payload form file storage, " +
message);
◆ getPayloadMeta()
PayloadDto Crest::CrestFsClient::getPayloadMeta |
( |
const std::string & |
hash | ) |
|
|
overridevirtual |
This method finds a payload meta info for the hash on the file storage.
(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 883 of file CrestApiFs.cxx.
897 std::string
res =
"";
909 throw CrestException(
"payload meta info with hash " +
hash +
" does not exist.");
915 throw CrestException(
"ERROR in CrestClient::getPayloadMeta cannot get the payload meta info form file storage, " +
message);
◆ getSize()
int Crest::CrestFsClient::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 644 of file CrestApiFs.cxx.
◆ getVectorPage()
std::vector< std::string > Crest::CrestFsClient::getVectorPage |
( |
const std::vector< std::string > & |
data, |
|
|
int |
size, |
|
|
int |
page |
|
) |
| |
|
private |
Definition at line 949 of file CrestApiFs.cxx.
951 std::vector<std::string>
res;
970 for (
int i = kmin;
i < kmax;
i++)
◆ isMatch() [1/2]
bool Crest::CrestFsClient::isMatch |
( |
const std::string & |
word, |
|
|
const std::string & |
pattern |
|
) |
| |
|
private |
◆ isMatch() [2/2]
bool Crest::CrestFsClient::isMatch |
( |
const std::string & |
word, |
|
|
long unsigned int |
n, |
|
|
const std::string & |
pattern, |
|
|
long unsigned int |
m |
|
) |
| |
|
private |
Definition at line 1073 of file CrestApiFs.cxx.
1077 return n == word.size();
1080 if (
n == word.size())
1082 for (
long unsigned int i =
m;
i <
pattern.size();
i++)
◆ listGlobalTags()
GlobalTagSetDto Crest::CrestFsClient::listGlobalTags |
( |
const std::string & |
name, |
|
|
int |
size, |
|
|
int |
page, |
|
|
const std::string & |
sort |
|
) |
| |
|
overridevirtual |
This method finds the global tags on the file storage.
- 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 166 of file CrestApiFs.cxx.
174 if (sort ==
"name:ASC")
178 else if (sort ==
"name:DESC")
184 throw CrestException(
185 "ERROR in CrestFsClient::listTags: wrong sort parameter." + sort);
191 std::vector<std::string> clearedTaglist;
203 clearedTaglist.push_back(
tag);
208 clearedTaglist.push_back(
tag);
224 throw CrestException(
225 "ERROR in CrestFsClient::listGlobalTags: cannot get the tag list.");
◆ listTags()
TagSetDto Crest::CrestFsClient::listTags |
( |
const std::string & |
name, |
|
|
int |
size, |
|
|
int |
page, |
|
|
const std::string & |
sort |
|
) |
| |
|
overridevirtual |
This method returns the tag list as TagSetDto.
(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 295 of file CrestApiFs.cxx.
303 if (sort ==
"name:ASC")
307 else if (sort ==
"name:DESC")
313 throw CrestException(
314 "ERROR in CrestFsClient::listTags: wrong sort parameter." + sort);
320 std::vector<std::string> clearedTaglist;
332 clearedTaglist.push_back(
tag);
337 clearedTaglist.push_back(
tag);
353 throw CrestException(
354 "ERROR in CrestFsClient::listTags: cannot get the tag list.");
◆ nameList()
std::vector< std::string > Crest::CrestFsClient::nameList |
( |
std::string & |
folder, |
|
|
bool |
ascending = true |
|
) |
| |
|
private |
Definition at line 977 of file CrestApiFs.cxx.
982 for (
auto i = std::filesystem::directory_iterator(
p);
i != std::filesystem::directory_iterator();
i++)
984 std::string
file =
i->path().filename().string();
◆ removeGlobalTag()
void Crest::CrestFsClient::removeGlobalTag |
( |
const std::string & |
name | ) |
|
|
overridevirtual |
This method removes a global tag.
(This method is an analogue of the remove_global_tag method in Python)
- Parameters
-
Implements Crest::CrestApiBase.
Definition at line 161 of file CrestApiFs.cxx.
◆ removeGlobalTagMap()
void Crest::CrestFsClient::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 from the file storage.
- Parameters
-
name | - the global tag name, |
label | - label, |
tagname | - tag name. |
Implements Crest::CrestApiBase.
Definition at line 518 of file CrestApiFs.cxx.
◆ removeTag()
void Crest::CrestFsClient::removeTag |
( |
const std::string & |
name | ) |
|
|
overridevirtual |
This method removes a tag from the file storage.
(This method is an analogue of the remove_tag method in Python)
- Parameters
-
Implements Crest::CrestApiBase.
Definition at line 290 of file CrestApiFs.cxx.
◆ selectGroups()
IovSetDto Crest::CrestFsClient::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.
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 662 of file CrestApiFs.cxx.
◆ selectIovs()
IovSetDto Crest::CrestFsClient::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 from the file storage.
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 564 of file CrestApiFs.cxx.
575 for (
int i = 0;
i < niovs;
i++)
590 if (currentS >=
since)
600 throw CrestException(
"ERROR in CrestClient::selectIovsFS : cannot get the iov list form file storage");
604 if (sort ==
"id.since:ASC")
606 else if (sort ==
"id.since:DESC")
610 throw CrestException(
611 "ERROR in CrestFsClient::selectIovs: wrong sort parameter." + sort);
◆ sortIOVJson()
Definition at line 1036 of file CrestApiFs.cxx.
1038 std::string
par =
"since";
1040 std::vector<double> parlist;
1041 std::map<double, nlohmann::json>
m;
1043 int size = js.size();
1044 for (
int i = 0;
i <
size;
i++)
1048 auto res = elem.find(
par);
1050 if (
res != elem.end())
1052 double par_val = elem[
par];
1053 parlist.push_back(par_val);
1058 std::sort(parlist.begin(), parlist.end());
1065 for (
double item : parlist)
1067 respond.push_back(
m[
item]);
◆ sortJson()
Definition at line 999 of file CrestApiFs.cxx.
1002 std::vector<std::string> parlist;
1003 std::map<std::string, nlohmann::json>
m;
1005 int size = js.size();
1006 for (
int i = 0;
i <
size;
i++)
1010 auto res = elem.find(
par);
1012 if (
res != elem.end())
1014 std::string par_val = elem[
par];
1015 parlist.push_back(par_val);
1020 std::sort(parlist.begin(), parlist.end());
1027 for (std::string
item : parlist)
1029 respond.push_back(
m[
item]);
◆ storeData()
void Crest::CrestFsClient::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 file storage.
(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 669 of file CrestApiFs.cxx.
686 auto it = js_data.find(
"resources");
687 if (
it != js_data.end())
689 res = js_data[
"resources"];
694 for (
auto &kvp :
res)
696 std::string
payload = kvp.value(
"data",
"");
697 int since = kvp.value(
"since", 0);
698 std::string streamer = kvp.value(
"streamerInfo",
"");
706 throw CrestException(
"ERROR in CrestFsClient::storeData cannot store the data in a file");
◆ storePayloadDump()
void Crest::CrestFsClient::storePayloadDump |
( |
const std::string & |
tag, |
|
|
uint64_t |
since, |
|
|
const std::string & |
js, |
|
|
const std::string & |
payloadFormat, |
|
|
const std::string & |
objectType, |
|
|
const std::string & |
compressionType, |
|
|
const std::string & |
version, |
|
|
const std::string & |
streamerInfo |
|
) |
| |
|
private |
This auxiliary method stores a single payload (with since time) on the file system.
- Parameters
-
tag | - tag name. |
since | - since parameter, |
js | - a string with a payload or file (the path and the file name) with payload. |
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. |
Definition at line 728 of file CrestApiFs.cxx.
740 std::string hashCode;
741 std::string payloadLocalFile;
744 if (payloadFormat ==
"JSON")
751 int found_dots = js.find_first_of(
':');
752 int word_size = js.size();
753 payloadLocalFile = js.substr(found_dots + 3, word_size);
771 std::string tagFile = workDir +
"/payload.json";
773 if (payloadFormat ==
"JSON")
783 std::filesystem::copy_file(payloadLocalFile, tagFile);
785 catch (std::filesystem::filesystem_error &
e)
787 throw CrestException(
"ERROR in CrestFsClient::storePayloadDump cannot not save payload file: " + tagFile +
e.what());
795 {
"checkSum",
"SHA-256"},
799 {
"streamerInfo", streamerInfo},
800 {
"compressionType", compressionType},
804 std::string metaFile = workDir +
"/meta.json";
817 m_data.insert(std::pair<std::string, nlohmann::json>(
tag, jsi));
825 m_data.insert(std::pair<std::string, nlohmann::json>(
tag, jsFree));
829 throw CrestException(
830 "ERROR in CrestFsClient::storePayloadDump cannot get data for tag \"" +
tag +
"\" from file storage.");
838 std::string link = hashCode;
844 obj[
"payloadHash"] = link;
◆ updateTagMeta()
void Crest::CrestFsClient::updateTagMeta |
( |
TagMetaDto & |
tag | ) |
|
|
overridevirtual |
◆ m_currentTag
std::string Crest::CrestFsClient::m_currentTag {} |
|
private |
◆ m_data
◆ m_data_folder
std::string Crest::CrestFsClient::m_data_folder {} |
|
private |
◆ m_isRewrite
bool Crest::CrestFsClient::m_isRewrite {} |
|
private |
◆ m_root_folder
std::string Crest::CrestFsClient::m_root_folder {} |
|
private |
◆ s_CREST_CLIENT_VERSION
const std::string Crest::CrestApiBase::s_CREST_CLIENT_VERSION = "5.0" |
|
inlinestaticprivateinherited |
◆ s_FS_DATA_PATH
const std::string Crest::CrestFsClient::s_FS_DATA_PATH = "/data" |
|
inlinestaticprivate |
◆ s_FS_GLOBALTAG_FILE
const std::string Crest::CrestFsClient::s_FS_GLOBALTAG_FILE = "/globaltag.json" |
|
inlinestaticprivate |
◆ s_FS_GLOBALTAG_PATH
const std::string Crest::CrestFsClient::s_FS_GLOBALTAG_PATH = "/globaltags" |
|
inlinestaticprivate |
◆ s_FS_IOV_FILE
const std::string Crest::CrestFsClient::s_FS_IOV_FILE = "/iovs.json" |
|
inlinestaticprivate |
◆ s_FS_MAP_FILE
const std::string Crest::CrestFsClient::s_FS_MAP_FILE = "/maps.json" |
|
inlinestaticprivate |
◆ s_FS_META_FILE
const std::string Crest::CrestFsClient::s_FS_META_FILE = "/meta.json" |
|
inlinestaticprivate |
◆ s_FS_PALOAD_FILE
const std::string Crest::CrestFsClient::s_FS_PALOAD_FILE = "/payload.json" |
|
inlinestaticprivate |
◆ s_FS_PATH
const std::string Crest::CrestFsClient::s_FS_PATH = "" |
|
inlinestaticprivate |
◆ s_FS_PREFIX_LENGTH
const int Crest::CrestFsClient::s_FS_PREFIX_LENGTH = 3 |
|
inlinestaticprivate |
◆ s_FS_TAG_FILE
const std::string Crest::CrestFsClient::s_FS_TAG_FILE = "/tag.json" |
|
inlinestaticprivate |
◆ s_FS_TAG_PATH
const std::string Crest::CrestFsClient::s_FS_TAG_PATH = "/tags" |
|
inlinestaticprivate |
◆ s_FS_TAGMETAINFO_FILE
const std::string Crest::CrestFsClient::s_FS_TAGMETAINFO_FILE = "/tagmetainfo.json" |
|
inlinestaticprivate |
The documentation for this class was generated from the following files:
JetConstituentVector::iterator iterator
static const std::string s_FS_GLOBALTAG_PATH
static const std::string s_FS_TAG_PATH
static IovSetDto from_fs_json(const json &j)
static GlobalTagMapSetDto from_fs_json(const json &j)
char data[hepevt_bytes_allocation_ATLAS]
void get_hash_hex_string(const hash256_one_by_one &hasher, std::string &hex_str)
path
python interpreter configuration --------------------------------------—
std::string m_data_folder
std::string find(const std::string &s)
return a remapped string
std::string getFirstLetters(const std::string &str)
This is an auxillary method extract first letters from the string (hash).
nlohmann::json sortIOVJson(nlohmann::json js, bool order)
void hash256_hex_string(InIter first, InIter last, std::string &hex_str)
static const std::string s_FS_IOV_FILE
static TagDto from_json(const json &j)
void flush()
Auxiliary method flush the data to the file system.
std::string getHash(std::string_view str)
This method method calculates the hash for string.
static const std::string s_FS_MAP_FILE
bool isMatch(const std::string &word, long unsigned int n, const std::string &pattern, long unsigned int m)
std::vector< std::string > nameList(std::string &folder, bool ascending=true)
static GlobalTagDto from_json(const json &j)
std::string getFileString(const std::string &path)
Auxiliary method to get a file as a string.
std::string m_root_folder
static const std::string s_FS_TAG_FILE
std::string getDateAndTime()
static PayloadDto from_json(const json &j)
The TagDto class It contains all fields of the TagDto class from the CREST API.
std::pair< std::vector< unsigned int >, bool > res
static const int s_FS_PREFIX_LENGTH
void checkFsException(const char *method_name)
Auxiliary method to check if the CrestApi library initialized to work with the file system.
std::optional< std::string > datatype
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
void process(RaIter first, RaIter last)
outFile
Comment Out Those You do not wish to run.
GlobalTagDto findGlobalTag(const std::string &name) override
This method finds a global tag by name on the file storage.
TagDto findTag(const std::string &name) override
This method finds a tag by the name on the file storage.
static const std::string s_FS_TAGMETAINFO_FILE
std::vector< std::string > getVectorPage(const std::vector< std::string > &data, int size, int page)
size_t dataSize(TDA::PayloadIterator start)
Size in bytes of the buffer that is needed to decode next fragment data content.
static const std::string s_FS_GLOBALTAG_FILE
nlohmann::json getPage(nlohmann::json data, int size, int page)
std::map< std::string, nlohmann::json > m_data
def time(flags, cells_name, *args, **kw)
std::string buildPath(const std::string &path, const std::string &file)
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
void storePayloadDump(const std::string &tag, uint64_t since, const std::string &js, const std::string &payloadFormat, const std::string &objectType, const std::string &compressionType, const std::string &version, const std::string &streamerInfo)
This auxiliary method stores a single payload (with since time) on the file system.
std::string getHashForFile(const std::string &file)
This method method calculates the hash for a file.
static const std::string s_CREST_CLIENT_VERSION
nlohmann::json findAllIovs(const std::string &tagname)
This auxiliary method finds all iovs for a given tag name.