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/XrdOucCache2.hh"
24 #include "XrdSys/XrdSysPthread.hh"
25 
26 #include "XrdFileCacheIO.hh"
27 
28 class XrdSysError;
29 class XrdOssDF;
30 
31 namespace XrdFileCache
32 {
33 //----------------------------------------------------------------------------
37 //----------------------------------------------------------------------------
38 class IOFileBlock : public IO
39 {
40 public:
41  //------------------------------------------------------------------------
43  //------------------------------------------------------------------------
44  IOFileBlock(XrdOucCacheIO2 *io, XrdOucCacheStats &stats, Cache &cache);
45 
46  //------------------------------------------------------------------------
48  //------------------------------------------------------------------------
49  ~IOFileBlock();
50 
51  //---------------------------------------------------------------------
55  //---------------------------------------------------------------------
56  virtual XrdOucCacheIO *Detach();
57 
58  //---------------------------------------------------------------------
60  //---------------------------------------------------------------------
62 
63  virtual int Read(char *Buffer, long long Offset, int Length);
64 
67  virtual bool ioActive();
68 
69  virtual int Fstat(struct stat &sbuff);
70 
71  virtual long long FSize();
72 
73 private:
74  long long m_blocksize;
75  std::map<int, File*> m_blocks;
77  struct stat *m_localStat;
80 
81  void GetBlockSizeFromPath();
82  int initLocalStat();
83  File* newBlockFile(long long off, int blocksize);
84  void CloseInfoFile();
85 };
86 }
87 
88 #endif
virtual int Fstat(struct stat &sbuff)
Downloads original file into multiple files, chunked into blocks. Only blocks that are asked for are ...
Definition: XrdFileCacheIOFileBlock.hh:38
virtual XrdOucCacheIO * Detach()
Definition: XrdFileCache.hh:40
File * newBlockFile(long long off, int blocksize)
Definition: XrdOucCache.hh:127
Status of cached file. Can be read from and written into a binary file.
Definition: XrdFileCacheInfo.hh:48
XrdOssDF * m_infoFile
Definition: XrdFileCacheIOFileBlock.hh:79
virtual bool ioActive()
Virtual method of XrdOucCacheIO. Called to check if destruction needs to be done in a separate task...
Info m_info
Definition: XrdFileCacheIOFileBlock.hh:78
XrdSysMutex m_mutex
map mutex
Definition: XrdFileCacheIOFileBlock.hh:76
Definition: XrdSysError.hh:89
Definition: XrdSysPthread.hh:165
Base cache-io class that implements XrdOucCacheIO abstract methods.
Definition: XrdFileCacheIO.hh:16
std::map< int, File * > m_blocks
map of created blocks
Definition: XrdFileCacheIOFileBlock.hh:75
Definition: XrdOucCache2.hh:62
virtual long long FSize()
long long m_blocksize
size of file-block
Definition: XrdFileCacheIOFileBlock.hh:74
virtual void Read(XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
Definition: XrdOucCache2.hh:107
Definition: XrdFileCacheFile.hh:133
#define stat(a, b)
Definition: XrdPosix.hh:96
struct stat * m_localStat
Definition: XrdFileCacheIOFileBlock.hh:77
~IOFileBlock()
Destructor.
Definition: XrdOss.hh:59
Definition: XrdOucCacheStats.hh:40
virtual int Read(char *Buffer, long long Offset, int Length)
IOFileBlock(XrdOucCacheIO2 *io, XrdOucCacheStats &stats, Cache &cache)
Constructor.
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
Definition: XrdFileCache.hh:129