Skip to content

Commit cc8a075

Browse files
committed
Always check gGrid before calling TGrid::Connect to alien
Suppress local caches of the TGrid::Connect pointer. Muliple TGrid::Connect lead to jalien connection loss.
1 parent a5bb3b4 commit cc8a075

File tree

10 files changed

+60
-18
lines changed

10 files changed

+60
-18
lines changed

CCDB/src/CcdbApi.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -958,14 +958,14 @@ void* CcdbApi::extractFromLocalFile(std::string const& filename, std::type_info
958958

959959
bool CcdbApi::initTGrid() const
960960
{
961-
if (mNeedAlienToken && !mAlienInstance) {
961+
if (mNeedAlienToken && !gGrid) {
962962
static bool allowNoToken = getenv("ALICEO2_CCDB_NOTOKENCHECK") && atoi(getenv("ALICEO2_CCDB_NOTOKENCHECK"));
963963
if (!allowNoToken && !checkAlienToken()) {
964964
LOG(fatal) << "Alien Token Check failed - Please get an alien token before running with https CCDB endpoint, or alice-ccdb.cern.ch!";
965965
}
966-
mAlienInstance = TGrid::Connect("alien");
966+
TGrid::Connect("alien");
967967
static bool errorShown = false;
968-
if (!mAlienInstance && errorShown == false) {
968+
if (!gGrid && errorShown == false) {
969969
if (allowNoToken) {
970970
LOG(error) << "TGrid::Connect returned nullptr. May be due to missing alien token";
971971
} else {
@@ -974,7 +974,7 @@ bool CcdbApi::initTGrid() const
974974
errorShown = true;
975975
}
976976
}
977-
return mAlienInstance != nullptr;
977+
return gGrid != nullptr;
978978
}
979979

980980
void* CcdbApi::downloadFilesystemContent(std::string const& url, std::type_info const& tinfo, std::map<string, string>* headers) const

Detectors/TRD/base/macros/OCDB2CCDB.C

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
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+
112
// Use this macro to extract TRD calibration data from run2 for O2 calibrations class
213
// Alot of this was taken from OCDBtoTree.C in AliRoot/TRD/macros/
314
// Usage:
@@ -230,7 +241,7 @@ void OCDB2CCDB(long timeStamp = -1, TString ccdbPath = "http://localhost:8080",
230241
TTimeStamp jobStartTime;
231242
// if the storage is on alien than we need to do some extra stuff
232243
TString storageString(storageURI);
233-
if (storageString.Contains("alien://")) {
244+
if (storageString.Contains("alien://") && !gGrid) {
234245
TGrid::Connect("alien://");
235246
}
236247

Detectors/TRD/base/macros/OCDB2CCDBTrapConfig.C

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
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+
112
// Use this macro to extract TRD calibration data from run2 for O2 calibrations class
213
// Alot of this was taken from OCDBtoTree.C in AliRoot/TRD/macros/
314
// Usage:
@@ -172,7 +183,7 @@ void OCDB2CCDBTrapConfig(TString ccdbPath = "http://localhost:8080", Int_t run =
172183
TTimeStamp jobStartTime;
173184
// if the storage is on alien than we need to do some extra stuff
174185
TString storageString(storageURI);
175-
if (storageString.Contains("raw://")) {
186+
if (storageString.Contains("raw://") && !gGrid) {
176187
TGrid::Connect("alien://");
177188
}
178189

Detectors/TRD/base/macros/PrintTrapConfig.C

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
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+
112
// Use this macro to extract TRD calibration data from run2 for O2 calibrations class
213
// Alot of this was taken from OCDBtoTree.C in AliRoot/TRD/macros/
314
// Usage:
@@ -200,7 +211,7 @@ void PrintTrapConfig(Int_t run, const Char_t* storageURI = "alien://folder=/alic
200211
TTimeStamp jobStartTime;
201212
// if the storage is on alien than we need to do some extra stuff
202213
TString storageString(storageURI);
203-
if (storageString.Contains("alien://")) {
214+
if (storageString.Contains("alien://") && !gGrid) {
204215
TGrid::Connect("alien://");
205216
}
206217

Detectors/TRD/base/macros/Readocdb.C

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
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+
112
// Use this macro to extract TRD calibration data from run2 for O2 calibrations class
213
// Alot of this was taken from OCDBtoTree.C in AliRoot/TRD/macros/
314
// Usage:
@@ -217,7 +228,7 @@ void Readocdb(Int_t run, const Char_t* storageURI = "alien://folder=/alice/data/
217228
TTimeStamp jobStartTime;
218229
// if the storage is on alien than we need to do some extra stuff
219230
TString storageString(storageURI);
220-
if (storageString.Contains("alien://")) {
231+
if (storageString.Contains("alien://") && !gGrid) {
221232
TGrid::Connect("alien://");
222233
}
223234

Framework/AODMerger/src/aodMerger.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ int main(int argc, char* argv[])
107107
std::ifstream in;
108108
in.open(inputCollection);
109109
TString line;
110-
bool connectedToAliEn = false;
111110
TMap* metaData = nullptr;
112111
TMap* parentFiles = nullptr;
113112
int totalMergedDFs = 0;
@@ -119,10 +118,9 @@ int main(int argc, char* argv[])
119118
continue;
120119
}
121120

122-
if (line.BeginsWith("alien:") && !connectedToAliEn) {
121+
if (line.BeginsWith("alien:") && !gGrid) {
123122
printf("Connecting to AliEn...");
124123
TGrid::Connect("alien:");
125-
connectedToAliEn = true; // Only try once
126124
}
127125

128126
printf("Processing input file: %s\n", line.Data());

Framework/AODMerger/src/aodThinner.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int main(int argc, char* argv[])
102102
}
103103
TDirectory* outputDir = nullptr;
104104

105-
if (inputFileName.find("alien:") == 0) {
105+
if (inputFileName.find("alien:") == 0 && !gGrid) {
106106
printf("Connecting to AliEn...");
107107
TGrid::Connect("alien:");
108108
}

Framework/AnalysisSupport/src/DataInputDirector.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void DataInputDescriptor::addFileNameHolder(FileNameHolder* fn)
114114
// remove leading file:// from file name
115115
if (fn->fileName.rfind("file://", 0) == 0) {
116116
fn->fileName.erase(0, 7);
117-
} else if (!mAlienSupport && fn->fileName.rfind("alien://", 0) == 0) {
117+
} else if (!mAlienSupport && fn->fileName.rfind("alien://", 0) == 0 && !gGrid) {
118118
LOGP(debug, "AliEn file requested. Enabling support.");
119119
TGrid::Connect("alien://");
120120
mAlienSupport = true;

Framework/AnalysisSupport/src/Plugin.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ struct DiscoverMetadataInAOD : o2::framework::ConfigDiscoveryPlugin {
192192
std::getline(file, filename);
193193
file.close();
194194
}
195-
if (filename.rfind("alien://", 0) == 0) {
195+
if (filename.rfind("alien://", 0) == 0 && !gGrid) {
196196
TGrid::Connect("alien://");
197197
}
198198
LOGP(info, "Loading metadata from file {} in PID {}", filename, getpid());
@@ -245,7 +245,7 @@ struct DiscoverMetadataInAOD : o2::framework::ConfigDiscoveryPlugin {
245245
}
246246
}
247247

248-
if (parentFilename.starts_with("alien://")) {
248+
if (parentFilename.starts_with("alien://") && !gGrid) {
249249
TGrid::Connect("alien://");
250250
}
251251

Generators/src/GeneratorFromFile.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ GeneratorFromO2Kine::GeneratorFromO2Kine(const char* name)
177177
setPositionUnit(1.);
178178
setTimeUnit(1.);
179179

180-
if (strncmp(name, "alien:/", 7) == 0) {
181-
mAlienInstance = TGrid::Connect("alien");
182-
if (!mAlienInstance) {
180+
if (strncmp(name, "alien:/", 7) == 0 && !gGrid) {
181+
TGrid::Connect("alien:");
182+
if (!gGrid) {
183183
LOG(fatal) << "Could not connect to alien, did you check the alien token?";
184184
return;
185185
}

0 commit comments

Comments
 (0)