32 TXNetFileStager::TXNetFileStager(
const char *url) : TFileStager(
"xrd")
35 if (url && strlen(url) > 0) {
36 GetPrefix(url, fPrefix);
38 fSystem =
new TXNetSystem(fPrefix);
45 TXNetFileStager::~TXNetFileStager()
56 Bool_t TXNetFileStager::IsStaged(
const char *path)
59 GetPrefix(path, fPrefix);
60 fSystem =
new TXNetSystem(path);
65 if (!p.BeginsWith(
"root:"))
67 return (fSystem->IsOnline(p));
71 Warning(
"IsStaged",
"TXNetSystem not initialized");
80 Bool_t TXNetFileStager::Stage(TCollection *paths, Option_t *opt)
86 if (opt && strlen(opt) > 0) {
89 while (xo.Tokenize(io, from,
"[ ,|]")) {
90 if (io.Contains(
"option=")) {
91 io.ReplaceAll(
"option=",
"");
94 if (i >= 0 && i <= 255)
98 if (io.Contains(
"priority=")) {
99 io.ReplaceAll(
"priority=",
"");
102 if (i >= 0 && i <= 255)
109 return fSystem->Prepare(paths, o, p);
113 Warning(
"Stage",
"TXNetSystem not initialized");
123 Bool_t TXNetFileStager::Stage(
const char *path, Option_t *opt)
126 GetPrefix(path, fPrefix);
127 fSystem =
new TXNetSystem(path);
136 while (xo.Tokenize(io, from,
"[ ,|]")) {
137 if (io.Contains(
"option=")) {
138 io.ReplaceAll(
"option=",
"");
141 if (i >= 0 && i <= 255)
145 if (io.Contains(
"priority=")) {
146 io.ReplaceAll(
"priority=",
"");
149 if (i >= 0 && i <= 255)
156 if (!pp.BeginsWith(
"root:"))
157 pp.Insert(0, fPrefix);
158 return fSystem->Prepare(pp, o, p);
162 Warning(
"Stage",
"TXNetSystem not initialized");
169 void TXNetFileStager::GetPrefix(
const char *url, TString &pfx)
172 ::Info(
"TXNetFileStager::GetPrefix",
"enter: %s", url);
175 pfx = Form(
"%s://", u.GetProtocol());
176 if (strlen(u.GetUser()) > 0)
177 pfx += Form(
"%s@", u.GetUser());
179 if (u.GetPort() != TUrl(
"root://host").GetPort())
180 pfx += Form(
":%d", u.GetPort());
184 ::Info(
"TXNetFileStager::GetPrefix",
"found prefix: %s", pfx.Data());
190 void TXNetFileStager::Print(Option_t *)
const
192 Printf(
"+++ stager: %s %s", GetName(), fPrefix.Data());
199 Int_t TXNetFileStager::Locate(
const char *path, TString &eurl)
202 GetPrefix(path, fPrefix);
203 fSystem =
new TXNetSystem(path);
207 return fSystem->Locate(path, eurl);
230 Int_t TXNetFileStager::LocateCollection(TFileCollection *fc,
234 Error(
"Locate",
"No input collection given!");
245 Double_t timeTaken_s;
248 Int_t rv = fSystem->Prepare(fc->GetList(), 0, 0, NULL);
251 TIter it(fc->GetList());
253 timeTaken_s = ts.RealTime();
255 Info(
"Locate",
"Bulk xprep done in %.1lfs (returned %d)",
262 while ((fi = dynamic_cast<TFileInfo *>(it.Next())) != NULL) {
264 surl = fi->GetCurrentUrl()->GetUrl();
267 GetPrefix(surl.Data(), fPrefix);
269 Info(
"Locate",
"Stager non initialized, doing it now for %s",
272 fSystem =
new TXNetSystem(surl.Data());
276 if (fSystem->Locate(surl.Data(), endp)) {
278 fi->ResetBit(TFileInfo::kStaged);
281 fi->AddUrl(
"noop://none", kTRUE);
284 Info(
"Locate",
"Not found: %s", surl.Data());
290 fi->SetBit(TFileInfo::kStaged);
292 fi->AddUrl(endp.Data(), kTRUE);
294 else if (addDummyUrl) {
296 fi->AddUrl(
"noop://redir", kTRUE);
300 Info(
"Locate",
"Found: %s --> %s", surl.Data(), endp.Data());
306 timeTaken_s += ts.RealTime();
308 Info(
"Locate",
"All locates finished in %.1lfs", ts.RealTime());
309 Info(
"Locate",
"Mass prepare and locates took %.1lfs", timeTaken_s);
319 Bool_t TXNetFileStager::Matches(
const char *s)
324 return ((fPrefix == pfx) ? kTRUE : kFALSE);