#include "TNetXNGFileStager.h"
#include "TNetXNGSystem.h"
#include "THashList.h"
#include "TFileInfo.h"
#include "TFileCollection.h"
#include <XrdCl/XrdClFileSystem.hh>
ClassImp( TNetXNGFileStager);
TNetXNGFileStager::TNetXNGFileStager(const char *url) :
TFileStager("xrd")
{
fSystem = new TNetXNGSystem(url);
}
TNetXNGFileStager::~TNetXNGFileStager()
{
delete fSystem;
}
Bool_t TNetXNGFileStager::IsStaged(const char *path)
{
FileStat_t st;
if (fSystem->GetPathInfo(path, st) != 0) {
if (gDebug > 0)
Info("IsStaged", "path %s cannot be stat'ed", path);
return kFALSE;
}
if (R_ISOFF(st.fMode)) {
if (gDebug > 0)
Info("IsStaged", "path '%s' is offline", path);
return kFALSE;
}
return kTRUE;
}
Int_t TNetXNGFileStager::Locate(const char *path, TString &url)
{
return fSystem->Locate(path, url);
}
Int_t TNetXNGFileStager::LocateCollection(TFileCollection *fc,
Bool_t addDummyUrl)
{
if (!fc) {
Error("LocateCollection", "No input collection given");
return -1;
}
int numFiles = 0;
TFileInfo *info;
TIter it(fc->GetList());
TString startUrl, endUrl;
while ((info = dynamic_cast<TFileInfo *>(it.Next())) != NULL) {
startUrl = info->GetCurrentUrl()->GetUrl();
if (fSystem->Locate(startUrl.Data(), endUrl)) {
info->ResetBit(TFileInfo::kStaged);
if (addDummyUrl)
info->AddUrl("noop://none", kTRUE);
if (gDebug > 1)
Info("LocateCollection", "Not found: %s", startUrl.Data());
}
else {
info->SetBit(TFileInfo::kStaged);
if (startUrl != endUrl) {
info->AddUrl(endUrl.Data(), kTRUE);
} else if (addDummyUrl) {
info->AddUrl("noop://redir", kTRUE);
}
if (gDebug > 1)
Info("LocateCollection", "Found: %s --> %s", startUrl.Data(),
endUrl.Data());
}
numFiles++;
}
return numFiles;
}
Bool_t TNetXNGFileStager::Matches(const char *s)
{
return ((s && (fName == s)) ? kTRUE : kFALSE);
}
Bool_t TNetXNGFileStager::Stage(const char *path, Option_t *opt)
{
Int_t priority = ParseStagePriority(opt);
return fSystem->Stage(path, priority);
}
Bool_t TNetXNGFileStager::Stage(TCollection *paths, Option_t *opt)
{
Int_t priority = ParseStagePriority(opt);
return fSystem->Stage(paths, priority);
}
UChar_t TNetXNGFileStager::ParseStagePriority(Option_t *opt)
{
UChar_t priority = 0;
Ssiz_t from = 0;
TString token;
while (TString(opt).Tokenize(token, from, "[ ,|]")) {
if (token.Contains("priority=")) {
token.ReplaceAll("priority=", "");
if (token.IsDigit()) {
priority = token.Atoi();
}
}
}
return priority;
}
TNetXNGFileStager.cxx:100 TNetXNGFileStager.cxx:101 TNetXNGFileStager.cxx:102 TNetXNGFileStager.cxx:103 TNetXNGFileStager.cxx:104 TNetXNGFileStager.cxx:105 TNetXNGFileStager.cxx:106 TNetXNGFileStager.cxx:107 TNetXNGFileStager.cxx:108 TNetXNGFileStager.cxx:109 TNetXNGFileStager.cxx:110 TNetXNGFileStager.cxx:111 TNetXNGFileStager.cxx:112 TNetXNGFileStager.cxx:113 TNetXNGFileStager.cxx:114 TNetXNGFileStager.cxx:115 TNetXNGFileStager.cxx:116 TNetXNGFileStager.cxx:117 TNetXNGFileStager.cxx:118 TNetXNGFileStager.cxx:119 TNetXNGFileStager.cxx:120 TNetXNGFileStager.cxx:121 TNetXNGFileStager.cxx:122 TNetXNGFileStager.cxx:123 TNetXNGFileStager.cxx:124 TNetXNGFileStager.cxx:125 TNetXNGFileStager.cxx:126 TNetXNGFileStager.cxx:127 TNetXNGFileStager.cxx:128 TNetXNGFileStager.cxx:129 TNetXNGFileStager.cxx:130 TNetXNGFileStager.cxx:131 TNetXNGFileStager.cxx:132 TNetXNGFileStager.cxx:133 TNetXNGFileStager.cxx:134 TNetXNGFileStager.cxx:135 TNetXNGFileStager.cxx:136 TNetXNGFileStager.cxx:137 TNetXNGFileStager.cxx:138 TNetXNGFileStager.cxx:139 TNetXNGFileStager.cxx:140 TNetXNGFileStager.cxx:141 TNetXNGFileStager.cxx:142 TNetXNGFileStager.cxx:143 TNetXNGFileStager.cxx:144 TNetXNGFileStager.cxx:145 TNetXNGFileStager.cxx:146 TNetXNGFileStager.cxx:147 TNetXNGFileStager.cxx:148 TNetXNGFileStager.cxx:149 TNetXNGFileStager.cxx:150 TNetXNGFileStager.cxx:151 TNetXNGFileStager.cxx:152 TNetXNGFileStager.cxx:153 TNetXNGFileStager.cxx:154 TNetXNGFileStager.cxx:155 TNetXNGFileStager.cxx:156 TNetXNGFileStager.cxx:157 TNetXNGFileStager.cxx:158 TNetXNGFileStager.cxx:159 TNetXNGFileStager.cxx:160 TNetXNGFileStager.cxx:161 TNetXNGFileStager.cxx:162 TNetXNGFileStager.cxx:163 TNetXNGFileStager.cxx:164 TNetXNGFileStager.cxx:165 TNetXNGFileStager.cxx:166 TNetXNGFileStager.cxx:167 TNetXNGFileStager.cxx:168 TNetXNGFileStager.cxx:169 TNetXNGFileStager.cxx:170 TNetXNGFileStager.cxx:171 TNetXNGFileStager.cxx:172 TNetXNGFileStager.cxx:173 TNetXNGFileStager.cxx:174 TNetXNGFileStager.cxx:175 TNetXNGFileStager.cxx:176 TNetXNGFileStager.cxx:177 TNetXNGFileStager.cxx:178 TNetXNGFileStager.cxx:179 TNetXNGFileStager.cxx:180 TNetXNGFileStager.cxx:181 TNetXNGFileStager.cxx:182 TNetXNGFileStager.cxx:183 TNetXNGFileStager.cxx:184 TNetXNGFileStager.cxx:185 TNetXNGFileStager.cxx:186 TNetXNGFileStager.cxx:187 TNetXNGFileStager.cxx:188 TNetXNGFileStager.cxx:189 TNetXNGFileStager.cxx:190 TNetXNGFileStager.cxx:191 TNetXNGFileStager.cxx:192 TNetXNGFileStager.cxx:193 TNetXNGFileStager.cxx:194 TNetXNGFileStager.cxx:195