Logo ROOT   6.21/01
Reference Guide
TDataSetManagerAliEn.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Dario Berzano, 26.11.12
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TDataSetManagerAliEn //
15 // //
16 // Implementation of TDataSetManager dynamically creating datasets //
17 // by querying the AliEn file catalog. Retrieved information is cached. //
18 // //
19 //////////////////////////////////////////////////////////////////////////
20 
21 #include "TDataSetManagerAliEn.h"
22 #include "TError.h"
23 
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Constructor
28 
29 TAliEnFind::TAliEnFind(const TString &basePath, const TString &fileName,
30  const TString &anchor, const Bool_t archSubst, const TString &treeName,
31  const TString &regexp, const TString &query) :
32  fBasePath(basePath), fFileName(fileName), fTreeName(treeName),
33  fRegexpRaw(regexp), fAnchor(anchor), fQuery(query), fArchSubst(archSubst),
34  fRegexp(0), fSearchId(""), fGridResult(0)
35 {
36  if (fArchSubst) fAnchor = ""; // no anchor when substituting zipfile
37  if (!fRegexpRaw.IsNull())
38  fRegexp = new TPMERegexp(regexp);
39 }
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Copy constructor. Cached query result is not copied
43 
45 {
46  fBasePath = src.fBasePath;
47  fFileName = src.fFileName;
48  fAnchor = src.fAnchor;
49  fArchSubst = src.fArchSubst;
50  fQuery = src.fQuery;
51  fTreeName = src.fTreeName;
52  fRegexpRaw = src.fRegexpRaw;
53 
54  if (src.fRegexp)
55  fRegexp = new TPMERegexp( *(src.fRegexp) );
56  else
57  fRegexp = NULL;
58 
59  fGridResult = NULL;
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// Assignment operator. Cached query result is not copied
64 
66 {
67  if (&rhs != this) {
68  fBasePath = rhs.fBasePath;
69  fFileName = rhs.fFileName;
70  fAnchor = rhs.fAnchor;
71  fArchSubst = rhs.fArchSubst;
72  fQuery = rhs.fQuery;
73  fTreeName = rhs.fTreeName;
74 
75  SetRegexp(rhs.fRegexpRaw);
76 
79  }
80 
81  return *this;
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Destructor
86 
88 {
89  if (fRegexp) delete fRegexp;
90  if (fGridResult) delete fGridResult;
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Query the AliEn file catalog
95 
97 {
98  if (fGridResult && !forceNewQuery) {
99  if (gDebug >= 1)
100  Info("GetGridResult", "Returning cached AliEn find results");
101  return fGridResult;
102  }
103  else if (gDebug >= 1) {
104  Info("GetGridResult", "Querying AliEn file catalog");
105  }
106 
108 
109  if (!gGrid) {
110  TGrid::Connect("alien:");
111  if (!gGrid) return NULL;
112  }
113 
114  if (gDebug >= 1) {
115  Info("GetGridResult", "AliEn find %s %s [regexp=%s] [archsubst=%d]",
117  }
118 
120  if (!fGridResult) return NULL;
121 
122  if (fRegexp || fArchSubst || !fAnchor.IsNull() || !fQuery.IsNull()) {
123 
124  TPMERegexp *reArchSubst = NULL;
125  TString substWith;
126  if (fArchSubst) {
127  TString temp;
128  temp.Form("/%s$", fFileName.Data());
129  reArchSubst = new TPMERegexp(temp.Data());
130  if (fQuery) {
131  substWith.Form("/root_archive.zip?%s#%s", fQuery.Data(),
132  fFileName.Data());
133  }
134  else {
135  substWith.Form("/root_archive.zip#%s", fFileName.Data());
136  }
137  }
138 
139  TIter it(fGridResult);
140  TMap *map;
141  TObjString *os;
142  TString tUrl;
143 
144  while (( map = dynamic_cast<TMap *>(it.Next()) ) != NULL) {
145 
146  os = dynamic_cast<TObjString *>( map->GetValue("turl") );
147  if (!os) continue;
148  tUrl = os->String();
149 
150  if (fRegexp && (fRegexp->Match(tUrl) == 0)) {
151  // Remove object if it does not match expression
152  TObject *exmap = fGridResult->Remove(map);
153  if (exmap) delete exmap; // Remove() does not delete
154  }
155 
156  if (reArchSubst) {
157  // Substitute file_name with containing_archive.zip#file_name
158  reArchSubst->Substitute(tUrl, substWith, kFALSE);
159  os->SetString(tUrl.Data());
160  }
161  else if (!fAnchor.IsNull()) {
162  // Append anchor (and, possibly, query first)
163  if (!fQuery.IsNull()) {
164  tUrl.Append("?");
165  tUrl.Append(fQuery);
166  }
167  tUrl.Append("#");
168  tUrl.Append(fAnchor);
169  os->SetString(tUrl.Data());
170  }
171  else if (!fQuery.IsNull()) {
172  // Append query only
173  tUrl.Append("?");
174  tUrl.Append(fQuery);
175  os->SetString(tUrl.Data());
176  }
177  }
178 
179  if (reArchSubst) delete reArchSubst;
180  }
181 
182  return fGridResult;
183 }
184 
185 ////////////////////////////////////////////////////////////////////////////////
186 
188 {
189  if (fSearchId.IsNull()) {
190  TString searchIdStr;
191  searchIdStr.Form("BasePath=%s FileName=%s Anchor=%s ArchSubst=%d "
192  "TreeName=%s Regexp=%s",
195  TMD5 *md5 = new TMD5();
196  md5->Update( (const UChar_t *)searchIdStr.Data(),
197  (UInt_t)searchIdStr.Length() );
198  md5->Final();
199  fSearchId = md5->AsString();
200  delete md5;
201  }
202  if (gDebug >= 2)
203  Info("GetSearchId", "Returning search ID %s", fSearchId.Data());
204  return fSearchId.Data();
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 
210 {
211  GetGridResult(forceNewQuery);
212  if (!fGridResult) return NULL;
213 
214  Int_t nEntries = fGridResult->GetEntries();
216 
217  for (Int_t i=0; i<nEntries; i++) {
218 
219  Long64_t size = TString(fGridResult->GetKey(i, "size")).Atoll();
220 
221  TString tUrl = fGridResult->GetKey(i, "turl");
222 
223  if (gDebug >= 2)
224  Info("GetCollection", ">> %s", tUrl.Data());
225 
226  // Append to TFileCollection: url, size, guid, md5
227  TFileInfo *fi = new TFileInfo( tUrl, size, fGridResult->GetKey(i, "guid"),
228  fGridResult->GetKey(i, "md5") );
229 
230  fc->Add(fi);
231 
232  }
233 
234  if (fTreeName != "")
235  fc->SetDefaultTreeName(fTreeName.Data());
236 
237  fc->Update(); // needed for summary info
238 
239  return fc;
240 }
241 
242 ////////////////////////////////////////////////////////////////////////////////
243 
244 void TAliEnFind::Print(Option_t* opt) const
245 {
246  if (opt) {} // silence warning
247  Printf("BasePath=%s FileName=%s Anchor=%s ArchSubst=%d "
248  "TreeName=%s Regexp=%s (query %s a result)",
250  fTreeName.Data(), fRegexpRaw.Data(), (fGridResult ? "has" : "has not"));
251 }
252 
253 ////////////////////////////////////////////////////////////////////////////////
254 
255 void TAliEnFind::SetBasePath(const char *basePath)
256 {
257  if (fBasePath.EqualTo(basePath)) return;
258  fBasePath = basePath;
261 }
262 
263 ////////////////////////////////////////////////////////////////////////////////
264 
265 void TAliEnFind::SetFileName(const char *fileName)
266 {
267  if (fFileName.EqualTo(fileName)) return;
268  fFileName = fileName;
271 }
272 
273 ////////////////////////////////////////////////////////////////////////////////
274 
275 void TAliEnFind::SetAnchor(const char *anchor)
276 {
277  if (fAnchor.EqualTo(anchor)) return;
278  fAnchor = anchor;
281 }
282 
283 ////////////////////////////////////////////////////////////////////////////////
284 
285 void TAliEnFind::SetTreeName(const char *treeName)
286 {
287  if (fTreeName.EqualTo(treeName)) return;
288  fTreeName = treeName;
290 }
291 
292 ////////////////////////////////////////////////////////////////////////////////
293 
295 {
296  if (fArchSubst == archSubst) return;
297  fArchSubst = archSubst;
300 }
301 
302 ////////////////////////////////////////////////////////////////////////////////
303 
304 void TAliEnFind::SetRegexp(const char *regexp)
305 {
306  if (fRegexpRaw.EqualTo(regexp)) return;
307 
308  fRegexpRaw = regexp;
309  if (fRegexp) delete fRegexp;
310  if (!fRegexpRaw.IsNull())
311  fRegexp = new TPMERegexp(regexp);
312  else
313  fRegexp = NULL;
314 
317 }
318 
319 ////////////////////////////////////////////////////////////////////////////////
320 
322 {
323  if (!fSearchId.IsNull())
324  fSearchId = "";
325 }
326 
327 ////////////////////////////////////////////////////////////////////////////////
328 
330 {
331  if (fGridResult) {
332  delete fGridResult;
333  fGridResult = NULL;
334  }
335 }
336 
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 
342  ULong_t cacheExpire_s)
343 {
344  kfNoopRedirUrl = new TUrl("noop://redir");
345  kfNoopUnknownUrl = new TUrl("noop://unknown");
346  kfNoopNoneUrl = new TUrl("noop://none");
347 
348  fCacheExpire_s = cacheExpire_s;
349  fUrlRe = new TPMERegexp("^alien://(.*)$");
350  fUrlTpl = urlTpl;
351 
352  if (fUrlTpl.Contains("<path>")) {
353  // Ordinary pattern, something like root://host/prefix/<path>
354  fUrlTpl.ReplaceAll("<path>", "$1");
355  }
356  else {
357  // No <path> to substitute: assume it is a SE (storage element) name
358  fReadFromSE = kTRUE;
359  }
360 
361  TString dsDirFmt;
362  dsDirFmt.Form("dir:%s perms:open", cacheDir.Data());
363  fCache = new TDataSetManagerFile("_cache_", "_cache_", dsDirFmt);
364 
366  Error("Init", "Cannot initialize cache on directory %s", cacheDir.Data());
368  return;
369  }
370 
371  // Provided for compatibility
372  ResetBit(TDataSetManager::kAllowRegister); // impossible to register
373  ResetBit(TDataSetManager::kCheckQuota); // quota control off
374 
375  if (gDebug >= 1) {
376  Info("TDataSetManagerAliEn", "Caching on %s", cacheDir.Data());
377  Info("TDataSetManagerAliEn", "URL schema: %s", urlTpl.Data());
378  Info("TDataSetManagerAliEn", "Cache expires after: %lus", cacheExpire_s);
379  }
380 }
381 
382 ////////////////////////////////////////////////////////////////////////////////
383 
385  const char *urlTpl, ULong_t cacheExpire_s)
386  : TDataSetManager("", "", ""), fUrlRe(0), fCache(0), fReadFromSE(kFALSE),
387  kfNoopRedirUrl(0), kfNoopUnknownUrl(0), kfNoopNoneUrl(0)
388 {
389  Init(cacheDir, urlTpl, cacheExpire_s);
390 }
391 
392 ////////////////////////////////////////////////////////////////////////////////
393 /// Compatibility with the plugin manager
394 
396  const char *cfgStr) : TDataSetManager("", "", ""), fUrlRe(0), fCache(0),
397  fReadFromSE(kFALSE), kfNoopRedirUrl(0), kfNoopUnknownUrl(0), kfNoopNoneUrl(0)
398 {
399  TPMERegexp reCache("(^| )cache:([^ ]+)( |$)");
400  if (reCache.Match(cfgStr) != 4) {
401  Error("TDataSetManagerAliEn", "No cache directory specified");
403  return;
404  }
405 
406  TPMERegexp reUrlTpl("(^| )urltemplate:([^ ]+)( |$)");
407  if (reUrlTpl.Match(cfgStr) != 4) {
408  Error("TDataSetManagerAliEn", "No local URL template specified");
410  return;
411  }
412 
413  TPMERegexp reCacheExpire("(^| )cacheexpiresecs:([0-9]+)( |$)");
414  if (reCacheExpire.Match(cfgStr) != 4) {
415  Error("TDataSetManagerAliEn", "No cache expiration set");
417  return;
418  }
419 
420  Init(reCache[2], reUrlTpl[2], (ULong_t)reCacheExpire[2].Atoll());
421 }
422 
423 ////////////////////////////////////////////////////////////////////////////////
424 
426 {
427  if (fCache) delete fCache;
428  if (fUrlRe) delete fUrlRe;
429  if (kfNoopRedirUrl) delete kfNoopRedirUrl;
431  if (kfNoopNoneUrl) delete kfNoopNoneUrl;
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// Parse kind
436 
438  EDataMode &dataMode, Bool_t &forceUpdate)
439 {
440  TPMERegexp reKind("^(Data;|Sim;|Find;)");
441  if (reKind.Match(uri) != 2) {
442  Error("GetFindCommandsFromUri", "Data, Sim or Find not specified");
443  return NULL;
444  }
445 
446  // Parse data mode (remote, local, cache -- optional)
447  TPMERegexp reMode("(^|;)Mode=([A-Za-z]+)(;|$)");
448  if (reMode.Match(uri) != 4) {
449  dataMode = kDataLocal; // default
450  }
451  else {
452  if (reMode[2].EqualTo("remote", TString::kIgnoreCase))
453  dataMode = kDataRemote;
454  else if (reMode[2].EqualTo("local", TString::kIgnoreCase))
455  dataMode = kDataLocal;
456  else if (reMode[2].EqualTo("cache", TString::kIgnoreCase))
457  dataMode = kDataCache;
458  else {
459  Error("GetFindCommandsFromUri",
460  "Wrong analysis mode specified: use one of: Mode=remote, local, cache");
461  return NULL; // no mode is ok, but wrong mode is not
462  }
463  }
464 
465  TList *findCommands = NULL;
466 
467  if (reKind[1].BeginsWith("Find")) {
468 
469  TString basePath;
470  TString fileName;
471  TString anchor;
472  TString query;
473  TString treeName;
474  TString regexp;
475 
476  // Custom search URI
477  if (!ParseCustomFindUri(uri, basePath, fileName, anchor, query, treeName,
478  regexp)) {
479  Error("GetFindCommandsFromUri", "Malformed AliEn find command");
480  return NULL;
481  }
482 
483  findCommands = new TList();
484  findCommands->SetOwner();
485  findCommands->Add( new TAliEnFind(basePath, fileName, anchor, kFALSE,
486  treeName, regexp, query) );
487 
488  }
489  else { // Data or Sim
490  Bool_t sim = (reKind[1][0] == 'S');
491  TString lhcPeriod;
492  Int_t year;
493  std::vector<Int_t> *runList;
494  Bool_t esd;
495  Int_t aodNum;
496  TString pass;
497 
498  if (!ParseOfficialDataUri(uri, sim, lhcPeriod, year, runList, esd,
499  aodNum, pass)) {
500  Error("GetFindCommandsFromUri", "Invalid parameters");
501  delete runList;
502  return NULL;
503  }
504 
505  findCommands = new TList();
506  findCommands->SetOwner(kTRUE);
507 
508  TString basePathRun;
509 
510  if (!gGrid) {
511  TGrid::Connect("alien:");
512  if (!gGrid) {
513  delete findCommands;
514  delete runList;
515  return NULL;
516  }
517  }
518 
519  if (sim) {
520  // Montecarlo init.
521  // Check whether this period is in /alice/sim/<period> or in
522  // /alice/sim/<year>/<period> and act properly, since naming convention
523  // is unclear!
524 
525  // Check once for all
526  basePathRun.Form("/alice/sim/%s", lhcPeriod.Data()); // no year
527  if (!gGrid->Cd(basePathRun.Data())) {
528  basePathRun.Form("/alice/sim/%d/%s", year, lhcPeriod.Data());
529  }
530  }
531  else {
532  // Real data init.
533  // Parse the pass string: if it starts with a number, prepend "pass"
534  if ((pass[0] >= '0') && (pass[0] <= '9')) pass.Prepend("pass");
535  basePathRun.Form("/alice/data/%d/%s", year, lhcPeriod.Data());
536  }
537 
538  // Form a list of valid runs (to avoid unnecessary queries when run ranges
539  // are specified)
540  std::vector<Int_t> validRuns;
541  {
542  TGridResult *validRunDirs = gGrid->Ls( basePathRun.Data() );
543  if (!validRunDirs) return NULL;
544 
545  TIter nrd(validRunDirs);
546  TMap *dir;
547  TObjString *os;
548  validRuns.resize( (size_t)(validRunDirs->GetEntries()) );
549 
550  while (( dir = dynamic_cast<TMap *>(nrd()) ) != NULL) {
551  os = dynamic_cast<TObjString *>( dir->GetValue("name") );
552  if (!os) continue;
553  Int_t run = (os->String()).Atoi();
554  if (run > 0) validRuns.push_back(run);
555  }
556  }
557 
558  for (UInt_t i=0; i<runList->size(); i++) {
559 
560  // Check if current run is valid
561  Bool_t valid = kFALSE;
562  for (UInt_t j=0; j<validRuns.size(); j++) {
563  if (validRuns[j] == (*runList)[i]) {
564  valid = kTRUE;
565  break;
566  }
567  }
568  if (!valid) {
569  //if (gDebug >=1) {
570  Warning("TDataSetManagerAliEn::GetFindCommandsFromUri",
571  "Avoiding unnecessary find on run %d: not found", (*runList)[i]);
572  //}
573  continue;
574  }
575  else if (gDebug >= 1) {
576  Info("TDataSetManagerAliEn::GetFindCommandsFromUri", "Run found: %d", (*runList)[i]);
577  }
578 
579  // Here we need to assemble the find string
580  TString basePath, fileName, temp;
581 
582  if (sim) {
583  // Montecarlo
584  temp.Form("/%06d", runList->at(i));
585  basePath = basePathRun + temp;
586 
587  if (!esd) {
588  temp.Form("/AOD%03d", aodNum);
589  basePath.Append(temp);
590  }
591  }
592  else {
593  // Real data
594  temp.Form("/%09d/ESDs/%s", runList->at(i), pass.Data());
595  basePath = basePathRun + temp;
596  if (esd) {
597  basePath.Append("/*.*");
598  }
599  else {
600  temp.Form("/AOD%03d", aodNum);
601  basePath.Append(temp);
602  }
603  }
604 
605  TString treeName;
606 
607  // File name and tree name
608  if (esd) {
609  fileName = "AliESDs.root";
610  treeName = "/esdTree";
611  }
612  else {
613  fileName = "AliAOD.root";
614  treeName = "/aodTree";
615  }
616 
617  findCommands->Add( new TAliEnFind(basePath, fileName, "", kTRUE,
618  treeName) );
619 
620  }
621 
622  delete runList;
623 
624  }
625 
626  // Force update or use cache (when possible)
627  TPMERegexp reForceUpdate("(^|;)ForceUpdate(;|$)");
628  forceUpdate = (reForceUpdate.Match(uri) == 3);
629 
630  // If no valid data was found, then findCommands is NULL
631  return findCommands;
632 }
633 
634 ////////////////////////////////////////////////////////////////////////////////
635 
637  TString &basePath, TString &fileName, TString &anchor, TString &query,
638  TString &treeName, TString &regexp)
639 {
640  // Copy URI to a dummy URI parsed to look for unrecognized stuff; initial
641  // part is known ("Find;") and stripped
642  TString checkUri = uri(5, uri.Length());
643 
644  // Mode and ForceUpdate (strip them from the check string)
645  TPMERegexp reMode("(^|;)(Mode=[A-Za-z]+)(;|$)");
646  if (reMode.Match(uri) == 4)
647  checkUri.ReplaceAll(reMode[2], "");
648  TPMERegexp reForceUpdate("(^|;)(ForceUpdate)(;|$)");
649  if (reForceUpdate.Match(uri) == 4)
650  checkUri.ReplaceAll(reForceUpdate[2], "");
651 
652  // Base path
653  TPMERegexp reBasePath("(^|;)(BasePath=([^; ]+))(;|$)");
654  if (reBasePath.Match(uri) != 5) {
655  ::Error("TDataSetManagerAliEn::ParseCustomFindUri",
656  "Base path not specified");
657  return kFALSE;
658  }
659  checkUri.ReplaceAll(reBasePath[2], "");
660  basePath = reBasePath[3];
661 
662  // File name
663  TPMERegexp reFileName("(^|;)(FileName=([^; ]+))(;|$)");
664  if (reFileName.Match(uri) != 5) {
665  ::Error("TDataSetManagerAliEn::ParseCustomFindUri",
666  "File name not specified");
667  return kFALSE;
668  }
669  checkUri.ReplaceAll(reFileName[2], "");
670  fileName = reFileName[3];
671 
672  // Anchor (optional)
673  TPMERegexp reAnchor("(^|;)(Anchor=([^; ]+))(;|$)");
674  if (reAnchor.Match(uri) != 5)
675  anchor = "";
676  else {
677  checkUri.ReplaceAll(reAnchor[2], "");
678  anchor = reAnchor[3];
679  }
680 
681  // Query string (optional)
682  TPMERegexp reQuery("(^|;)(Query=([^; ]+))(;|$)");
683  if (reQuery.Match(uri) != 5)
684  query = "";
685  else {
686  checkUri.ReplaceAll(reQuery[2], "");
687  query = reQuery[3];
688  }
689 
690  // Tree name (optional)
691  TPMERegexp reTreeName("(^|;)(Tree=(/[^; ]+))(;|$)");
692  if (reTreeName.Match(uri) != 5)
693  treeName = "";
694  else {
695  checkUri.ReplaceAll(reTreeName[2], "");
696  treeName = reTreeName[3];
697  }
698 
699  // Regexp (optional)
700  TPMERegexp reRegexp("(^|;)(Regexp=([^; ]+))(;|$)");
701  if (reRegexp.Match(uri) != 5)
702  regexp = "";
703  else {
704  checkUri.ReplaceAll(reRegexp[2], "");
705  regexp = reRegexp[3];
706  }
707 
708  // Check for unparsed stuff; parsed stuff has been stripped from checkUri
709  checkUri.ReplaceAll(";", "");
710  checkUri.ReplaceAll(" ", "");
711  if (!checkUri.IsNull()) {
712  ::Error("TDataSetManagerAliEn::ParseCustomFindUri",
713  "There are unrecognized parameters in the dataset find string");
714  return kFALSE;
715  }
716  return kTRUE;
717 }
718 
719 ////////////////////////////////////////////////////////////////////////////////
720 
722  TString &period, Int_t &year, std::vector<Int_t> *&runList, Bool_t &esd,
723  Int_t &aodNum, TString &pass)
724 {
725  // Copy URI to a dummy URI parsed to look for unrecognized stuff
726  TString checkUri;
727 
728  // Strip the initial part (either "Data;" or "Sim;")
729  {
730  Ssiz_t idx = uri.Index(";");
731  checkUri = uri(idx, uri.Length());
732  }
733 
734  // Mode and ForceUpdate (strip them from the check string)
735  TPMERegexp reMode("(^|;)(Mode=[A-Za-z]+)(;|$)");
736  if (reMode.Match(uri) == 4)
737  checkUri.ReplaceAll(reMode[2], "");
738  TPMERegexp reForceUpdate("(^|;)(ForceUpdate)(;|$)");
739  if (reForceUpdate.Match(uri) == 4)
740  checkUri.ReplaceAll(reForceUpdate[2], "");
741 
742  //
743  // Parse LHC period
744  //
745 
746  TPMERegexp rePeriod("(^|;)(Period=(LHC([0-9]{2})[^;]*))(;|$)");
747  if (rePeriod.Match(uri) != 6) {
748  ::Error("TDataSetManagerAliEn::ParseOfficialDataUri",
749  "LHC period not specified (e.g. Period=LHC10h)");
750  return kFALSE;
751  }
752 
753  checkUri.ReplaceAll(rePeriod[2], "");
754  period = rePeriod[3];
755  year = rePeriod[4].Atoi() + 2000;
756 
757  //
758  // Parse data format (ESDs or AODXXX)
759  //
760 
761  TPMERegexp reFormat("(^|;)(Variant=(ESDs?|AOD([0-9]{3})))(;|$)");
762  if (reFormat.Match(uri) != 6) {
763  ::Error("TDataSetManagerAliEn::ParseOfficialDataUri",
764  "Data variant (e.g., Variant=ESD or AOD079) not specified");
765  return kFALSE;
766  }
767 
768  checkUri.ReplaceAll(reFormat[2], "");
769  if (reFormat[3].BeginsWith("ESD")) esd = kTRUE;
770  else {
771  esd = kFALSE;
772  aodNum = reFormat[4].Atoi();
773  }
774 
775  //
776  // Parse pass: mandatory on Data, useless on Sim
777  //
778 
779  TPMERegexp rePass("(^|;)(Pass=([a-zA-Z_0-9-]+))(;|$)");
780  if ((!sim) && (rePass.Match(uri) != 5)) {
781  ::Error("TDataSetManagerAliEn::ParseOfficialDataUri",
782  "Pass (e.g., Pass=cpass1_muon) is mandatory on real data");
783  return kFALSE;
784  }
785  checkUri.ReplaceAll(rePass[2], "");
786  pass = rePass[3];
787 
788  //
789  // Parse run list
790  //
791 
792  TPMERegexp reRun("(^|;)(Run=([0-9,-]+))(;|$)");
793  if (reRun.Match(uri) != 5) {
794  ::Error("TDataSetManagerAliEn::ParseOfficialDataUri",
795  "Run or run range not specified (e.g., Run=139104-139107,139306)");
796  return kFALSE;
797  }
798  checkUri.ReplaceAll(reRun[2], "");
799  TString runListStr = reRun[3];
800  runList = ExpandRunSpec(runListStr); // must be freed by caller
801 
802  // Check for unparsed stuff; parsed stuff has been stripped from checkUri
803  checkUri.ReplaceAll(";", "");
804  checkUri.ReplaceAll(" ", "");
805  if (!checkUri.IsNull()) {
806  ::Error("TDataSetManagerAliEn::ParseOfficialDataUri",
807  "There are unrecognized parameters in dataset string");
808  return kFALSE;
809  }
810 
811  return kTRUE;
812 }
813 
814 ////////////////////////////////////////////////////////////////////////////////
815 
817  Bool_t onlyFromCloseSE) {
818  // Performs an AliEn "whereis -r" on the given input AliEn URL. The input URL
819  // is assumed to be an AliEn one, with alien:// as protocol. The "whereis"
820  // command returns the full list of XRootD URLs actually pointing to the files
821  // (the PFNs). The "-r" switch resolves pointers to files in archives to their
822  // PFNs.
823  // With closeSE a "close storage element" can be specified (like
824  // "ALICE::Torino::SE"): if onlyFromCloseSE is kTRUE, the endpoint URL will be
825  // returned only if there is one endpoint matching that SE (NULL is returned
826  // otherwise). Elsewhere, the first URL found is returned.
827  // This function might return NULL if it does not find a suitable endpoint URL
828  // for the given file.
829 
830  if (!alienUrl) {
831  ::Error("TDataSetManagerAliEn::AliEnWhereIs", "input AliEn URL not given!");
832  return NULL;
833  }
834 
835  if (!gGrid || (strcmp(gGrid->GetGrid(), "alien") != 0)) {
836  ::Error("TDataSetManagerAliEn::AliEnWhereIs", "no AliEn grid connection available!");
837  return NULL;
838  }
839 
840  TString cmd = "whereis -r ";
841  cmd.Append(alienUrl->GetFile());
842  TList *resp;
843 
844  resp = dynamic_cast<TList *>( gGrid->Command(cmd.Data()) );
845  if (!resp) {
846  ::Error("TDataSetManagerAliEn::AliEnWhereIs", "cannot get response from AliEn");
847  return NULL;
848  }
849 
850  TIter nextPfn(resp);
851  TMap *pfn;
852  TString se, pfnUrl, validPfnUrl;
853  while ( (pfn = dynamic_cast<TMap *>( nextPfn() )) != NULL ) {
854 
855  if ((pfn->GetValue("se") == NULL) || (pfn->GetValue("pfn") == NULL)) {
856  continue; // skip invalid result
857  }
858 
859  pfnUrl = pfn->GetValue("pfn")->GetName();
860  se = pfn->GetValue("se")->GetName();
861 
862  if (se.EqualTo(closeSE, TString::kIgnoreCase)) {
863  // Found matching URL from the preferred SE
864  validPfnUrl = pfnUrl;
865  break;
866  }
867  else if (!onlyFromCloseSE && validPfnUrl.IsNull()) {
868  validPfnUrl = pfnUrl;
869  }
870 
871  // TIter nextPair(pfn);
872  // TObjString *keyos;
873  // while ( (keyos = dynamic_cast<TObjString *>( nextPair() )) != NULL ) {
874  // const char *key = keyos->GetName();
875  // const char *val = pfn->GetValue(key)->GetName();
876  // ::Info("TDataSetManagerAliEn::AliEnWhereIs", "%s-->%s", key, val);
877  // // se, pfn, guid
878  // }
879 
880  }
881 
882  delete resp;
883 
884  if (validPfnUrl.IsNull()) {
885  if (gDebug >= 1) {
886  ::Error("TDataSetManagerAliEn::AliEnWhereIs", "cannot find endpoint URL for %s", alienUrl->GetUrl());
887  }
888  return NULL;
889  }
890 
891  TUrl *pfnTUrl = new TUrl( validPfnUrl.Data() );
892 
893  // Append original options and the zip=<anchor> if applicable (needed!)
894  TString options = alienUrl->GetOptions();
895  TString anchor = alienUrl->GetAnchor();
896  if (!anchor.IsNull()) {
897  options.Append("&zip=");
898  options.Append(anchor);
899  pfnTUrl->SetAnchor(anchor.Data());
900  pfnTUrl->SetOptions(options.Data());
901  }
902 
903  return pfnTUrl;
904 }
905 
906 ////////////////////////////////////////////////////////////////////////////////
907 
908 std::vector<Int_t> *TDataSetManagerAliEn::ExpandRunSpec(TString &runSpec) {
909  std::vector<Int_t> *runNumsPtr = new std::vector<Int_t>();
910  std::vector<Int_t> &runNums = *runNumsPtr;
911 
912  TObjArray *runs = runSpec.Tokenize(":,");
913  runs->SetOwner();
914  TIter run(runs);
915  TObjString *runOs;
916 
917  while ( (runOs = dynamic_cast<TObjString *>(run.Next())) ) {
918 
919  TString runStr = runOs->String();
920 
921  TPMERegexp p("^([0-9]+)-([0-9]+)$");
922  if (p.Match(runStr) == 3) {
923  Int_t r1 = p[1].Atoi();
924  Int_t r2 = p[2].Atoi();
925 
926  if (r1 > r2) {
927  // Swap
928  r1 = r1 ^ r2;
929  r2 = r1 ^ r2;
930  r1 = r1 ^ r2;
931  }
932 
933  for (Int_t r=r1; r<=r2; r++) {
934  runNums.push_back(r);
935  }
936  }
937  else {
938  runNums.push_back(runStr.Atoi());
939  }
940  }
941 
942  delete runs;
943 
944  // Bubble sort (slow)
945  for (UInt_t i=0; i<runNums.size(); i++) {
946  for (UInt_t j=i+1; j<runNums.size(); j++) {
947  if (runNums[j] < runNums[i]) {
948  runNums[i] = runNums[i] ^ runNums[j];
949  runNums[j] = runNums[i] ^ runNums[j];
950  runNums[i] = runNums[i] ^ runNums[j];
951  }
952  }
953  }
954 
955  // Remove duplicates
956  {
957  std::vector<Int_t>::iterator itr = runNums.begin();
958  Int_t prevVal = 0; // unneeded but silences uninitialized warning
959  while (itr != runNums.end()) {
960  if ((itr == runNums.begin()) || (prevVal != *itr)) {
961  prevVal = *itr;
962  ++itr;
963  }
964  else {
965  itr = runNums.erase(itr);
966  }
967  }
968  }
969 
970  return runNumsPtr;
971 
972 }
973 
974 ////////////////////////////////////////////////////////////////////////////////
975 
976 TFileCollection *TDataSetManagerAliEn::GetDataSet(const char *uri, const char *)
977 {
978  TFileCollection *fc = NULL; // global collection
979 
980  TString sUri(uri);
981  EDataMode dataMode;
982  Bool_t forceUpdate;
983  TList *findCmds = GetFindCommandsFromUri(sUri, dataMode, forceUpdate);
984  if (!findCmds) return NULL;
985 
986  fc = new TFileCollection(); // this fc will contain all data
987 
988  TFileStager *fstg = NULL; // used and reused for bulk lookup
989  TFileInfo *fi;
990 
991  TIter it(findCmds);
992  TAliEnFind *af;
993  while ((af = dynamic_cast<TAliEnFind *>(it.Next())) != NULL) {
994 
995  TString cachedUri = af->GetSearchId();
996  TFileCollection *newFc = NULL;
997  Bool_t saveToCache = kFALSE;
998  Bool_t fillLocality = kFALSE;
999 
1000  // Check modified time
1001  Long_t mtime = fCache->GetModTime(cachedUri.Data());
1002  Long_t now = gSystem->Now();
1003  now = now/1000 + 788914800; // magic is secs between Jan 1st 1970 and 1995
1004 
1005  if (forceUpdate) {
1006  if (gDebug >= 1)
1007  Info("GetDataSet", "Ignoring cached query result: forcing update");
1008  }
1009  else if ((mtime > 0) && (now-mtime > fCacheExpire_s)) {
1010  if (gDebug >= 1)
1011  Info("GetDataSet", "Dataset cache has expired");
1012  }
1013  else {
1014  if (gDebug >= 1)
1015  Info("GetDataSet", "Getting file collection from cache");
1016  newFc = fCache->GetDataSet(cachedUri.Data());
1017  }
1018 
1019  if (!newFc) {
1020 
1021  if (gDebug >= 1)
1022  Info("GetDataSet", "Getting file collection from AliEn");
1023 
1024  newFc = af->GetCollection();
1025  if (!newFc) {
1026  Error("GetDataSet", "Cannot get collection from AliEn");
1027  delete findCmds;
1028  delete fc;
1029  return NULL;
1030  }
1031 
1032  // Dataset was not cached. Just got from AliEn. Either fill with endpoint,
1033  // if kDataLocal, or fill with dummy data, if kDataRemote/kDataLocal.
1034  // Inside this scope we are processing data that will be cached, and not
1035  // data actually returned to the user
1036 
1037  // Add redirector's URL
1038  TIter itCache(newFc->GetList());
1039  TString tUrl;
1040  while ((fi = dynamic_cast<TFileInfo *>(itCache.Next()))) {
1041 
1042  if (fReadFromSE) {
1043  TUrl *seUrl;
1044  seUrl = AliEnWhereIs( fi->GetCurrentUrl(), fUrlTpl, kTRUE );
1045 
1046  if (seUrl) {
1047  // File is present (according to catalog) in the given SE
1048  fi->AddUrl(seUrl->GetUrl(), kTRUE); // kTRUE == prepend URL
1049  fi->ResetUrl();
1050  delete seUrl;
1051  }
1052  else {
1053  // File not found in that SE
1054  fi->AddUrl(kfNoopNoneUrl->GetUrl(), kTRUE);
1055  }
1056 
1057  }
1058  else {
1059  tUrl = fi->GetCurrentUrl()->GetUrl();
1060  fUrlRe->Substitute(tUrl, fUrlTpl);
1061  fi->AddUrl(tUrl.Data(), kTRUE); // kTRUE == prepend URL
1062  fi->ResetUrl();
1063  }
1064 
1065  }
1066 
1067  // Add endpoint?
1068  if (dataMode == kDataLocal) {
1069  fillLocality = kTRUE;
1070  }
1071  else {
1072  // Don't make the user waste time: don't cache dataset locality info at
1073  // this time, and signal our ignorance with a dummy URL
1074  if (gDebug >= 1)
1075  Info("GetDataSet", "Not caching data locality information now");
1076  itCache.Reset();
1077  while ((fi = dynamic_cast<TFileInfo *>(itCache.Next())))
1079  }
1080 
1081  // Update summary information and save to cache!
1082  saveToCache = kTRUE;
1083 
1084  } // end dataset just got from AliEn
1085  else {
1086 
1087  // Reading dataset from cache. Check if it has endpoint information.
1088  Bool_t hasEndp = kTRUE;
1089 
1090  fi = dynamic_cast<TFileInfo *>(newFc->GetList()->At(0));
1091  if (fi) {
1092  if ( strcmp(fi->GetCurrentUrl()->GetUrl(), kfNoopUnknownUrl->GetUrl()) == 0 ) {
1093  if (gDebug >= 1)
1094  Info("GetDataSet", "No dataset locality information in cache");
1095  hasEndp = kFALSE;
1096  }
1097  }
1098 
1099  if ((dataMode == kDataLocal) && !hasEndp) {
1100  // Fill missing locality information now
1101 
1102  // Remove first dummy URL everywhere
1103  TIter itCache(newFc->GetList());
1104  while ((fi = dynamic_cast<TFileInfo *>(itCache.Next()))) {
1105  fi->RemoveUrl( kfNoopUnknownUrl->GetUrl() );
1106  }
1107 
1108  fillLocality = kTRUE; // will locate
1109  saveToCache = kTRUE; // will cache
1110  }
1111 
1112  } // end processing dataset from cache
1113 
1114  // Fill locality: initialize stager, locate URLs
1115  if (fillLocality) {
1116 
1117  if (fReadFromSE) {
1118 
1119  // If we have the redirector's URL, file is staged; elsewhere, assume
1120  // that it is not. This way of filling locality info does not imply
1121  // queries. The "dummy" URL signalling that no suitable redirector is
1122  // there is not removed (it will be in the final results)
1123 
1124  TIter nxtLoc(newFc->GetList());
1125  while (( fi = dynamic_cast<TFileInfo *>(nxtLoc()) )) {
1126  if (fi->FindByUrl( kfNoopNoneUrl->GetUrl() )) {
1128  }
1129  else {
1131  }
1132  }
1133 
1134  }
1135  else {
1136 
1137  // Fill locality with a redirector
1138 
1139  fi = dynamic_cast<TFileInfo *>(newFc->GetList()->At(0));
1140  if (fi) {
1141  Info("GetDataSet", "Filling dataset locality information: "
1142  "it might take time, be patient!");
1143 
1144  // Lazy stager initialization
1145  if (!fstg)
1146  fstg = TFileStager::Open(fi->GetCurrentUrl()->GetUrl());
1147 
1148  if (!fstg) {
1149  Error("GetDataSet", "Can't create file stager");
1150  delete newFc;
1151  delete fc;
1152  delete findCmds;
1153  return NULL;
1154  }
1155  else {
1156  Int_t rv = fstg->LocateCollection(newFc, kTRUE);
1157  if (rv < 0) {
1158  Error("GetDataSet", "Endpoint lookup returned an error");
1159  delete fstg;
1160  delete newFc;
1161  delete fc;
1162  delete findCmds;
1163  return NULL;
1164  }
1165  else if (gDebug >= 1) {
1166  Info("GetDataSet", "Lookup successful for %d file(s)", rv);
1167  }
1168  }
1169  } // end if fi
1170  }
1171 
1172  } // end if fillLocality
1173 
1174  // Save (back) to cache if requested
1175  if (saveToCache) {
1176  newFc->Update();
1177  TString group, user, name;
1178  fCache->ParseUri(cachedUri, &group, &user, &name);
1179  if (fCache->WriteDataSet(group, user, name, newFc) == 0) {
1180  // Non-fatal error, but warn user
1181  Warning("GetDataSet", "Could not cache retrieved information");
1182  }
1183  }
1184 
1185  // Just print the newFc (debug)
1186  if (gDebug >= 2) {
1187  Info("GetDataSet", "Dataset information currently cached follows");
1188  newFc->Print("filter:SsCc");
1189  }
1190 
1191  // Now we prepare the final dataset, by appending proper information from
1192  // newFc to fc. Cache has been already saved (possibly with locality info)
1193 
1194  TIter itCache(newFc->GetList());
1195  Int_t nDeleteUrls;
1196  while ((fi = dynamic_cast<TFileInfo *>(itCache.Next()))) {
1197 
1198  // Keep only URLs requested by user: remove the rest. We are acting on
1199  // the user's copy, not on the cached copy
1200 
1201  fi->ResetUrl();
1202 
1203  if (dataMode == kDataRemote) {
1204  // Assume remote file is always available
1206  // Only last URL should survive
1207  nDeleteUrls = fi->GetNUrls() - 1;
1208  for (Int_t i=0; i<nDeleteUrls; i++) {
1209  fi->RemoveUrlAt(0);
1210  }
1211  }
1212  else if (dataMode == kDataCache) {
1213  // Access from redirector: pretend that everything is staged
1215  // Only two last URLs should survive
1216  nDeleteUrls = fi->GetNUrls() - 2;
1217  for (Int_t i=0; i<nDeleteUrls; i++) {
1218  fi->RemoveUrlAt(0);
1219  }
1220  }
1221  // else {} // dataMode == kLocal (trust all: also the staged bit)
1222 
1223  // Now remove all dummy URLs
1224  fi->RemoveUrl( kfNoopUnknownUrl->GetUrl() );
1225  fi->RemoveUrl( kfNoopNoneUrl->GetUrl() );
1226  fi->RemoveUrl( kfNoopRedirUrl->GetUrl() );
1227 
1228  fi->ResetUrl();
1229 
1230  // Append to big file collection used for analysis
1231  TFileInfo *newFi = new TFileInfo(*fi);
1232  fc->Add(newFi);
1233 
1234  }
1235 
1236  // Set default tree
1237  if (!fc->GetDefaultTreeName())
1238  fc->SetDefaultTreeName(newFc->GetDefaultTreeName());
1239 
1240  delete newFc;
1241 
1242  } // end loop over find commands
1243 
1244  delete findCmds;
1245  if (fstg) delete fstg;
1246 
1247  fc->Update();
1248  return fc;
1249 }
1250 
1251 ////////////////////////////////////////////////////////////////////////////////
1252 
1254 {
1255  TFileCollection *fc = GetDataSet(uri);
1256  Bool_t existsNonEmpty = (fc && (fc->GetNFiles() > 0));
1257  if (fc) delete fc;
1258  return existsNonEmpty;
1259 }
1260 
1261 ////////////////////////////////////////////////////////////////////////////////
1262 
1264  const char *)
1265 {
1266  MayNotUse("RegisterDataSet");
1267  return -1;
1268 }
1269 
1270 ////////////////////////////////////////////////////////////////////////////////
1271 
1273 {
1274  MayNotUse("GetDataSets");
1275  return NULL;
1276 }
1277 
1278 ////////////////////////////////////////////////////////////////////////////////
1279 
1280 void TDataSetManagerAliEn::ShowDataSets(const char *, const char *)
1281 {
1282  MayNotUse("ShowDataSets");
1283 }
1284 
1285 ////////////////////////////////////////////////////////////////////////////////
1286 
1288 {
1289  MayNotUse("RemoveDataSet");
1290  return kFALSE;
1291 }
1292 
1293 ////////////////////////////////////////////////////////////////////////////////
1294 
1296 {
1297  MayNotUse("ScanDataSet");
1298  return -1;
1299 }
1300 
1301 ////////////////////////////////////////////////////////////////////////////////
1302 
1304 {
1305  MayNotUse("ShowCache");
1306  return -1;
1307 }
1308 
1309 ////////////////////////////////////////////////////////////////////////////////
1310 
1312 {
1313  MayNotUse("ClearCache");
1314  return -1;
1315 }
static Bool_t ParseOfficialDataUri(TString &uri, Bool_t sim, TString &period, Int_t &year, std::vector< Int_t > *&runList, Bool_t &esd, Int_t &aodNum, TString &pass)
An array of TObjects.
Definition: TObjArray.h:37
virtual void SetRegexp(const char *regexp)
virtual Int_t ClearCache(const char *)
Clear cached information matching uri.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
virtual Bool_t ExistsDataSet(const char *uri)
Checks if the indicated dataset exits.
const char * GetDefaultTreeName() const
Returns the tree set with SetDefaultTreeName if set Returns the name of the first tree in the meta da...
long long Long64_t
Definition: RtypesCore.h:69
virtual void SetArchSubst(Bool_t archSubst)
virtual const char * GetKey(UInt_t, const char *) const
Definition: TGridResult.h:45
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
Definition: TMD5.cxx:167
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
Definition: TString.h:628
Collectable string class.
Definition: TObjString.h:28
const char Option_t
Definition: RtypesCore.h:62
R__EXTERN TGrid * gGrid
Definition: TGrid.h:128
This class represents a WWW compatible URL.
Definition: TUrl.h:35
static TUrl * AliEnWhereIs(TUrl *alienUrl, TString &closeSE, Bool_t onlyFromCloseSE)
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
Bool_t RemoveUrl(const char *url)
Remove an URL. Returns kTRUE if successful, kFALSE otherwise.
Definition: TFileInfo.cxx:320
TUrl * GetCurrentUrl() const
Return the current url.
Definition: TFileInfo.cxx:248
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void InvalidateGridResult()
virtual TMap * GetDataSets(const char *, UInt_t)
Returns all datasets for the <group> and <user> specified by <uri>.
virtual Int_t GetEntries() const
Definition: TCollection.h:177
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
const char * AsString() const
Return message digest as string.
Definition: TMD5.cxx:220
virtual TGridResult * GetGridResult(Bool_t forceNewQuery=kFALSE)
Query the AliEn file catalog.
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Long_t GetModTime(const char *uri)
Gets last dataset modification time.
const char * GetOptions() const
Definition: TUrl.h:73
Bool_t AddUrl(const char *url, Bool_t infront=kFALSE)
Add a new URL.
Definition: TFileInfo.cxx:295
TString & Prepend(const char *cs)
Definition: TString.h:656
virtual Bool_t Cd(const char *="", Bool_t=kFALSE)
Definition: TGrid.h:90
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:387
TPMERegexp * fRegexp
virtual TFileCollection * GetCollection(Bool_t forceNewQuery=kFALSE)
const char * GetFile() const
Definition: TUrl.h:71
virtual TGridResult * Query(const char *, const char *, const char *="", const char *="")
Definition: TGrid.h:77
static struct mg_connection * fc(struct mg_context *ctx)
Definition: civetweb.c:3728
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
static TGrid * Connect(const char *grid, const char *uid=0, const char *pw=0, const char *options=0)
The grid should be of the form: <grid>://<host>[:<port>], e.g.
Definition: TGrid.cxx:49
Int_t GetNUrls() const
Definition: TFileInfo.h:74
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:44
TString & Append(const char *cs)
Definition: TString.h:559
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition: TObject.cxx:933
virtual Int_t ShowCache(const char *)
Show cached information matching uri.
const char * GetAnchor() const
Definition: TUrl.h:72
TUrl * FindByUrl(const char *url, Bool_t withDeflt=kFALSE)
Find an element from a URL. Returns 0 if not found.
Definition: TFileInfo.cxx:276
A doubly linked list.
Definition: TList.h:44
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition: TSystem.cxx:457
Bool_t RemoveUrlAt(Int_t i)
Remove URL at given position. Returns kTRUE on success, kFALSE on error.
Definition: TFileInfo.cxx:336
ROOT::R::TRInterface & r
Definition: Object.C:4
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
Definition: TMD5.cxx:108
R__EXTERN TSystem * gSystem
Definition: TSystem.h:557
if object ctor succeeded but object should not be used
Definition: TObject.h:68
THashList * GetList()
virtual void SetFileName(const char *fileName)
void Print(Option_t *option="") const
Prints the contents of the TFileCollection.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:819
Bool_t ParseUri(const char *uri, TString *dsGroup=0, TString *dsUser=0, TString *dsName=0, TString *dsTree=0, Bool_t onlyCurrent=kFALSE, Bool_t wildcards=kFALSE)
Parses a (relative) URI that describes a DataSet on the cluster.
TObject * Next()
Definition: TCollection.h:249
Int_t WriteDataSet(const char *group, const char *user, const char *dsName, TFileCollection *dataset, UInt_t option=0, TMD5 *checksum=0)
Writes indicated dataset.
static std::vector< Int_t > * ExpandRunSpec(TString &runSpec)
virtual Int_t LocateCollection(TFileCollection *fc, Bool_t addDummyUrl=kFALSE)
Massive location of files.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
virtual ~TAliEnFind()
Destructor.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Ssiz_t Length() const
Definition: TString.h:405
TGridResult * fGridResult
static Bool_t ParseCustomFindUri(TString &uri, TString &basePath, TString &fileName, TString &anchor, TString &query, TString &treeName, TString &regexp)
virtual Int_t RegisterDataSet(const char *, TFileCollection *, const char *)
Register a dataset, perfoming quota checkings, if needed.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:354
virtual void Init(TString cacheDir, TString urlTpl, ULong_t cacheExpire_s)
TString & String()
Definition: TObjString.h:48
virtual void SetBasePath(const char *basePath)
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
int Ssiz_t
Definition: RtypesCore.h:63
const char * GetGrid() const
Definition: TGrid.h:60
void SetAnchor(const char *anchor)
Definition: TUrl.h:88
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2197
TAliEnFind & operator=(const TAliEnFind &rhs)
Assignment operator. Cached query result is not copied.
#define ClassImp(name)
Definition: Rtypes.h:365
virtual TFileCollection * GetDataSet(const char *uri, const char *=0)
Utility function used in various methods for user dataset upload.
virtual void Print(Option_t *opt="") const
This method must be overridden when a class wants to print itself.
void Printf(const char *fmt,...)
virtual Int_t ScanDataSet(const char *, UInt_t)
Scans the dataset indicated by <uri> and returns the number of missing files.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
unsigned long ULong_t
Definition: RtypesCore.h:51
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
static TFileStager * Open(const char *stager)
Open a stager, after having loaded the relevant plug-in.
TAliEnFind(const TString &basePath="", const TString &fileName="", const TString &anchor="", const Bool_t archSubst=kFALSE, const TString &treeName="", const TString &regexp="", const TString &query="")
Constructor.
virtual TList * GetFindCommandsFromUri(TString &uri, EDataMode &dataMode, Bool_t &forceUpdate)
Parse kind.
void ResetUrl()
Definition: TFileInfo.h:68
virtual const char * GetSearchId()
Bool_t IsNull() const
Definition: TString.h:402
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex &#39;this&#39; was created with.
Definition: TPRegexp.cxx:708
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void SetTreeName(const char *fileName)
virtual void Add(TObject *obj)
Definition: TList.h:87
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition: TPRegexp.h:97
Class that contains a list of TFileInfo&#39;s and accumulated meta data information about its entries...
TFileCollection * GetDataSet(const char *uri, const char *srv=0)
Utility function used in various methods for user dataset upload.
virtual void InvalidateSearchId()
void SetOptions(const char *opt)
Definition: TUrl.h:89
virtual void ShowDataSets(const char *="*", const char *="")
Prints formatted information about the dataset &#39;uri&#39;.
R__EXTERN Int_t gDebug
Definition: Rtypes.h:91
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:235
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1921
virtual void SetAnchor(const char *anchor)
virtual TGridResult * Ls(const char *="", Option_t *="", Bool_t=kFALSE)
Definition: TGrid.h:84
Class describing a generic file including meta information.
Definition: TFileInfo.h:38
void ResetBit(UInt_t f)
Definition: TObject.h:171
unsigned char UChar_t
Definition: RtypesCore.h:34
virtual Bool_t RemoveDataSet(const char *uri)
Removes the indicated dataset.
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
Int_t Substitute(TString &s, const TString &r, Bool_t doDollarSubst=kTRUE)
Substitute matching part of s with r, dollar back-ref substitution is performed if doDollarSubst is t...
Definition: TPRegexp.cxx:874
void SetString(const char *s)
Definition: TObjString.h:45
virtual TGridResult * Command(const char *, Bool_t=kFALSE, UInt_t=2)
Definition: TGrid.h:72
const Bool_t kTRUE
Definition: RtypesCore.h:87
TDataSetManagerFile * fCache
char name[80]
Definition: TGX11.cxx:109
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
const char * Data() const
Definition: TString.h:364