ATLAS Offline Software
Public Member Functions | Protected Member Functions | Static Private Attributes | List of all members
Crest::CrestApiBase Class Referenceabstract

#include <CrestApiBase.h>

Inheritance diagram for Crest::CrestApiBase:
Collaboration diagram for Crest::CrestApiBase:

Public Member Functions

virtual ~CrestApiBase ()=default
 
virtual void createGlobalTag (GlobalTagDto &globalTag)=0
 This method creates a global tag. More...
 
virtual GlobalTagDto findGlobalTag (const std::string &name)=0
 This method finds a global tag by name. More...
 
virtual GlobalTagSetDto listGlobalTags (const std::string &name, int size, int page, const std::string &sort)=0
 This method finds the global tags. More...
 
virtual void removeGlobalTag (const std::string &name)=0
 This method removes a global tag. More...
 
virtual void createTag (TagDto &tag)=0
 This method creates a tag. More...
 
virtual TagDto findTag (const std::string &name)=0
 This method finds a tag by the name. More...
 
virtual TagSetDto listTags (const std::string &name, int size, int page, const std::string &sort)=0
 This method returns the tag list as TagSetDto. More...
 
virtual void removeTag (const std::string &name)=0
 This method removes a tag. More...
 
virtual int getSize (const std::string &tagname)=0
 This method gets the number of IOVs for the given tag. More...
 
virtual void createTagMeta (TagMetaDto &tag)=0
 This method creates a tag meta info. More...
 
virtual void updateTagMeta (TagMetaDto &tag)=0
 This method updates a tag meta info. More...
 
virtual TagMetaDto findTagMeta (const std::string &name)=0
 This method gets a tag meta info by the tag name. More...
 
virtual IovSetDto selectIovs (const std::string &name, uint64_t since, uint64_t until, long snapshot, int size, int page, const std::string &sort)=0
 This method selects IOVs for a given tagname. More...
 
virtual IovSetDto selectGroups (const std::string &name, long snapshot, int size, int page, const std::string &sort)=0
 This method returns IOV groups for a given tagname. More...
 
virtual void createGlobalTagMap (GlobalTagMapDto &globalTagMap)=0
 This method creates a global tag map. More...
 
virtual GlobalTagMapSetDto findGlobalTagMap (const std::string &name, const std::string &xCrestMapMode)=0
 This method searches for tag mappings using the global tag name or tag name . More...
 
virtual void removeGlobalTagMap (const std::string &name, const std::string &record, const std::string &label, const std::string &tagname)=0
 This method removes a global tag map. More...
 
virtual void storeData (const std::string &tag, const StoreSetDto &storeSetJson, const std::string &payloadFormat, const std::string &objectType, const std::string &compressionType, const std::string &version, uint64_t endTime)=0
 This method stores several payloads in batch mode. More...
 
virtual std::string getPayload (const std::string &hash)=0
 This method finds a payload resource associated to the hash. More...
 
virtual PayloadDto getPayloadMeta (const std::string &hash)=0
 This method finds a payload meta info for the hash. More...
 
virtual std::string getCrestVersion ()=0
 This method returns the full CREST Server version. More...
 

Protected Member Functions

std::string getHash (std::string_view str)
 This method method calculates the hash for string. More...
 
std::string getHashForFile (const std::string &file)
 This method method calculates the hash for a file. More...
 
const std::string & getClientVersion ()
 This method returns the full CrestApi version. More...
 

Static Private Attributes

static const std::string s_CREST_CLIENT_VERSION = "5.0"
 

Detailed Description

Definition at line 32 of file CrestApiBase.h.

Constructor & Destructor Documentation

◆ ~CrestApiBase()

virtual Crest::CrestApiBase::~CrestApiBase ( )
virtualdefault

Member Function Documentation

◆ createGlobalTag()

virtual void Crest::CrestApiBase::createGlobalTag ( GlobalTagDto globalTag)
pure virtual

This method creates a global tag.

Parameters
globalTag- global tag as GlobalTagDto.
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);

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ createGlobalTagMap()

virtual void Crest::CrestApiBase::createGlobalTagMap ( GlobalTagMapDto globalTagMap)
pure virtual

This method creates a global tag map.

Parameters
globalTagMap- the global tag map as GlobalTagMapDto.
Example:
 nlohmann::json js =
 {
   {"globalTagName", globaltag},
   {"record", "testing2"},
   {"label", "test2"},
   {"tagName", tagname}
 };
 GlobalTagMapDto globalTagMap = GlobalTagMapDto();
 globalTagMap = globalTagMap.from_json(js);
 myCrestClient.createGlobalTagMap(globalTagMap);

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ createTag()

virtual void Crest::CrestApiBase::createTag ( TagDto tag)
pure virtual

This method creates a tag.

Parameters
tag- tag as TagDto.
 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);
 

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ createTagMeta()

virtual void Crest::CrestApiBase::createTagMeta ( TagMetaDto tag)
pure virtual

This method creates a tag meta info.

Parameters
tag- tag meta info as TagMetaDto.
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);

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ findGlobalTag()

virtual GlobalTagDto Crest::CrestApiBase::findGlobalTag ( const std::string &  name)
pure virtual

This method finds a global tag by name.

Only one global tag should be returned. (This method is an analogue of the find_global_tag method in Python)

Parameters
name- global tag name,
Returns
global tag as GlobalTagDto.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ findGlobalTagMap()

virtual GlobalTagMapSetDto Crest::CrestApiBase::findGlobalTagMap ( const std::string &  name,
const std::string &  xCrestMapMode 
)
pure virtual

This method searches for tag mappings using the global tag name or tag name .

(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.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ findTag()

virtual TagDto Crest::CrestApiBase::findTag ( const std::string &  name)
pure virtual

This method finds a tag by the name.

(This method is an analogue of the find_tag method in Python)

Parameters
name- tag name
Returns
tag as TagDto object.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ findTagMeta()

virtual TagMetaDto Crest::CrestApiBase::findTagMeta ( const std::string &  name)
pure virtual

This method gets a tag meta info by the tag name.

Parameters
name- tag name
Returns
tag meta info as a TagMetaDto.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ getClientVersion()

const std::string & Crest::CrestApiBase::getClientVersion ( )
protected

This method returns the full CrestApi version.

Returns
CrestApi library version.

Definition at line 38 of file CrestApiBase.cxx.

39  {
41  }

◆ getCrestVersion()

virtual std::string Crest::CrestApiBase::getCrestVersion ( )
pure virtual

This method returns the full CREST Server version.

Returns
CREST server version.

Implemented in Crest::CrestFsClient, and Crest::CrestClient.

◆ getHash()

std::string Crest::CrestApiBase::getHash ( std::string_view  str)
protected

This method method calculates the hash for string.

Parameters
str- string.
Returns
hash for a given string.

Definition at line 32 of file CrestApiBase.cxx.

33  {
34  std::string hash_hex_str = picosha2::hash256_hex_string(str.begin(), str.end());
35  return hash_hex_str;
36  }

◆ getHashForFile()

std::string Crest::CrestApiBase::getHashForFile ( const std::string &  file)
protected

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.

9  {
10  std::ifstream ifs(file);
11  if (!ifs)
12  {
13  throw CrestException(
14  "ERROR in CrestFsClient::getHashForFile cannot open file \"" + file + "\".");
15  }
16 
18  std::vector<char> buffer(1024 * 1024); // use 1M memory
19  while (ifs.read(buffer.data(), static_cast<std::streamsize>(buffer.size())))
20  {
21  std::cout << "#" << std::flush;
22  hasher.process(buffer.begin(), buffer.end());
23  }
24  // process remains
25  hasher.process(buffer.begin(), buffer.begin() + static_cast<int>(ifs.gcount()));
26  hasher.finish();
27 
28  std::string hash = picosha2::get_hash_hex_string(hasher);
29  return hash;
30  }

◆ getPayload()

virtual std::string Crest::CrestApiBase::getPayload ( const std::string &  hash)
pure virtual

This method finds a payload resource associated to the hash.

The payload returns as a string. (This method is an analogue of the get_payload method in Python)

Parameters
hash- hash.
Returns
payload as a std::string

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ getPayloadMeta()

virtual PayloadDto Crest::CrestApiBase::getPayloadMeta ( const std::string &  hash)
pure virtual

This method finds a payload meta info for the hash.

(This method is an analogue of the get_payload_meta method in Python)

Parameters
hash- hash.
Returns
payload meta info as PayloadDto.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ getSize()

virtual int Crest::CrestApiBase::getSize ( const std::string &  tagname)
pure virtual

This method gets the number of IOVs for the given tag.

(This method is an analogue of the get_size method in Python)

Parameters
tagname- tag name.
Returns
IOV number.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ listGlobalTags()

virtual GlobalTagSetDto Crest::CrestApiBase::listGlobalTags ( const std::string &  name,
int  size,
int  page,
const std::string &  sort 
)
pure virtual

This method finds the global tags.

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.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ listTags()

virtual TagSetDto Crest::CrestApiBase::listTags ( const std::string &  name,
int  size,
int  page,
const std::string &  sort 
)
pure virtual

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.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ removeGlobalTag()

virtual void Crest::CrestApiBase::removeGlobalTag ( const std::string &  name)
pure virtual

This method removes a global tag.

(This method is an analogue of the remove_global_tag method in Python)

Parameters
name- global tag name

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ removeGlobalTagMap()

virtual void Crest::CrestApiBase::removeGlobalTagMap ( const std::string &  name,
const std::string &  record,
const std::string &  label,
const std::string &  tagname 
)
pure virtual

This method removes a global tag map.

Parameters
name- the global tag name,
label- label,
tagname- tag name.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ removeTag()

virtual void Crest::CrestApiBase::removeTag ( const std::string &  name)
pure virtual

This method removes a tag.

(This method is an analogue of the remove_tag method in Python)

Parameters
tagName- tag name

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ selectGroups()

virtual IovSetDto Crest::CrestApiBase::selectGroups ( const std::string &  name,
long  snapshot,
int  size,
int  page,
const std::string &  sort 
)
pure virtual

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.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ selectIovs()

virtual IovSetDto Crest::CrestApiBase::selectIovs ( const std::string &  name,
uint64_t  since,
uint64_t  until,
long  snapshot,
int  size,
int  page,
const std::string &  sort 
)
pure virtual

This method selects IOVs for a given tagname.

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.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ storeData()

virtual void Crest::CrestApiBase::storeData ( const std::string &  tag,
const StoreSetDto storeSetJson,
const std::string &  payloadFormat,
const std::string &  objectType,
const std::string &  compressionType,
const std::string &  version,
uint64_t  endTime 
)
pure virtual

This method stores several payloads in batch mode.

(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);

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

◆ updateTagMeta()

virtual void Crest::CrestApiBase::updateTagMeta ( TagMetaDto tag)
pure virtual

This method updates a tag meta info.

Parameters
tag- tag meta info as TagMetaDto.

Implemented in Crest::CrestClient, and Crest::CrestFsClient.

Member Data Documentation

◆ s_CREST_CLIENT_VERSION

const std::string Crest::CrestApiBase::s_CREST_CLIENT_VERSION = "5.0"
inlinestaticprivate

Definition at line 36 of file CrestApiBase.h.


The documentation for this class was generated from the following files:
picosha2::get_hash_hex_string
void get_hash_hex_string(const hash256_one_by_one &hasher, std::string &hex_str)
Definition: picosha2.h:281
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:182
picosha2::hash256_hex_string
void hash256_hex_string(InIter first, InIter last, std::string &hex_str)
Definition: picosha2.h:353
picosha2::hash256_one_by_one::finish
void finish()
Definition: picosha2.h:207
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
file
TFile * file
Definition: tile_monitor.h:29
picosha2::hash256_one_by_one::process
void process(RaIter first, RaIter last)
Definition: picosha2.h:196
picosha2::hash256_one_by_one
Definition: picosha2.h:184
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
str
Definition: BTagTrackIpAccessor.cxx:11
Crest::CrestApiBase::s_CREST_CLIENT_VERSION
static const std::string s_CREST_CLIENT_VERSION
Definition: CrestApiBase.h:36