xrootd
XrdFileCacheIOFileBlock.hh
Go to the documentation of this file.
1 #ifndef __XRDFILECACHE_IO_FILE_BLOCK_HH__
2 #define __XRDFILECACHE_IO_FILE_BLOCK_HH__
3 //----------------------------------------------------------------------------------
4 // Copyright (c) 2014 by Board of Trustees of the Leland Stanford, Jr., University
5 // Author: Alja Mrak-Tadel, Matevz Tadel, Brian Bockelman
6 //----------------------------------------------------------------------------------
7 // XRootD is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // XRootD is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19 //----------------------------------------------------------------------------------
20 #include <map>
21 #include <string>
22 
23 #include "XrdOuc/XrdOucCache.hh"
24 #include "XrdSys/XrdSysPthread.hh"
25 
26 #include "XrdFileCache.hh"
27 #include "XrdFileCachePrefetch.hh"
28 
29 class XrdSysError;
30 class XrdOssDF;
31 
32 namespace XrdFileCache
33 {
34  //----------------------------------------------------------------------------
38  //----------------------------------------------------------------------------
39  class IOFileBlock : public IO
40  {
41  public:
42  //------------------------------------------------------------------------
44  //------------------------------------------------------------------------
45  IOFileBlock(XrdOucCacheIO &io, XrdOucCacheStats &stats, Cache &cache);
46 
47  //------------------------------------------------------------------------
49  //------------------------------------------------------------------------
51 
52  //---------------------------------------------------------------------
56  //---------------------------------------------------------------------
57  virtual XrdOucCacheIO *Detach();
58 
59  //---------------------------------------------------------------------
61  //---------------------------------------------------------------------
62  virtual int Read(char *Buffer, long long Offset, int Length);
63 
64  private:
65  struct FileBlock
66  {
67  FileBlock(off_t off, XrdOucCacheIO* io) : m_prefetch(0), m_offset(off) {}
69  long long m_offset;
70  };
71 
72  long long m_blockSize;
73  std::map<int, FileBlock*> m_blocks;
75 
76  FileBlock* newBlockPrefetcher(long long off, int blocksize, XrdOucCacheIO* io);
77  };
78 }
79 
80 #endif
FileBlock(off_t off, XrdOucCacheIO *io)
Definition: XrdFileCacheIOFileBlock.hh:67
Downloads original file into multiple files, chunked into blocks. Only blocks that are asked for are ...
Definition: XrdFileCacheIOFileBlock.hh:39
virtual XrdOucCacheIO * Detach()
Definition: XrdOucCache.hh:158
XrdSysMutex m_mutex
map mutex
Definition: XrdFileCacheIOFileBlock.hh:74
Definition: XrdSysError.hh:87
Downloads data into a file on local disk and handles IO read requests.
Definition: XrdFileCachePrefetch.hh:40
long long m_offset
Definition: XrdFileCacheIOFileBlock.hh:69
Definition: XrdSysPthread.hh:140
Base cache-io class that implements XrdOucCacheIO abstract methods.
Definition: XrdFileCache.hh:125
Prefetch * m_prefetch
Definition: XrdFileCacheIOFileBlock.hh:68
FileBlock * newBlockPrefetcher(long long off, int blocksize, XrdOucCacheIO *io)
IOFileBlock(XrdOucCacheIO &io, XrdOucCacheStats &stats, Cache &cache)
Constructor.
std::map< int, FileBlock * > m_blocks
map of created blocks
Definition: XrdFileCacheIOFileBlock.hh:73
~IOFileBlock()
Destructor.
Definition: XrdFileCacheIOFileBlock.hh:50
Definition: XrdOss.hh:59
Definition: XrdOucCache.hh:93
virtual int Read(char *Buffer, long long Offset, int Length)
Pass Read request to the corresponding Prefetch object.
Definition: XrdFileCacheIOFileBlock.hh:65
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
Definition: XrdFileCache.hh:39
long long m_blockSize
size of file-block
Definition: XrdFileCacheIOFileBlock.hh:72