Skip to content

Commit

Permalink
Replace Prefetch class with File class to do async reads.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and abh3 committed Jun 30, 2016
1 parent aaed924 commit 5912da0
Show file tree
Hide file tree
Showing 13 changed files with 763 additions and 1,280 deletions.
10 changes: 4 additions & 6 deletions src/XrdFileCache/XrdFileCache.cc
Expand Up @@ -27,11 +27,10 @@
#include "XrdOuc/XrdOucEnv.hh"

#include "XrdFileCache.hh"
#include "XrdFileCachePrefetch.hh"
#include "XrdFileCacheFile.hh"
#include "XrdFileCacheIOEntireFile.hh"
#include "XrdFileCacheIOFileBlock.hh"
#include "XrdFileCacheFactory.hh"
#include "XrdFileCachePrefetch.hh"
#include "XrdFileCacheFactory.hh"x


XrdFileCache::Cache::WriteQ XrdFileCache::Cache::s_writeQ;
Expand Down Expand Up @@ -68,7 +67,6 @@ XrdOucCacheIO *Cache::Attach(XrdOucCacheIO *io, int Options)
else
cio = new IOEntireFile(*io, m_stats, *this);

cio->StartPrefetch();
return cio;
}
else
Expand Down Expand Up @@ -117,7 +115,7 @@ Cache::HaveFreeWritingSlots()

//______________________________________________________________________________
void
Cache::AddWriteTask(Prefetch* p, int ri, size_t s, bool fromRead)
Cache::AddWriteTask(File* p, int ri, size_t s, bool fromRead)
{
XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::AddWriteTask() wqsize = %d, bi=%d", s_writeQ.size, ri);
s_writeQ.condVar.Lock();
Expand All @@ -131,7 +129,7 @@ Cache::AddWriteTask(Prefetch* p, int ri, size_t s, bool fromRead)
}

//______________________________________________________________________________
void Cache::RemoveWriteQEntriesFor(Prefetch *p)
void Cache::RemoveWriteQEntriesFor(File *p)
{
s_writeQ.condVar.Lock();
std::list<WriteTask>::iterator i = s_writeQ.queue.begin();
Expand Down
15 changes: 7 additions & 8 deletions src/XrdFileCache/XrdFileCache.hh
Expand Up @@ -28,7 +28,7 @@ namespace XrdCl {
class Log;
}
namespace XrdFileCache {
class Prefetch;
class File;
}

namespace XrdFileCache
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace XrdFileCache
//---------------------------------------------------------------------
//! Add downloaded block in write queue.
//---------------------------------------------------------------------
static void AddWriteTask(Prefetch* p, int ramBlockidx, size_t size, bool fromRead);
static void AddWriteTask(File* p, int ramBlockidx, size_t size, bool fromRead);

//---------------------------------------------------------------------
//! Check write queue size is not over limit.
Expand All @@ -76,9 +76,9 @@ namespace XrdFileCache

//---------------------------------------------------------------------
//! \brief Remove blocks from write queue which belong to given prefetch.
//! This method is used at the time of Prefetch destruction.
//! This method is used at the time of File destruction.
//---------------------------------------------------------------------
static void RemoveWriteQEntriesFor(Prefetch *p);
static void RemoveWriteQEntriesFor(File *p);

//---------------------------------------------------------------------
//! Separate task which writes blocks from ram to disk.
Expand All @@ -101,10 +101,10 @@ namespace XrdFileCache

struct WriteTask
{
Prefetch* prefetch; //!< object queued for writing
File* prefetch; //!< object queued for writing
int ramBlockIdx; //!< in memory cache index
size_t size; //!< write size -- block size except in case this is the end file block
WriteTask(Prefetch* p, int ri, size_t s):prefetch(p), ramBlockIdx(ri), size(s){}
WriteTask(File* p, int ri, size_t s):prefetch(p), ramBlockIdx(ri), size(s){}
};

struct WriteQ
Expand All @@ -124,7 +124,7 @@ namespace XrdFileCache
//----------------------------------------------------------------------------
class IO : public XrdOucCacheIO
{
friend class Prefetch;
friend class File;

public:
IO (XrdOucCacheIO &io, XrdOucCacheStats &stats, Cache &cache) :
Expand All @@ -146,7 +146,6 @@ namespace XrdFileCache
virtual int Write(char *Buffer, long long Offset, int Length)
{ errno = ENOTSUP; return -1; }

virtual void StartPrefetch() {}

protected:
XrdCl::Log* clLog() const { return XrdCl::DefaultEnv::GetLog(); }
Expand Down
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCacheFactory.cc
Expand Up @@ -42,7 +42,7 @@

#include "XrdFileCache.hh"
#include "XrdFileCacheFactory.hh"
#include "XrdFileCachePrefetch.hh"
#include "XrdFileCacheFile.hh"


using namespace XrdFileCache;
Expand Down

0 comments on commit 5912da0

Please sign in to comment.