Loading...
Searching...
No Matches
XrdPfcIO.cc
Go to the documentation of this file.
#include "XrdPfcIO.hh"
#include "XrdPfcTrace.hh"
#include "XrdCl/XrdClURL.hh"
using namespace XrdPfc;
IO::IO(XrdOucCacheIO *io, Cache &cache) :
m_cache (cache),
m_traceID ("IO"),
m_active_read_reqs(0),
m_io (io),
m_read_seqid (0u)
{}
//==============================================================================
void IO::Update(XrdOucCacheIO &iocp)
{
SetInput(&iocp);
RefreshLocation();
TRACE_PC(Info, const char* loc = GetLocation(),
"Update() " << Path() << " location: " <<
((loc && loc[0] != 0) ? loc : "<not set>"));
}
void IO::SetInput(XrdOucCacheIO* x)
{
m_io = x;
}
XrdOucCacheIO* IO::GetInput()
{
return m_io;
}
std::string IO::GetFilename()
{
return XrdCl::URL(GetPath()).GetPath();
}
//==============================================================================
bool IO::Detach(XrdOucCacheIOCD &iocdP)
{
// Called from XrdPosixFile when local connection is closed.
if ( ! ioActive())
{
DetachFinalize();
return true;
}
else
{
class FutureDetach : public XrdJob
{
IO *f_io;
XrdOucCacheIOCD *f_detach_cb;
time_t f_wait_time;
public:
FutureDetach(IO *io, XrdOucCacheIOCD *cb, time_t wt) :
f_io (io),
f_detach_cb (cb),
f_wait_time (wt)
{}
void DoIt()
{
if (f_io->ioActive())
{
// Reschedule up to 120 sec in the future.
f_wait_time = std::min(2 * f_wait_time, (time_t) 120);
Schedule();
}
else
{
f_io->DetachFinalize();
f_detach_cb->DetachDone();
delete this;
}
}
void Schedule()
{
Cache::schedP->Schedule(this, time(0) + f_wait_time);
}
};
(new FutureDetach(this, &iocdP, 10))->Schedule();
return false;
}
}
DoIt
int DoIt(int argpnt, int argc, char **argv, bool singleshot)
Definition XrdAccTest.cc:262
XrdClURL.hh
XrdPfcIO.hh
XrdPfcTrace.hh
TRACE_PC
#define TRACE_PC(act, pre_code, x)
Definition XrdPfcTrace.hh:59
XrdCl::URL
URL representation.
Definition XrdClURL.hh:31
XrdCl::URL::GetPath
const std::string & GetPath() const
Get the path.
Definition XrdClURL.hh:217
XrdJob
Definition XrdJob.hh:43
XrdOucCacheIOCD
Definition XrdOucCache.hh:82
XrdOucCacheIOCD::DetachDone
virtual void DetachDone()=0
Indicate that the CacheIO object has been detached.
XrdOucCacheIO
Definition XrdOucCache.hh:105
XrdOucCacheIO::XrdOucCacheIO
XrdOucCacheIO()
Construct and Destructor.
Definition XrdOucCache.hh:480
XrdPfc::Cache
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
Definition XrdPfc.hh:163
XrdPfc::Cache::schedP
static XrdScheduler * schedP
Definition XrdPfc.hh:302
XrdPfc::IO::Path
const char * Path() override
Original data source URL.
Definition XrdPfcIO.hh:24
XrdPfc::IO::IO
IO(XrdOucCacheIO *io, Cache &cache)
Definition XrdPfcIO.cc:7
XrdPfc::IO::GetPath
const char * GetPath()
Definition XrdPfcIO.hh:53
XrdPfc::IO::GetInput
XrdOucCacheIO * GetInput()
Definition XrdPfcIO.cc:31
XrdPfc::IO::m_traceID
const char * m_traceID
Definition XrdPfcIO.hh:51
XrdPfc::IO::m_cache
Cache & m_cache
reference to Cache object
Definition XrdPfcIO.hh:50
XrdPfc::IO::m_active_read_reqs
RAtomic_int m_active_read_reqs
number of active read requests
Definition XrdPfcIO.hh:70
XrdPfc::IO::RefreshLocation
const char * RefreshLocation()
Definition XrdPfcIO.hh:55
XrdPfc::IO::Detach
bool Detach(XrdOucCacheIOCD &iocdP) final
Definition XrdPfcIO.cc:43
XrdPfc::IO::ioActive
virtual bool ioActive()=0
XrdPfc::IO::GetLocation
const char * GetLocation()
Definition XrdPfcIO.hh:44
XrdPfc::IO::Update
void Update(XrdOucCacheIO &iocp) override
Definition XrdPfcIO.cc:17
XrdPfc::IO::DetachFinalize
virtual void DetachFinalize()=0
XrdPfc::IO::GetFilename
std::string GetFilename()
Definition XrdPfcIO.cc:36
XrdPfc::Info
Status of cached file. Can be read from and written into a binary file.
Definition XrdPfcInfo.hh:41
XrdPfc
Definition XrdPfc.hh:41