13 #include "XrdCl/XrdClDefaultEnv.hh" 14 #include "XrdNet/XrdNetUtils.hh" 21 class PrepareHandler :
public XrdCl::ResponseHandler {
23 PrepareHandler(
const XrdCl::URL &
url) : m_fs(url) { m_fileList.push_back(url.GetPath()); }
25 void callAsyncPrepare() {
26 auto status = m_fs.Prepare(m_fileList, XrdCl::PrepareFlags::Stage, 0,
this);
28 LogDebug(
"StageInError") <<
"XrdCl::FileSystem::Prepare submit failed with error '" <<
status.ToStr()
29 <<
"' (errNo = " <<
status.errNo <<
")";
34 void HandleResponse(XrdCl::XRootDStatus *
status, XrdCl::AnyObject *response)
override {
36 if (!status->IsOK()) {
37 LogDebug(
"StageInError") <<
"XrdCl::FileSystem::Prepare failed with error '" << status->ToStr()
38 <<
"' (errNo = " << status->errNo <<
")";
46 XrdCl::FileSystem m_fs;
47 std::vector<std::string> m_fileList;
54 static const unsigned int XRD_DEFAULT_TIMEOUT = 3*60;
64 XrdCl::Env *
env = XrdCl::DefaultEnv::GetEnv();
67 env->PutString(
"NetworkStack",
"IPAuto");
69 XrdNetUtils::SetAuto(XrdNetUtils::prefAuto);
70 setTimeout(XRD_DEFAULT_TIMEOUT);
95 auto file = std::make_unique<XrdFile>(fullpath,
mode);
106 XrdCl::URL
url(fullpath);
108 auto prep_handler =
new PrepareHandler(url);
109 prep_handler->callAsyncPrepare();
121 XrdCl::URL
url(fullpath);
122 XrdCl::FileSystem fs(url);
124 XrdCl::StatInfo *
stat;
125 if (!(fs.Stat(url.GetPath(),
stat)).IsOK() || (stat ==
nullptr))
136 auto oldLevel = m_lastDebugLevel.load();
137 if(level == oldLevel) {
140 std::lock_guard<std::mutex> guard(m_envMutex);
141 if(oldLevel != m_lastDebugLevel) {
151 XrdCl::DefaultEnv::SetLogLevel(
"Warning");
154 XrdCl::DefaultEnv::SetLogLevel(
"Info");
157 XrdCl::DefaultEnv::SetLogLevel(
"Debug");
160 XrdCl::DefaultEnv::SetLogLevel(
"Dump");
163 XrdCl::DefaultEnv::SetLogLevel(
"Dump");
167 ex <<
"Invalid log level specified " <<
level;
168 ex.
addContext(
"Calling XrdStorageMaker::setDebugLevel()");
171 m_lastDebugLevel =
level;
176 timeout = timeout ? timeout : XRD_DEFAULT_TIMEOUT;
178 auto oldTimeout = m_lastTimeout.load();
179 if (oldTimeout == timeout) {
183 std::lock_guard<std::mutex> guard(m_envMutex);
184 if (oldTimeout != m_lastTimeout) {
189 XrdCl::Env *
env = XrdCl::DefaultEnv::GetEnv();
192 env->PutInt(
"StreamTimeout", timeout);
193 env->PutInt(
"RequestTimeout", timeout);
194 env->PutInt(
"ConnectionWindow", timeout);
195 env->PutInt(
"StreamErrorWindow", timeout);
199 env->PutInt(
"ConnectionWindow", timeout/6+1);
200 env->PutInt(
"ConnectionRetry", 2);
static boost::mutex mutex
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
std::atomic< unsigned int > m_lastDebugLevel
bool check(const std::string &proto, const std::string &path, const AuxSettings &aux, IOOffset *size=0) const override
std::unique_ptr< Storage > open(const std::string &proto, const std::string &path, int mode, const AuxSettings &aux) const override
void stagein(const std::string &proto, const std::string &path, const AuxSettings &aux) const override
static const StorageFactory * get(void)
void setTimeout(unsigned int timeout) const
std::atomic< unsigned int > m_lastTimeout
#define DEFINE_FWK_SERVICE(type)
ReadHint readHint(void) const
void addContext(std::string const &context)
#define DEFINE_EDM_PLUGIN(factory, type, name)
void setDebugLevel(unsigned int level) const