XRootD
XrdOssArcStage Class Reference

#include <XrdOssArcStage.hh>

+ Inheritance diagram for XrdOssArcStage:
+ Collaboration diagram for XrdOssArcStage:

Public Types

enum  MssRC {
  isBad = -1 ,
  isFalse = 0 ,
  isTrue = 1
}
 

Public Member Functions

 XrdOssArcStage (const char *aPath)
 
virtual ~XrdOssArcStage ()
 
virtual void DoIt () override
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 

Static Public Member Functions

static MssRC isOnline (const char *path)
 
static int Stage (const char *path, const char *mssPath)
 

Additional Inherited Members

- Public Attributes inherited from XrdJob
const char * Comment
 
XrdJobNextJob
 

Detailed Description

Definition at line 40 of file XrdOssArcStage.hh.

Member Enumeration Documentation

◆ MssRC

Enumerator
isBad 
isFalse 
isTrue 

Definition at line 46 of file XrdOssArcStage.hh.

Constructor & Destructor Documentation

◆ XrdOssArcStage()

XrdOssArcStage::XrdOssArcStage ( const char *  aPath)
inline

Definition at line 52 of file XrdOssArcStage.hh.

52  : XrdJob("Arc Staging"),
53  arcvPath(aPath) {}
XrdJob(const char *desc="")
Definition: XrdJob.hh:51

◆ ~XrdOssArcStage()

virtual XrdOssArcStage::~XrdOssArcStage ( )
inlinevirtual

Definition at line 55 of file XrdOssArcStage.hh.

55 {}

Member Function Documentation

◆ DoIt()

void XrdOssArcStage::DoIt ( )
overridevirtual

Implements XrdJob.

Definition at line 90 of file XrdOssArcStage.cc.

91 {
92  TraceInfo("Bring_Online",0);
93  const char* nxtPath;
94  time_t seTime;
95  int fd;
96 
97 // The arcvPath is the path of the file in the locally mounted tape buffer.
98 // Simply open it to force it to be staged online.
99 //
100 do{DEBUG("Staging "<<arcvPath);
101  seTime = time(0);
102  if ((fd = XrdSysFD_Open(arcvPath, O_RDONLY)) < 0)
103  StageError(errno, "open/stage file", arcvPath);
104  else {close(fd);
105  seTime = time(0) - seTime;
106  DEBUG(arcvPath<<" staged in "<<seTime<<" second(s)");
107  }
108 
109 // Check if there is something pending that we can do now
110 //
111  schedMtx.Lock();
112  if (Pending.empty()) break;
113  nxtPath = Pending.front();
114  Pending.pop();
115  schedMtx.UnLock();
116 
117 // Reset this object to handle the path
118 //
119  Reset(nxtPath);
120 
121  } while(true);
122 
123 // Do final reset as we finished processing
124 //
125  Reset(0);
126 
127 // We are done, so delete this object and return
128 //
129  int n = Config.maxStage++; // schedMtx is still held
130  schedMtx.UnLock();
131  DEBUG("Staging queue empty; MaxStage="<<n+1);
132  delete this;
133 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define TraceInfo(x, y)
#define close(a)
Definition: XrdPosix.hh:48
XrdCmsConfig Config
std::queue< const char * > Pending
XrdSysMutex schedMtx

References close, XrdOssArcGlobals::Config, DEBUG, XrdSysMutex::Lock(), XrdOssArcConfig::maxStage, XrdOssArcGlobals::Pending, XrdOssArcGlobals::schedMtx, TraceInfo, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ isOnline()

XrdOssArcStage::MssRC XrdOssArcStage::isOnline ( const char *  path)
static

Definition at line 139 of file XrdOssArcStage.cc.

140 {
141  TraceInfo("isOnline",0);
142  int rc, finrc;
143 
144  DEBUG("Running "<<Config.MssComName<<" online "<<path);
145  rc = Config.MssComProg->Run("online", path);
146 
147 // Adjust return code. Note that XrdOucProg return -status!
148 //
149  if (rc < -1 || rc > 1) finrc = -1;
150  else finrc = -rc;
151  DEBUG("MssComCmd returned "<<rc<<" -> "<<finrc);
152 
153  return static_cast<MssRC>(finrc);
154 }

References XrdOssArcGlobals::Config, DEBUG, XrdOssArcConfig::MssComName, XrdOssArcConfig::MssComProg, XrdOucProg::Run(), and TraceInfo.

+ Here is the call graph for this function:

◆ Stage()

int XrdOssArcStage::Stage ( const char *  path,
const char *  mssPath 
)
static

Definition at line 186 of file XrdOssArcStage.cc.

187 {
188  TraceInfo("Stage",0);
189  ActInfo aInfo(path);
190 
191 // Check if this is being staged
192 //
193  stageMtx.Lock();
194  auto it = Active.find(&aInfo);
195  if (it != Active.end())
196  {int rc;
197  if ((*it)->rc == 0) rc = EINPROGRESS;
198  else {rc = (*it)->rc;
199  ActInfo* aiP = *it;
200  Active.erase(it);
201  delete aiP;
202  }
203  stageMtx.UnLock();
204  return rc;
205  } else stageMtx.UnLock();
206 
207 // Make sure the path exists and is actually online
208 //
209  MssRC mssRC = isOnline(mssPath);
210  switch(mssRC)
211  {case isFalse: break;
212  case isTrue: return 0; break;
213  default: return EINVAL; break;
214  }
215 
216 // Create a an action information object. This will copy the path and we
217 // can use the copy in other places as the pointer i
218 //
219  ActInfo* stageInfo = new ActInfo(path, true);
220 
221 // Add the path to the staging set. Another thread may have beat us to it.
222 //
223  stageMtx.Lock();
224  auto iResult = Active.insert(stageInfo);
225  stageMtx.UnLock();
226  if (!iResult.second)
227  {delete stageInfo;
228  return EINPROGRESS;
229  }
230 
231 // Schedule this staging request if we are allowed to do so
232 //
233  int smx;
234  schedMtx.Lock();
235  if (Config.maxStage)
236  {smx = Config.maxStage--;
237  schedMtx.UnLock();
238  XrdOssArcStage *asP = new XrdOssArcStage(stageInfo->path);
239  schedP->Schedule((XrdJob*)asP);
240  return EINPROGRESS;
241  } else smx = 0;
242 
243 // Too many things being staged, so queue this request
244 //
245  Pending.push(stageInfo->path);
246  schedMtx.UnLock();
247 
248 // Do some debugging
249 //
250  DEBUG("MaxStage="<<smx<<" staging '"<<path<<(smx?"' scheduled":"' queued"));
251 
252 // All done
253 //
254  return EINPROGRESS;
255 }
Definition: XrdJob.hh:43
XrdOssArcStage(const char *aPath)
static MssRC isOnline(const char *path)
void Schedule(XrdJob *jp)
XrdScheduler * schedP
XrdSysMutex stageMtx

References XrdOssArcGlobals::Config, DEBUG, XrdSysMutex::Lock(), XrdOssArcConfig::maxStage, XrdOssArcGlobals::ActInfo::path, XrdOssArcGlobals::Pending, XrdOssArcGlobals::schedMtx, XrdOssArcGlobals::schedP, XrdScheduler::Schedule(), XrdOssArcGlobals::stageMtx, TraceInfo, and XrdSysMutex::UnLock().

Referenced by XrdOssArcFile::Open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: