XRootD
XrdPfcIO.cc
Go to the documentation of this file.
1 #include "XrdPfcIO.hh"
2 #include "XrdPfcTrace.hh"
3 
4 using namespace XrdPfc;
5 
6 IO::IO(XrdOucCacheIO *io, Cache &cache) :
7  m_cache (cache),
8  m_traceID ("IO"),
9  m_active_read_reqs(0),
10  m_io (io),
11  m_read_seqid (0u)
12 {}
13 
14 //==============================================================================
15 
17 {
18  SetInput(&iocp);
20  TRACE_PC(Info, const char* loc = GetLocation(),
21  "Update() " << Path() << " location: " <<
22  ((loc && loc[0] != 0) ? loc : "<not set>"));
23 }
24 
25 void IO::SetInput(XrdOucCacheIO* x)
26 {
27  m_io = x;
28 }
29 
31 {
32  return m_io;
33 }
34 
35 //==============================================================================
36 
38 {
39  // Called from XrdPosixFile when local connection is closed.
40 
41  if ( ! ioActive())
42  {
44 
45  return true;
46  }
47  else
48  {
49  class FutureDetach : public XrdJob
50  {
51  IO *f_io;
52  XrdOucCacheIOCD *f_detach_cb;
53  time_t f_wait_time;
54 
55  public:
56  FutureDetach(IO *io, XrdOucCacheIOCD *cb, time_t wt) :
57  f_io (io),
58  f_detach_cb (cb),
59  f_wait_time (wt)
60  {}
61 
62  void DoIt()
63  {
64  if (f_io->ioActive())
65  {
66  // Reschedule up to 120 sec in the future.
67  f_wait_time = std::min(2 * f_wait_time, (time_t) 120);
68  Schedule();
69  }
70  else
71  {
72  f_io->DetachFinalize();
73  f_detach_cb->DetachDone();
74 
75  delete this;
76  }
77  }
78 
79  void Schedule()
80  {
81  Cache::schedP->Schedule(this, time(0) + f_wait_time);
82  }
83  };
84 
85  (new FutureDetach(this, &iocdP, 30))->Schedule();
86 
87  return false;
88  }
89 }
int DoIt(int argpnt, int argc, char **argv, bool singleshot)
Definition: XrdAccTest.cc:262
#define TRACE_PC(act, pre_code, x)
Definition: XrdPfcTrace.hh:55
Definition: XrdJob.hh:43
virtual void DetachDone()=0
Indicate that the CacheIO object has been detached.
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
Definition: XrdPfc.hh:151
static XrdScheduler * schedP
Definition: XrdPfc.hh:285
Base cache-io class that implements some XrdOucCacheIO abstract methods.
Definition: XrdPfcIO.hh:16
IO(XrdOucCacheIO *io, Cache &cache)
Definition: XrdPfcIO.cc:6
XrdOucCacheIO * GetInput()
Definition: XrdPfcIO.cc:30
const char * Path() override
Original data source URL.
Definition: XrdPfcIO.hh:24
const char * RefreshLocation()
Definition: XrdPfcIO.hh:55
bool Detach(XrdOucCacheIOCD &iocdP) final
Definition: XrdPfcIO.cc:37
virtual bool ioActive()=0
const char * GetLocation()
Definition: XrdPfcIO.hh:44
void Update(XrdOucCacheIO &iocp) override
Definition: XrdPfcIO.cc:16
virtual void DetachFinalize()=0
Status of cached file. Can be read from and written into a binary file.
Definition: XrdPfcInfo.hh:41
void Schedule(XrdJob *jp)
Definition: XrdPfc.hh:41