51 #define MAX_FILE_IMAGES 16
83 const char *ftitle,
Int_t compress,
84 Bool_t parallelopen,
const char *lurl,
86 TXNetFile(purl, option, ftitle, compress, 0, parallelopen, lurl)
88 TUrl logicalurl(lurl);
105 const char *ftitle,
Int_t compress,
109 ::Error(
"TAlienFileAccess",
"No GRID connection available!");
156 storageelement =
value;
159 if (atoi(value.
Data()))
160 publicaccess =
kTRUE;
191 if (fAOption ==
"NEW")
195 recreate = (fAOption ==
"RECREATE") ?
kTRUE :
kFALSE;
199 if (!create && !recreate && !update && !read) {
204 if (create || recreate || update) {
209 fAOption =
"RECREATE";
217 ::Error(
"TAlienFile::Open",
"no active GRID connection found");
227 ::Error(
"TAlienFile::Open",
"you don't have an active <alien> grid!");
244 command =
TString(
"access -p read ");
246 command =
TString(
"access read ");
250 command =
TString(
"access write-once ");
254 command =
TString(
"access write-version ");
258 command =
TString(
"access write-version ");
266 command += storageelement;
275 repcommand = command;
278 if (storageelement !=
"") {
280 repcommand += storageelement;
283 repcommand +=
"unknown";
286 repcommand += imagenr;
295 list = dynamic_cast <
TList * >(alienResult);
300 "cannot get the access envelope for %s and image %u in SE <%s>",
304 "cannot get the access envelope for %s and image %u",
318 iter = list->MakeIterator();
323 while ((
object = iter->
Next()) != 0) {
324 TMap *map = dynamic_cast <
TMap * >(object);
327 urlStr = dynamic_cast <
TObjString * >(urlObject);
328 if (urlStr) urlStrs = urlStr->
GetName();
331 authzStr = dynamic_cast <
TObjString * >(authzObject);
334 seStr = dynamic_cast <
TObjString * >(seObject);
335 if (seStr) seStrs = seStr->
GetName();
338 if (nreplicasObject) {
339 snreplicas = nreplicasObject->
GetName();
340 nreplicas = snreplicas.
Atoi();
344 if (guidObject) sguid = guidObject->
GetName();
347 if (pfnObject) pfnStr = pfnObject->
GetName();
356 if ((!urlStr) || (!authzStr)) {
359 "didn't get the authorization to write %s",
364 "didn't get the authorization to read %s from location %u",
369 ::Info(
"TAlienFile::Open",
370 "Command::Stdout !!!");
372 ::Info(
"TAlienFile::Open",
373 "Command::Stderr !!!");
375 ::Info(
"TAlienFile::Open",
376 "End of Output !!!");
386 "No more images to try - giving up");
417 ::Info(
"TAlienFile::Open",
"Accessing image %u of %s in SE <%s>",
420 ::Info(
"TAlienFile::Open",
"Accessing image %u of %s", imagenr, purl.
GetUrl());
434 lUrloption +=
"&mkpath=1";
444 lUrloption += anchor;
445 lUrloption +=
"&mkpath=1";
453 loption +=
"&mkpath=1";
461 fAUrl =
TUrl(newurl);
498 parallelopen, lUrl.
GetUrl(), authz);
508 alienfile->
SetSE(seStrs);
509 alienfile->
SetPfn(pfnStr);
513 alienfile->
SetUrl(urlStrs);
521 "Couldn't open any of the file images of %s", lUrl.
GetUrl());
540 Info(
"~TAlienFile",
"dtor called for %s",
GetName());
565 Error(
"Close",
"the reported size of the written file is <= 0");
573 TList *list = dynamic_cast <
TList * >(alienResult);
578 Error(
"Close",
"cannot commit envelope for %s",
fLfn.
Data());
584 while ((
object = iter->
Next()) != 0) {
585 TMap *map = dynamic_cast <
TMap * >(object);
590 if (!(strcmp(commitStr->
GetName(),
"1"))) {
622 command =
"access -p read ";
628 ::Error(
"TAlienFile::SUrl",
"no grid connection");
634 ::Error(
"TAlienFile::SUrl",
"couldn't get access URL for alien file %s", lfn);
642 object = iter->
Next();
644 TMap *map = dynamic_cast <
TMap * >(object);
646 urlStr = dynamic_cast <
TObjString * >(urlObject);
655 ::Error(
"TAlienFile::SUrl",
"couldn't get surl for alien file %s", lfn);
const char * GetName() const
Returns name of object.
void SetFile(const char *file)
double read(const std::string &file_name)
reading
virtual Long64_t GetSize() const
Returns the current file size.
virtual void Close(const Option_t *opt="")
Close the file.
static TAlienFile * Open(const char *lfn, const Option_t *option="", const char *title="", Int_t compress=1, Bool_t parallelopen=kFALSE)
Static method used to create a TAlienFile object.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Collectable string class.
This class represents a WWW compatible URL.
virtual Bool_t SendFileOpenProgress(TFile *, TList *, const char *, Bool_t=kFALSE)
void SetPfn(const char *pfn)
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void SetElapsed(Double_t real)
void ToUpper()
Change string to upper case.
ClassImp(TAlienFile) TAlienFile
Create an Alien File Object.
const char * GetOptions() const
Iterator abstract base class.
const char * Data() const
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
void SetSE(const char *se)
std::map< std::string, std::string >::const_iterator iter
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
virtual const char * Getenv(const char *env)
Get environment variable.
void Info(const char *location, const char *msgfmt,...)
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Int_t Atoi() const
Return integer value of string.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void Error(const char *location, const char *msgfmt,...)
const char * GetGrid() const
virtual void Setenv(const char *name, const char *value)
Set environment variable.
R__EXTERN TSystem * gSystem
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
virtual const char * GetName() const
Returns name of object.
const char * GetAnchor() const
void SetNreplicas(Int_t nrep)
virtual void Unsetenv(const char *name)
Unset environment variable.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t fWritable
True if directory is writable.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
virtual ~TAlienFile()
TAlienFile file dtor.
void SetGUID(const char *guid)
virtual const char * GetName() const
Returns name of object.
virtual void Close(const Option_t *opt="")
Close the file (see TNetFile::Close() or TFile::Close() for more details).
void SetImage(Int_t image)
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
TString fOption
File options.
Int_t GetEntries() const
Return the number of objects in array (i.e.
Mother of all ROOT objects.
virtual TObject * Next()=0
void SetOptions(const char *opt)
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
TObject * At(Int_t idx) const
void SetString(const char *s)
virtual Bool_t IsOpen() const
Return kTRUE if the file is open, kFALSE otherwise.
virtual TGridResult * Command(const char *, Bool_t=kFALSE, UInt_t=2)
static TString SUrl(const char *lfn)
Get surl from lfn by asking AliEn catalog.
const char * GetFile() const
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
void SetUrl(const char *url)