Skip to content

Commit 9cf6eae

Browse files
authored
Merge branch 'dev' into dev
2 parents 058f32f + 39dbf61 commit 9cf6eae

589 files changed

Lines changed: 17136 additions & 8995 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,11 @@
1-
name: Check PR with clang-format
1+
---
2+
name: Formatting
23

3-
on: [pull_request_target]
4+
'on': [pull_request_target]
45

56
jobs:
6-
build:
7-
# We need at least 20.04 to install clang-format-11.
8-
runs-on: ubuntu-20.04
9-
10-
steps:
11-
- uses: actions/checkout@v2
12-
with:
13-
ref: ${{ github.event.pull_request.head.sha }}
14-
persist-credentials: false
15-
# We need the history of the dev branch all the way back to where the PR
16-
# diverged. We're fetching everything here, as we don't know how many
17-
# commits back that point is.
18-
fetch-depth: 0
19-
20-
- name: Install prerequisites
21-
env:
22-
DEBIAN_FRONTEND: noninteractive
23-
run: |
24-
sudo apt update -y
25-
sudo apt install -y clang-format-11
26-
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
27-
sudo update-alternatives --install /usr/bin/git-clang-format git-clang-format /usr/bin/git-clang-format-11 100
28-
29-
- name: Run clang format
30-
id: clang_format
31-
env:
32-
ALIBUILD_GITHUB_TOKEN: ${{secrets.ALIBUILD_GITHUB_TOKEN}}
33-
run: |
34-
set -x
35-
# We need to fetch the other commit.
36-
git fetch origin ${{ github.event.pull_request.base.ref }} \
37-
pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}
38-
39-
# We create a new branch which we will use for the eventual PR.
40-
git config --global user.email "alibuild@cern.ch"
41-
git config --global user.name "ALICE Action Bot"
42-
git checkout -b alibot-cleanup-${{ github.event.pull_request.number }} ${{ github.event.pull_request.head.sha }}
43-
44-
# github.event.pull_request.base.sha is the latest commit on the branch
45-
# the PR will be merged into, NOT the commit this PR derives from! For
46-
# that, we need to find the latest common ancestor between the PR and
47-
# the branch we are merging into.
48-
BASE_COMMIT=$(git merge-base HEAD ${{ github.event.pull_request.base.sha }})
49-
echo "Running clang-format against branch ${{ github.event.pull_request.base.ref }}, with hash ${{ github.event.pull_request.base.sha }}"
50-
COMMIT_FILES=$(git diff --diff-filter d --name-only "$BASE_COMMIT" -- ':!*LinkDef*' ':!Utilities/PCG/')
51-
if [ -z "$COMMIT_FILES" ]; then
52-
echo "No files to check" >&2
53-
echo ::set-output name=clean::true
54-
exit 0
55-
fi
56-
RESULT_OUTPUT="$(git-clang-format --commit $BASE_COMMIT --diff --style file $COMMIT_FILES)"
57-
58-
for x in $COMMIT_FILES; do
59-
case $x in
60-
*.hxx|*.cc|*.hpp) echo "$x uses non-allowed extension." && exit 1 ;;
61-
*) ;;
62-
esac
63-
done
64-
65-
if [ "$RESULT_OUTPUT" == 'no modified files to format' ] ||
66-
[ "$RESULT_OUTPUT" == 'clang-format did not modify any files' ]
67-
then
68-
echo "clang-format passed."
69-
git push --set-upstream https://alibuild:$ALIBUILD_GITHUB_TOKEN@github.com/alibuild/AliceO2.git :alibot-cleanup-${{ github.event.pull_request.number }} -f || true
70-
echo ::set-output name=clean::true
71-
else
72-
git-clang-format --diff --commit $BASE_COMMIT --style file $COMMIT_FILES |
73-
patch -p1
74-
echo "clang-format failed."
75-
echo "To reproduce it locally please run"
76-
echo -e "\tgit checkout ${{ github.event.pull_request.head.ref }}"
77-
echo -e "\tgit-clang-format --commit $BASE_COMMIT --diff --style file"
78-
echo "Note: using clang-format version $(clang-format --version)"
79-
echo "Opening a PR to your branch with the fixes"
80-
git commit -m "Please consider the following formatting changes" -a
81-
git show | cat
82-
git fetch https://github.com/AliceO2Group/AliceO2.git pull/${{ github.event.pull_request.number }}/head
83-
git push --set-upstream https://alibuild:$ALIBUILD_GITHUB_TOKEN@github.com/alibuild/AliceO2.git HEAD:refs/heads/alibot-cleanup-${{ github.event.pull_request.number }} -f
84-
echo ::set-output name=clean::false
85-
fi
86-
87-
- name: pull-request
88-
uses: alisw/pull-request@master
89-
with:
90-
source_branch: 'alibuild:alibot-cleanup-${{ github.event.pull_request.number }}'
91-
destination_branch: '${{ github.event.pull_request.head.label }}'
92-
github_token: ${{ secrets.ALIBUILD_GITHUB_TOKEN }}
93-
pr_title: "Please consider the following formatting changes to ${{ github.event.pull_request.repository.full_name }}#${{ github.event.pull_request.number }}"
94-
pr_body: |
95-
This PR cannot be merged as is. You should either run clang-format yourself and update the pull request, or merge this PR in yours.
96-
You can find AliceO2 coding conventions at http://github.com/AliceO2Group/CodingGuidelines.
97-
continue-on-error: true # We do not create PRs if the branch is not there.
98-
99-
- name: Exit with error if the PR is not clean
100-
run: |
101-
case ${{ steps.clang_format.outputs.clean }} in
102-
true) echo "PR clean" ; exit 0 ;;
103-
false) echo "PR not clean" ; exit 1 ;;
104-
esac
7+
formatting:
8+
name: PR formatting
9+
uses: alisw/ali-bot/.github/workflows/c++-code-formatting.yml@master
10+
secrets:
11+
alibuild_github_token: ${{ secrets.ALIBUILD_GITHUB_TOKEN }}

.github/workflows/pragmaonce.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/space-checker.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,17 @@ class CCDBManagerInstance
4646
std::string uuid;
4747
long startvalidity = 0;
4848
long endvalidity = -1;
49-
bool isBlob = false; // is this raw blob or parsed object?
5049
bool isValid(long ts) { return ts < endvalidity && ts > startvalidity; }
5150
void clear()
5251
{
5352
objPtr.reset();
5453
uuid = "";
5554
startvalidity = 0;
5655
endvalidity = -1;
57-
isBlob = false;
5856
}
5957
};
6058

6159
public:
62-
using BLOB = std::vector<char>;
6360
using MD = std::map<std::string, std::string>;
6461

6562
CCDBManagerInstance(std::string const& path) : mCCDBAccessor{}
@@ -103,11 +100,6 @@ class CCDBManagerInstance
103100
return getForTimeStamp<T>(path, mTimestamp);
104101
}
105102

106-
/// aliases for BLOB retrieval
107-
BLOB* getBlobForTimeStamp(std::string const& path, long timestamp) { return getForTimeStamp<BLOB>(path, timestamp); }
108-
BLOB* getSpecificBlob(std::string const& path, long timestamp = -1, MD metaData = MD()) { return getSpecific<BLOB>(path, timestamp, metaData); }
109-
BLOB* getBlob(std::string const& path) { return get<BLOB>(path); }
110-
111103
bool isHostReachable() const { return mCCDBAccessor.isHostReachable(); }
112104

113105
/// clear all entries in the cache
@@ -157,13 +149,13 @@ class CCDBManagerInstance
157149
/// set the fatal property (when false; nullptr object responses will not abort)
158150
void setFatalWhenNull(bool b) { mFatalWhenNull = b; }
159151

152+
/// a convenience function for MC to fetch
153+
/// valid timestamps given an ALICE run number
154+
std::pair<uint64_t, uint64_t> getRunDuration(int runnumber) const;
155+
160156
private:
161157
// method to print (fatal) error
162158
void reportFatal(std::string_view s);
163-
BLOB* createBlob(std::string const& path,
164-
MD const& metadata, long timestamp,
165-
MD* headers, std::string const& etag,
166-
const std::string& createdNotAfter, const std::string& createdNotBefore);
167159
// we access the CCDB via the CURL based C++ API
168160
o2::ccdb::CcdbApi mCCDBAccessor;
169161
std::unordered_map<std::string, CachedObject> mCache; //! map for {path, CachedObject} associations
@@ -185,53 +177,27 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
185177
{
186178
T* ptr = nullptr;
187179
if (!isCachingEnabled()) {
188-
if constexpr (std::is_same<T, BLOB>::value) {
189-
ptr = createBlob(path, mMetaData, timestamp, nullptr, "",
190-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
191-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
192-
} else {
193-
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, nullptr, "",
194-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
195-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
196-
}
180+
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, nullptr, "",
181+
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
182+
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
197183
if (!ptr && mFatalWhenNull) {
198184
reportFatal(std::string("Got nullptr from CCDB for path ") + path + std::string(" and timestamp ") + std::to_string(timestamp));
199185
}
200186
return ptr;
201187
}
202188
auto& cached = mCache[path];
203-
if constexpr (std::is_same<T, BLOB>::value) { // check if cached object type is consistent with requested one
204-
if (!cached.isBlob) {
205-
cached.clear();
206-
}
207-
} else {
208-
if (cached.isBlob) {
209-
cached.clear();
210-
}
211-
}
212189
if (mCheckObjValidityEnabled && cached.isValid(timestamp)) {
213190
return reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
214191
}
215-
if constexpr (std::is_same<T, BLOB>::value) {
216-
ptr = createBlob(path, mMetaData, timestamp, &mHeaders, cached.uuid,
217-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
218-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
219-
} else {
220-
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
221-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
222-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
223-
}
192+
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
193+
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
194+
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
224195
if (ptr) { // new object was shipped, old one (if any) is not valid anymore
225196
if constexpr (std::is_same<TGeoManager, T>::value) { // some special objects cannot be cached to shared_ptr since root may delete their raw global pointer
226197
cached.noCleanupPtr = ptr;
227198
} else {
228199
cached.objPtr.reset(ptr);
229200
}
230-
if constexpr (std::is_same<T, BLOB>::value) {
231-
cached.isBlob = true;
232-
} else {
233-
cached.isBlob = false;
234-
}
235201
cached.uuid = mHeaders["ETag"];
236202
cached.startvalidity = std::stol(mHeaders["Valid-From"]);
237203
cached.endvalidity = std::stol(mHeaders["Valid-Until"]);

CCDB/include/CCDB/CcdbApi.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CcdbApi //: public DatabaseInterface
5757
{
5858
public:
5959
/// \brief Default constructor
60-
CcdbApi() = default;
60+
CcdbApi();
6161
/// \brief Default destructor
6262
virtual ~CcdbApi();
6363

@@ -294,7 +294,7 @@ class CcdbApi //: public DatabaseInterface
294294
* @param headers the headers found in the request. Will be emptied when we return false.
295295
* @return true if the headers where updated WRT last time, false if the previous results can still be used.
296296
*/
297-
static bool getCCDBEntryHeaders(std::string const& url, std::string const& etag, std::vector<std::string>& headers);
297+
static bool getCCDBEntryHeaders(std::string const& url, std::string const& etag, std::vector<std::string>& headers, const std::string& agentID = "");
298298

299299
/**
300300
* Extract the possible locations for a file and check whether or not
@@ -342,7 +342,7 @@ class CcdbApi //: public DatabaseInterface
342342
void loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
343343
std::map<std::string, std::string> const& metadata, long timestamp,
344344
std::map<std::string, std::string>* headers, std::string const& etag,
345-
const std::string& createdNotAfter, const std::string& createdNotBefore) const;
345+
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot = true) const;
346346
void navigateURLsAndLoadFileToMemory(o2::pmr::vector<char>& dest, CURL* curl_handle, std::string const& url, std::map<string, string>* headers) const;
347347

348348
// the failure to load the file to memory is signaled by 0 size and non-0 capacity
@@ -361,6 +361,9 @@ class CcdbApi //: public DatabaseInterface
361361
#endif
362362

363363
private:
364+
// report what file is read and for which purpose
365+
void logReading(const std::string& fname, const std::string& comment) const;
366+
364367
/**
365368
* Initialize in local mode; Objects will be retrieved from snapshot
366369
*
@@ -455,8 +458,6 @@ class CcdbApi //: public DatabaseInterface
455458

456459
// initialize the TGrid (Alien connection)
457460
bool initTGrid() const;
458-
// checks if an alien token is available, required to make a TGrid connection
459-
bool checkAlienToken() const;
460461

461462
/// Queries the CCDB server and navigates through possible redirects until binary content is found; Retrieves content as instance
462463
/// given by tinfo if that is possible. Returns nullptr if something fails...
@@ -513,12 +514,14 @@ class CcdbApi //: public DatabaseInterface
513514
std::string getSnapshotFile(const std::string& topdir, const string& path) const { return getSnapshotDir(topdir, path) + "/snapshot.root"; }
514515

515516
/// Base URL of the CCDB (with port)
517+
std::string mUniqueAgentID{}; // Unique User-Agent ID communicated to server for logging
516518
std::string mUrl{};
517519
std::vector<std::string> hostsPool{};
518-
std::string mSnapshotTopPath{};
520+
std::string mSnapshotTopPath{}; // root of the snaphot in the snapshot backend mode, i.e. with init("file://<dir>) call
521+
std::string mSnapshotCachePath{}; // root of the local snapshot (to fill or impose, even if not in the snapshot backend mode)
522+
bool mPreferSnapshotCache = false; // if snapshot is available, don't try to query its validity even in non-snapshot backend mode
519523
bool mInSnapshotMode = false;
520524
mutable TGrid* mAlienInstance = nullptr; // a cached connection to TGrid (needed for Alien locations)
521-
bool mHaveAlienToken = false; // stores if an alien token is available
522525
static std::unique_ptr<TJAlienCredentials> mJAlienCredentials; // access JAliEn credentials
523526

524527
ClassDefNV(CcdbApi, 1);

CCDB/include/CCDB/CcdbObjectInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class CcdbObjectInfo
3232
static constexpr long MONTH = 30 * DAY;
3333
static constexpr long YEAR = 364 * DAY;
3434
static constexpr long INFINITE_TIMESTAMP = 9999999999999;
35+
static constexpr long INFINITE_TIMESTAMP_SECONDS = 2000000000; // not really inifinity, but close to std::numeric_limits<int>::max() till 18.05.2033
3536

3637
CcdbObjectInfo() = default;
3738
CcdbObjectInfo(std::string path, std::string objType, std::string flName,

0 commit comments

Comments
 (0)