Skip to content

Commit a8598f2

Browse files
authored
Merge branch 'AliceO2Group:dev' into new-detector4
2 parents 2d1bd3b + 8252a1f commit a8598f2

File tree

128 files changed

+1424
-1434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1424
-1434
lines changed

CCDB/include/CCDB/CcdbApi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ class CcdbApi //: public DatabaseInterface
556556
* @param tcl The TClass object describing the serialized type
557557
* @return raw pointer to created object
558558
*/
559-
void* downloadFilesystemContent(std::string const& fullUrl, std::type_info const& tinfo, std::map<string, string>* headers) const;
559+
void* downloadFilesystemContent(std::string const& fullUrl, std::type_info const& tinfo, std::map<std::string, std::string>* headers) const;
560560

561561
// initialize the TGrid (Alien connection)
562562
bool initTGrid() const;

CCDB/src/CcdbApi.cxx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void CcdbApi::updateMetaInformationInLocalFile(std::string const& filename, std:
297297
*/
298298
std::string sanitizeObjectName(const std::string& objectName)
299299
{
300-
string tmpObjectName = objectName;
300+
std::string tmpObjectName = objectName;
301301
tmpObjectName.erase(std::remove_if(tmpObjectName.begin(), tmpObjectName.end(),
302302
[](auto const& c) -> bool { return (!std::isalnum(c) && c != '_' && c != '/' && c != '.'); }),
303303
tmpObjectName.end());
@@ -431,7 +431,7 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin
431431
CURLcode res = CURL_LAST;
432432

433433
for (size_t hostIndex = 0; hostIndex < hostsPool.size() && res > 0; hostIndex++) {
434-
string fullUrl = getFullUrlForStorage(curl, path, objectType, metadata, sanitizedStartValidityTimestamp, sanitizedEndValidityTimestamp, hostIndex);
434+
std::string fullUrl = getFullUrlForStorage(curl, path, objectType, metadata, sanitizedStartValidityTimestamp, sanitizedEndValidityTimestamp, hostIndex);
435435
LOG(debug3) << "Full URL Encoded: " << fullUrl;
436436
/* what URL that receives this POST */
437437
curl_easy_setopt(curl, CURLOPT_URL, fullUrl.c_str());
@@ -476,57 +476,57 @@ int CcdbApi::storeAsTFile(const TObject* rootObject, std::string const& path, st
476476
return storeAsBinaryFile(img->data(), img->size(), info.getFileName(), info.getObjectType(), path, metadata, startValidityTimestamp, endValidityTimestamp, maxSize);
477477
}
478478

479-
string CcdbApi::getFullUrlForStorage(CURL* curl, const string& path, const string& objtype,
480-
const map<string, string>& metadata,
481-
long startValidityTimestamp, long endValidityTimestamp, int hostIndex) const
479+
std::string CcdbApi::getFullUrlForStorage(CURL* curl, const std::string& path, const std::string& objtype,
480+
const std::map<std::string, std::string>& metadata,
481+
long startValidityTimestamp, long endValidityTimestamp, int hostIndex) const
482482
{
483483
// Prepare timestamps
484-
string startValidityString = getTimestampString(startValidityTimestamp < 0 ? getCurrentTimestamp() : startValidityTimestamp);
485-
string endValidityString = getTimestampString(endValidityTimestamp < 0 ? getFutureTimestamp(60 * 60 * 24 * 1) : endValidityTimestamp);
484+
std::string startValidityString = getTimestampString(startValidityTimestamp < 0 ? getCurrentTimestamp() : startValidityTimestamp);
485+
std::string endValidityString = getTimestampString(endValidityTimestamp < 0 ? getFutureTimestamp(60 * 60 * 24 * 1) : endValidityTimestamp);
486486
// Get url
487-
string url = getHostUrl(hostIndex);
487+
std::string url = getHostUrl(hostIndex);
488488
// Build URL
489-
string fullUrl = url + "/" + path + "/" + startValidityString + "/" + endValidityString + "/";
489+
std::string fullUrl = url + "/" + path + "/" + startValidityString + "/" + endValidityString + "/";
490490
// Add type as part of metadata
491491
// we need to URL encode the object type, since in case it has special characters (like the "<", ">" for templated classes) it won't work otherwise
492492
char* objtypeEncoded = curl_easy_escape(curl, objtype.c_str(), objtype.size());
493-
fullUrl += "ObjectType=" + string(objtypeEncoded) + "/";
493+
fullUrl += "ObjectType=" + std::string(objtypeEncoded) + "/";
494494
curl_free(objtypeEncoded);
495495
// Add general metadata
496496
for (auto& kv : metadata) {
497-
string mfirst = kv.first;
498-
string msecond = kv.second;
497+
std::string mfirst = kv.first;
498+
std::string msecond = kv.second;
499499
// same trick for the metadata as for the object type
500500
char* mfirstEncoded = curl_easy_escape(curl, mfirst.c_str(), mfirst.size());
501501
char* msecondEncoded = curl_easy_escape(curl, msecond.c_str(), msecond.size());
502-
fullUrl += string(mfirstEncoded) + "=" + string(msecondEncoded) + "/";
502+
fullUrl += std::string(mfirstEncoded) + "=" + std::string(msecondEncoded) + "/";
503503
curl_free(mfirstEncoded);
504504
curl_free(msecondEncoded);
505505
}
506506
return fullUrl;
507507
}
508508

509509
// todo make a single method of the one above and below
510-
string CcdbApi::getFullUrlForRetrieval(CURL* curl, const string& path, const map<string, string>& metadata, long timestamp, int hostIndex) const
510+
std::string CcdbApi::getFullUrlForRetrieval(CURL* curl, const std::string& path, const std::map<std::string, std::string>& metadata, long timestamp, int hostIndex) const
511511
{
512512
if (mInSnapshotMode) {
513513
return getSnapshotFile(mSnapshotTopPath, path);
514514
}
515515

516516
// Prepare timestamps
517-
string validityString = getTimestampString(timestamp < 0 ? getCurrentTimestamp() : timestamp);
517+
std::string validityString = getTimestampString(timestamp < 0 ? getCurrentTimestamp() : timestamp);
518518
// Get host url
519-
string hostUrl = getHostUrl(hostIndex);
519+
std::string hostUrl = getHostUrl(hostIndex);
520520
// Build URL
521-
string fullUrl = hostUrl + "/" + path + "/" + validityString + "/";
521+
std::string fullUrl = hostUrl + "/" + path + "/" + validityString + "/";
522522
// Add metadata
523523
for (auto& kv : metadata) {
524-
string mfirst = kv.first;
525-
string msecond = kv.second;
524+
std::string mfirst = kv.first;
525+
std::string msecond = kv.second;
526526
// trick for the metadata in case it contains special characters
527527
char* mfirstEncoded = curl_easy_escape(curl, mfirst.c_str(), mfirst.size());
528528
char* msecondEncoded = curl_easy_escape(curl, msecond.c_str(), msecond.size());
529-
fullUrl += string(mfirstEncoded) + "=" + string(msecondEncoded) + "/";
529+
fullUrl += std::string(mfirstEncoded) + "=" + std::string(msecondEncoded) + "/";
530530
curl_free(mfirstEncoded);
531531
curl_free(msecondEncoded);
532532
}
@@ -755,7 +755,7 @@ bool CcdbApi::receiveObject(void* dataHolder, std::string const& path, std::map<
755755
CURLcode curlResultCode = CURL_LAST;
756756

757757
for (size_t hostIndex = 0; hostIndex < hostsPool.size() && (responseCode >= 400 || curlResultCode > 0); hostIndex++) {
758-
string fullUrl = getFullUrlForRetrieval(curlHandle, path, metadata, timestamp, hostIndex);
758+
std::string fullUrl = getFullUrlForRetrieval(curlHandle, path, metadata, timestamp, hostIndex);
759759
curl_easy_setopt(curlHandle, CURLOPT_URL, fullUrl.c_str());
760760

761761
curlResultCode = CURL_perform(curlHandle);
@@ -885,7 +885,7 @@ void CcdbApi::snapshot(std::string const& ccdbrootpath, std::string const& local
885885
{
886886
// query all subpaths to ccdbrootpath
887887
const auto allfolders = getAllFolders(ccdbrootpath);
888-
std::map<string, string> metadata;
888+
std::map<std::string, std::string> metadata;
889889
for (auto& folder : allfolders) {
890890
retrieveBlob(folder, localDir, metadata, timestamp);
891891
}
@@ -977,7 +977,7 @@ bool CcdbApi::initTGrid() const
977977
return gGrid != nullptr;
978978
}
979979

980-
void* CcdbApi::downloadFilesystemContent(std::string const& url, std::type_info const& tinfo, std::map<string, string>* headers) const
980+
void* CcdbApi::downloadFilesystemContent(std::string const& url, std::type_info const& tinfo, std::map<std::string, std::string>* headers) const
981981
{
982982
if ((url.find("alien:/", 0) != std::string::npos) && !initTGrid()) {
983983
return nullptr;
@@ -1016,7 +1016,7 @@ void* CcdbApi::interpretAsTMemFileAndExtract(char* contentptr, size_t contentsiz
10161016
}
10171017

10181018
// navigate sequence of URLs until TFile content is found; object is extracted and returned
1019-
void* CcdbApi::navigateURLsAndRetrieveContent(CURL* curl_handle, std::string const& url, std::type_info const& tinfo, std::map<string, string>* headers) const
1019+
void* CcdbApi::navigateURLsAndRetrieveContent(CURL* curl_handle, std::string const& url, std::type_info const& tinfo, std::map<std::string, std::string>* headers) const
10201020
{
10211021
// a global internal data structure that can be filled with HTTP header information
10221022
// static --> to avoid frequent alloc/dealloc as optimization
@@ -1164,7 +1164,7 @@ void* CcdbApi::retrieveFromTFile(std::type_info const& tinfo, std::string const&
11641164

11651165
CURL* curl_handle = curl_easy_init();
11661166
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, mUniqueAgentID.c_str());
1167-
string fullUrl = getFullUrlForRetrieval(curl_handle, path, metadata, timestamp); // todo check if function still works correctly in case mInSnapshotMode
1167+
std::string fullUrl = getFullUrlForRetrieval(curl_handle, path, metadata, timestamp); // todo check if function still works correctly in case mInSnapshotMode
11681168
// if we are in snapshot mode we can simply open the file; extract the object and return
11691169
if (mInSnapshotMode) {
11701170
auto res = extractFromLocalFile(fullUrl, tinfo, headers);
@@ -1218,8 +1218,8 @@ std::string CcdbApi::list(std::string const& path, bool latestOnly, std::string
12181218
curl_easy_setopt(curl, CURLOPT_USERAGENT, mUniqueAgentID.c_str());
12191219

12201220
struct curl_slist* headers = nullptr;
1221-
headers = curl_slist_append(headers, (string("Accept: ") + returnFormat).c_str());
1222-
headers = curl_slist_append(headers, (string("Content-Type: ") + returnFormat).c_str());
1221+
headers = curl_slist_append(headers, (std::string("Accept: ") + returnFormat).c_str());
1222+
headers = curl_slist_append(headers, (std::string("Content-Type: ") + returnFormat).c_str());
12231223
if (createdNotAfter >= 0) {
12241224
headers = curl_slist_append(headers, ("If-Not-After: " + std::to_string(createdNotAfter)).c_str());
12251225
}
@@ -1230,7 +1230,7 @@ std::string CcdbApi::list(std::string const& path, bool latestOnly, std::string
12301230

12311231
curlSetSSLOptions(curl);
12321232

1233-
string fullUrl;
1233+
std::string fullUrl;
12341234
// Perform the request, res will get the return code
12351235
for (size_t hostIndex = 0; hostIndex < hostsPool.size() && res != CURLE_OK; hostIndex++) {
12361236
fullUrl = getHostUrl(hostIndex);
@@ -1290,7 +1290,7 @@ void CcdbApi::truncate(std::string const& path) const
12901290
CURLcode res;
12911291
stringstream fullUrl;
12921292
for (size_t i = 0; i < hostsPool.size(); i++) {
1293-
string url = getHostUrl(i);
1293+
std::string url = getHostUrl(i);
12941294
fullUrl << url << "/truncate/" << path;
12951295

12961296
curl = curl_easy_init();
@@ -1436,7 +1436,7 @@ std::map<std::string, std::string> CcdbApi::retrieveHeaders(std::string const& p
14361436
auto do_remote_header_call = [this, &path, &metadata, timestamp]() -> std::map<std::string, std::string> {
14371437
CURL* curl = curl_easy_init();
14381438
CURLcode res = CURL_LAST;
1439-
string fullUrl = getFullUrlForRetrieval(curl, path, metadata, timestamp);
1439+
std::string fullUrl = getFullUrlForRetrieval(curl, path, metadata, timestamp);
14401440
std::map<std::string, std::string> headers;
14411441

14421442
if (curl != nullptr) {
@@ -1632,12 +1632,12 @@ int CcdbApi::updateMetadata(std::string const& path, std::map<std::string, std::
16321632
fullUrl << "?";
16331633

16341634
for (auto& kv : metadata) {
1635-
string mfirst = kv.first;
1636-
string msecond = kv.second;
1635+
std::string mfirst = kv.first;
1636+
std::string msecond = kv.second;
16371637
// same trick for the metadata as for the object type
16381638
char* mfirstEncoded = curl_easy_escape(curl, mfirst.c_str(), mfirst.size());
16391639
char* msecondEncoded = curl_easy_escape(curl, msecond.c_str(), msecond.size());
1640-
fullUrl << string(mfirstEncoded) + "=" + string(msecondEncoded) + "&";
1640+
fullUrl << std::string(mfirstEncoded) + "=" + std::string(msecondEncoded) + "&";
16411641
curl_free(mfirstEncoded);
16421642
curl_free(msecondEncoded);
16431643
}
@@ -1728,7 +1728,7 @@ void CcdbApi::scheduleDownload(RequestContext& requestContext, size_t* requestCo
17281728

17291729
CURL* curl_handle = curl_easy_init();
17301730
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, mUniqueAgentID.c_str());
1731-
string fullUrl = getFullUrlForRetrieval(curl_handle, requestContext.path, requestContext.metadata, requestContext.timestamp);
1731+
std::string fullUrl = getFullUrlForRetrieval(curl_handle, requestContext.path, requestContext.metadata, requestContext.timestamp);
17321732
curl_slist* options_list = nullptr;
17331733
initCurlHTTPHeaderOptionsForRetrieve(curl_handle, options_list, requestContext.timestamp, &requestContext.headers,
17341734
requestContext.etag, requestContext.createdNotAfter, requestContext.createdNotBefore);

CCDB/test/testBasicCCDBManager.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
using namespace o2::ccdb;
2828

29-
static string basePath;
29+
static std::string basePath;
3030
std::string ccdbUrl = "http://ccdb-test.cern.ch:8080";
3131
bool hostReachable = false;
3232

@@ -43,7 +43,7 @@ struct Fixture {
4343
std::cout << "Is host reachable ? --> " << hostReachable << std::endl;
4444
char hostname[_POSIX_HOST_NAME_MAX];
4545
gethostname(hostname, _POSIX_HOST_NAME_MAX);
46-
basePath = string("Test/") + hostname + "/pid" + getpid() + "/BasicCCDBManager/";
46+
basePath = std::string("Test/") + hostname + "/pid" + getpid() + "/BasicCCDBManager/";
4747
std::cout << "Path we will use in this test suite : " + basePath << std::endl;
4848
}
4949
~Fixture()

CCDB/test/testCcdbApi.cxx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ using namespace o2::ccdb;
4545
namespace utf = boost::unit_test;
4646
namespace tt = boost::test_tools;
4747

48-
static string ccdbUrl;
49-
static string basePath;
48+
static std::string ccdbUrl;
49+
static std::string basePath;
5050
bool hostReachable = false;
5151

5252
/**
@@ -63,7 +63,7 @@ struct Fixture {
6363
cout << "Is host reachable ? --> " << hostReachable << endl;
6464
char hostname[_POSIX_HOST_NAME_MAX];
6565
gethostname(hostname, _POSIX_HOST_NAME_MAX);
66-
basePath = string("Test/TestCcdbApi/") + hostname + "/pid" + getpid() + "/";
66+
basePath = std::string("Test/TestCcdbApi/") + hostname + "/pid" + getpid() + "/";
6767
// Replace dashes by underscores to avoid problems in the creation of local directories
6868
std::replace(basePath.begin(), basePath.end(), '-','_');
6969
cout << "Path we will use in this test suite : " + basePath << endl;
@@ -72,7 +72,7 @@ struct Fixture {
7272
{
7373
if (hostReachable) {
7474
CcdbApi api;
75-
map<string, string> metadata;
75+
std::map<std::string, std::string> metadata;
7676
api.init(ccdbUrl);
7777
api.truncate(basePath + "*");
7878
cout << "Test data truncated (" << basePath << ")" << endl;
@@ -104,7 +104,7 @@ struct test_fixture {
104104
~test_fixture() = default;
105105

106106
CcdbApi api;
107-
map<string, string> metadata;
107+
std::map<std::string, std::string> metadata;
108108
};
109109

110110
BOOST_AUTO_TEST_CASE(storeTMemFile_test, *utf::precondition(if_reachable()))
@@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE(store_retrieve_TMemFile_templated_test, *utf::precondition(
153153
BOOST_CHECK(f.api.retrieveFromTFileAny<o2::utils::RootChain>(basePath + "CCDBPath", f.metadata) == nullptr);
154154

155155
// try to get the headers back and to find the metadata
156-
map<string, string> md;
156+
std::map<std::string, std::string> md;
157157
path2 = f.api.retrieveFromTFileAny<o2::ccdb::IdPath>(basePath + "CCDBPath", f.metadata, -1, &md);
158158
BOOST_CHECK_EQUAL(md.count("Hello"), 1);
159159
BOOST_CHECK_EQUAL(md["Hello"], "World");
@@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(delete_test, *utf::precondition(if_reachable()))
345345
BOOST_CHECK(h2 == nullptr);
346346
}
347347

348-
void countItems(const string& s, int& countObjects, int& countSubfolders)
348+
void countItems(const std::string& s, int& countObjects, int& countSubfolders)
349349
{
350350
countObjects = 0;
351351
countSubfolders = 0;
@@ -368,7 +368,7 @@ BOOST_AUTO_TEST_CASE(list_test, *utf::precondition(if_reachable()))
368368
test_fixture f;
369369

370370
// test non-empty top dir
371-
string s = f.api.list("", "application/json"); // top dir
371+
std::string s = f.api.list("", "application/json"); // top dir
372372
long nbLines = std::count(s.begin(), s.end(), '\n') + 1;
373373
BOOST_CHECK(nbLines > 5);
374374

@@ -436,7 +436,7 @@ BOOST_AUTO_TEST_CASE(TestHeaderParsing)
436436
BOOST_AUTO_TEST_CASE(TestFetchingHeaders, *utf::precondition(if_reachable()))
437437
{
438438
// first store the object
439-
string objectPath = basePath + "objectETag";
439+
std::string objectPath = basePath + "objectETag";
440440
test_fixture f;
441441
TH1F h1("objectETag", "objectETag", 100, 0, 99);
442442
f.api.storeAsTFile(&h1, objectPath, f.metadata);
@@ -445,7 +445,7 @@ BOOST_AUTO_TEST_CASE(TestFetchingHeaders, *utf::precondition(if_reachable()))
445445
std::string etag;
446446
std::vector<std::string> headers;
447447
std::vector<std::string> pfns;
448-
string path = objectPath + "/" + std::to_string(getCurrentTimestamp());
448+
std::string path = objectPath + "/" + std::to_string(getCurrentTimestamp());
449449
auto updated = CcdbApi::getCCDBEntryHeaders("http://ccdb-test.cern.ch:8080/" + path, etag, headers);
450450
BOOST_CHECK_EQUAL(updated, true);
451451
BOOST_REQUIRE(headers.size() != 0);
@@ -462,7 +462,7 @@ BOOST_AUTO_TEST_CASE(TestRetrieveHeaders, *utf::precondition(if_reachable()))
462462

463463
TH1F h1("object1", "object1", 100, 0, 99);
464464
cout << "storing object 1 in " << basePath << "Test" << endl;
465-
map<string, string> metadata;
465+
std::map<std::string, std::string> metadata;
466466
metadata["custom"] = "whatever";
467467
f.api.storeAsTFile(&h1, basePath + "Test", metadata);
468468

@@ -498,7 +498,7 @@ BOOST_AUTO_TEST_CASE(TestUpdateMetadata, *utf::precondition(if_reachable()))
498498
// upload an object
499499
TH1F h1("object1", "object1", 100, 0, 99);
500500
cout << "storing object 1 in " << basePath << "Test" << endl;
501-
map<string, string> metadata;
501+
std::map<std::string, std::string> metadata;
502502
metadata["custom"] = "whatever";
503503
metadata["id"] = "first";
504504
f.api.storeAsTFile(&h1, basePath + "Test", metadata);
@@ -507,10 +507,10 @@ BOOST_AUTO_TEST_CASE(TestUpdateMetadata, *utf::precondition(if_reachable()))
507507
std::map<std::string, std::string> headers = f.api.retrieveHeaders(basePath + "Test", metadata);
508508
BOOST_CHECK(headers.count("custom") > 0);
509509
BOOST_CHECK(headers.at("custom") == "whatever");
510-
string firstID = headers.at("ETag");
510+
std::string firstID = headers.at("ETag");
511511
firstID.erase(std::remove(firstID.begin(), firstID.end(), '"'), firstID.end());
512512

513-
map<string, string> newMetadata;
513+
std::map<std::string, std::string> newMetadata;
514514
newMetadata["custom"] = "somethingelse";
515515

516516
// update the metadata and check
@@ -529,7 +529,7 @@ BOOST_AUTO_TEST_CASE(TestUpdateMetadata, *utf::precondition(if_reachable()))
529529
// get id
530530
cout << "get id" << endl;
531531
headers = f.api.retrieveHeaders(basePath + "Test", metadata);
532-
string secondID = headers.at("ETag");
532+
std::string secondID = headers.at("ETag");
533533
secondID.erase(std::remove(secondID.begin(), secondID.end(), '"'), secondID.end());
534534

535535
// update the metadata by id

CCDB/test/testCcdbApiMultipleUrls.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ using namespace o2::ccdb;
2424
namespace utf = boost::unit_test;
2525
namespace tt = boost::test_tools;
2626

27-
static string ccdbUrl;
28-
static string basePath;
27+
static std::string ccdbUrl;
28+
static std::string basePath;
2929
bool hostReachable = false;
3030

3131
/**
@@ -40,14 +40,14 @@ struct Fixture {
4040
cout << "ccdb url: " << ccdbUrl << endl;
4141
hostReachable = api.isHostReachable();
4242
cout << "Is host reachable ? --> " << hostReachable << endl;
43-
basePath = string("Test/pid") + getpid() + "/";
43+
basePath = std::string("Test/pid") + getpid() + "/";
4444
cout << "Path we will use in this test suite : " + basePath << endl;
4545
}
4646
~Fixture()
4747
{
4848
if (hostReachable) {
4949
CcdbApi api;
50-
map<string, string> metadata;
50+
std::map<std::string, std::string> metadata;
5151
api.init(ccdbUrl);
5252
api.truncate(basePath + "*");
5353
cout << "Test data truncated (" << basePath << ")" << endl;
@@ -79,7 +79,7 @@ struct test_fixture {
7979
~test_fixture() = default;
8080

8181
CcdbApi api;
82-
map<string, string> metadata;
82+
std::map<std::string, std::string> metadata;
8383
};
8484

8585
BOOST_AUTO_TEST_CASE(storeAndRetrieve, *utf::precondition(if_reachable()))

0 commit comments

Comments
 (0)