12 #include "shift/stager_api.h"
23 size_t suffix = path.find(
"?");
24 if (suffix == std::string::npos)
28 if (path.find (
":") == std::string::npos)
30 size_t e = path.find_first_not_of (
"/");
31 if (e != std::string::npos)
33 size_t c = path.find(
"/castor/");
34 if ((c != std::string::npos) && (c == e-1))
38 prefix =
"rfio:///?path=";
42 c = path.find(
"/dpm/");
43 if ((c != std::string::npos) && (c == e-1))
56 prefix = path.substr(0, suffix);
57 size_t h = prefix.find_first_not_of(
'/');
58 size_t s = prefix.find_last_not_of(
'/');
60 prefix.replace(0,h,
"rfio://");
64 return prefix + path.substr(suffix);
87 <<
"SiteLocalConfig Failed: SiteLocalConfigService is not loaded yet."
88 <<
"Will use default 'castor' RFIO implementation.";
94 putenv(const_cast<char *>(
"RFIO_TCP_NODELAY=1"));
124 size_t castor = npath.find(
"?path=/castor/");
125 size_t rest = npath.find(
"&");
126 if (proto !=
"rfio" || castor == std::string::npos)
130 size_t len = (rest == std::string::npos ? rest : rest-castor);
134 opts.stage_host = getenv(
"STAGE_HOST");
135 opts.service_class = getenv(
"STAGE_SVCCLASS");
137 opts.stage_version = 2;
139 stage_prepareToGet_filereq req;
140 req.protocol = (
char *)
"rfio";
141 req.filename = (
char *) stagepath.c_str();
145 stage_prepareToGet_fileresp *resp = 0;
146 int rc = stage_prepareToGet(0, &req, 1, &resp, &nresp, 0, &opts);
149 ex <<
"Error while staging in '" << stagepath
151 <<
" (serrno=" <<
serrno <<
")";
152 ex.
addContext(
"Calling RFIOStorageMaker::stagein()");
156 if (nresp == 1 && resp->errorCode != 0) {
158 ex <<
"Error while staging in '" << stagepath
159 <<
"', stagein error was: " << resp->errorMessage
160 <<
" (code=" << resp->errorCode <<
")";
161 ex.
addContext(
"Calling RFIOStorageMaker::stagein()");
165 free(resp->filename);
166 free(resp->errorMessage);
CacheHint cacheHint(void) const
std::unique_ptr< Storage > wrapNonLocalFile(std::unique_ptr< Storage > s, const std::string &proto, const std::string &path, int mode) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
virtual void stagein(const std::string &proto, const std::string &path, const AuxSettings &) const override
static const StorageFactory * get(void)
int rfio_access(const char *filepath, int mode)
std::string normalise(const std::string &path) const
virtual std::unique_ptr< Storage > open(const std::string &proto, const std::string &path, int mode, const AuxSettings &) const override
ReadHint readHint(void) const
void addContext(std::string const &context)
#define DEFINE_EDM_PLUGIN(factory, type, name)
virtual std::string const rfioType(void) const =0
virtual bool check(const std::string &, const std::string &path, const AuxSettings &, IOOffset *size=0) const override
int rfio_stat64(const char *path, struct stat *statbuf)
tuple size
Write out results.
T get(const Candidate &c)