Skip to content

Commit 8618c04

Browse files
committed
DPL CCDB: move helper class to shared header
So that I can reuse it for the analysis code.
1 parent 0364324 commit 8618c04

File tree

4 files changed

+97
-53
lines changed

4 files changed

+97
-53
lines changed

Framework/CCDBSupport/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
1+
# Copyright 2019-2025 CERN and copyright holders of ALICE O2.
22
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
# All rights not expressly granted are reserved.
44
#
@@ -9,8 +9,9 @@
99
# granted to it by virtue of its status as an Intergovernmental Organization
1010
# or submit itself to any jurisdiction.
1111
o2_add_library(FrameworkCCDBSupport
12-
SOURCES
12+
SOURCES
1313
src/Plugin.cxx
14+
src/CCDBFetcherHelper.cxx
1415
src/CCDBHelpers.cxx
1516
PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/src
1617
PUBLIC_LINK_LIBRARIES O2::Framework O2::CCDB)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
#include "CCDBFetcherHelper.h"
12+
13+
namespace o2::framework
14+
{
15+
16+
o2::ccdb::CcdbApi& CCDBFetcherHelper::getAPI(const std::string& path)
17+
{
18+
// find the first = sign in the string. If present drop everything after it
19+
// and between it and the previous /.
20+
auto pos = path.find('=');
21+
if (pos == std::string::npos) {
22+
auto entry = remappings.find(path);
23+
return apis[entry == remappings.end() ? "" : entry->second];
24+
}
25+
auto pos2 = path.rfind('/', pos);
26+
if (pos2 == std::string::npos || pos2 == pos - 1 || pos2 == 0) {
27+
throw runtime_error_f("Malformed path %s", path.c_str());
28+
}
29+
auto entry = remappings.find(path.substr(0, pos2));
30+
return apis[entry == remappings.end() ? "" : entry->second];
31+
}
32+
} // o2::framework
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
#ifndef O2_FRAMEWORK_CCDBFETCHERHELPER_H_
12+
#define O2_FRAMEWORK_CCDBFETCHERHELPER_H_
13+
14+
#include "Framework/OutputRoute.h"
15+
#include "Framework/DataAllocator.h"
16+
#include "CCDB/CcdbApi.h"
17+
#include <unordered_map>
18+
#include <string>
19+
20+
namespace o2::framework
21+
{
22+
23+
struct CCDBFetcherHelper {
24+
struct CCDBCacheInfo {
25+
std::string etag;
26+
size_t cacheValidUntil = 0;
27+
size_t cachePopulatedAt = 0;
28+
size_t cacheMiss = 0;
29+
size_t cacheHit = 0;
30+
size_t minSize = -1ULL;
31+
size_t maxSize = 0;
32+
int lastCheckedTF = 0;
33+
};
34+
35+
struct RemapMatcher {
36+
std::string path;
37+
};
38+
39+
struct RemapTarget {
40+
std::string url;
41+
};
42+
43+
std::unordered_map<std::string, CCDBCacheInfo> mapURL2UUID;
44+
std::unordered_map<std::string, DataAllocator::CacheId> mapURL2DPLCache;
45+
std::string createdNotBefore = "0";
46+
std::string createdNotAfter = "3385078236000";
47+
std::unordered_map<std::string, o2::ccdb::CcdbApi> apis;
48+
std::vector<OutputRoute> routes;
49+
std::unordered_map<std::string, std::string> remappings;
50+
uint32_t lastCheckedTFCounterOrbReset = 0; // last checkecked TFcounter for bulk check
51+
int queryPeriodGlo = 1;
52+
int queryPeriodFactor = 1;
53+
int64_t timeToleranceMS = 5000;
54+
55+
o2::ccdb::CcdbApi& getAPI(const std::string& path);
56+
};
57+
58+
} // namespace o2::framework
59+
60+
#endif // O2_FRAMEWORK_CCDBFETCHERHELPER_H_

Framework/CCDBSupport/src/CCDBHelpers.cxx

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
22
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
// All rights not expressly granted are reserved.
44
//
@@ -10,6 +10,7 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "CCDBHelpers.h"
13+
#include "CCDBFetcherHelper.h"
1314
#include "Framework/DeviceSpec.h"
1415
#include "Framework/Logger.h"
1516
#include "Framework/TimingInfo.h"
@@ -28,56 +29,6 @@ O2_DECLARE_DYNAMIC_LOG(ccdb);
2829
namespace o2::framework
2930
{
3031

31-
struct CCDBFetcherHelper {
32-
struct CCDBCacheInfo {
33-
std::string etag;
34-
size_t cacheValidUntil = 0;
35-
size_t cachePopulatedAt = 0;
36-
size_t cacheMiss = 0;
37-
size_t cacheHit = 0;
38-
size_t minSize = -1ULL;
39-
size_t maxSize = 0;
40-
int lastCheckedTF = 0;
41-
};
42-
43-
struct RemapMatcher {
44-
std::string path;
45-
};
46-
47-
struct RemapTarget {
48-
std::string url;
49-
};
50-
51-
std::unordered_map<std::string, CCDBCacheInfo> mapURL2UUID;
52-
std::unordered_map<std::string, DataAllocator::CacheId> mapURL2DPLCache;
53-
std::string createdNotBefore = "0";
54-
std::string createdNotAfter = "3385078236000";
55-
std::unordered_map<std::string, o2::ccdb::CcdbApi> apis;
56-
std::vector<OutputRoute> routes;
57-
std::unordered_map<std::string, std::string> remappings;
58-
uint32_t lastCheckedTFCounterOrbReset = 0; // last checkecked TFcounter for bulk check
59-
int queryPeriodGlo = 1;
60-
int queryPeriodFactor = 1;
61-
int64_t timeToleranceMS = 5000;
62-
63-
o2::ccdb::CcdbApi& getAPI(const std::string& path)
64-
{
65-
// find the first = sign in the string. If present drop everything after it
66-
// and between it and the previous /.
67-
auto pos = path.find('=');
68-
if (pos == std::string::npos) {
69-
auto entry = remappings.find(path);
70-
return apis[entry == remappings.end() ? "" : entry->second];
71-
}
72-
auto pos2 = path.rfind('/', pos);
73-
if (pos2 == std::string::npos || pos2 == pos - 1 || pos2 == 0) {
74-
throw runtime_error_f("Malformed path %s", path.c_str());
75-
}
76-
auto entry = remappings.find(path.substr(0, pos2));
77-
return apis[entry == remappings.end() ? "" : entry->second];
78-
}
79-
};
80-
8132
bool isPrefix(std::string_view prefix, std::string_view full)
8233
{
8334
return prefix == full.substr(0, prefix.size());

0 commit comments

Comments
 (0)