xrootd
XrdFileCacheFactory.hh
Go to the documentation of this file.
1 #ifndef __XRDFILECACHE_FACTORY_HH__
2 #define __XRDFILECACHE_FACTORY_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 
21 #include <string>
22 #include <vector>
23 #include <map>
24 
25 #include "XrdSys/XrdSysPthread.hh"
26 #include "XrdOuc/XrdOucCache.hh"
27 
28 #include "XrdCl/XrdClDefaultEnv.hh"
29 #include "XrdVersion.hh"
30 #include "XrdFileCacheDecision.hh"
31 
32 class XrdOucStream;
33 class XrdSysError;
34 
35 namespace XrdCl
36 {
37  class Log;
38 }
39 
40 namespace XrdFileCache
41 {
42  //----------------------------------------------------------------------------
44  //----------------------------------------------------------------------------
46  {
48  m_hdfsmode(false),
49  m_diskUsageLWM(-1),
50  m_diskUsageHWM(-1),
51  m_bufferSize(1024*1024),
54  m_hdfsbsize(128*1024*1024) {}
55 
56  bool m_hdfsmode;
57  std::string m_cache_dir;
58  std::string m_username;
59 
60  long long m_diskUsageLWM;
61  long long m_diskUsageHWM;
62 
63  long long m_bufferSize;
66  long long m_hdfsbsize;
67  };
68 
69 
70  //----------------------------------------------------------------------------
72  //----------------------------------------------------------------------------
73  class Factory : public XrdOucCache
74  {
75  public:
76  //--------------------------------------------------------------------------
78  //--------------------------------------------------------------------------
79  Factory();
80 
81  //---------------------------------------------------------------------
84  //---------------------------------------------------------------------
85  virtual XrdOucCacheIO *Attach(XrdOucCacheIO *, int Options=0) { return NULL; }
86 
87  //---------------------------------------------------------------------
90  //---------------------------------------------------------------------
91  virtual int isAttached() { return false; }
92 
93  //---------------------------------------------------------------------
95  //---------------------------------------------------------------------
96  virtual XrdOucCache* Create(Parms &, XrdOucCacheIO::aprParms *aprP);
97 
98  XrdOss* GetOss() const { return m_output_fs; }
99 
100  //---------------------------------------------------------------------
102  //---------------------------------------------------------------------
104 
105  //--------------------------------------------------------------------
111  //--------------------------------------------------------------------
112  bool Decide(XrdOucCacheIO*);
113 
114  //------------------------------------------------------------------------
116  //------------------------------------------------------------------------
117  const Configuration& RefConfiguration() const { return m_configuration; }
118 
119 
120  //---------------------------------------------------------------------
128  //---------------------------------------------------------------------
129  bool Config(XrdSysLogger *logger, const char *config_filename, const char *parameters);
130 
131  //---------------------------------------------------------------------
133  //---------------------------------------------------------------------
134  static Factory &GetInstance();
135 
136  //---------------------------------------------------------------------
138  //---------------------------------------------------------------------
139  static bool VCheck(XrdVersionInfo &urVersion) { return true; }
140 
141  //---------------------------------------------------------------------
143  //---------------------------------------------------------------------
144  void CacheDirCleanup();
145 
146  private:
147  bool ConfigParameters(std::string, XrdOucStream&);
148  bool ConfigXeq(char *, XrdOucStream &);
149  bool xdlib(XrdOucStream &);
150 
151  XrdCl::Log* clLog() const { return XrdCl::DefaultEnv::GetLog(); }
152 
153  static Factory *m_factory;
154 
158 
159  std::vector<XrdFileCache::Decision*> m_decisionpoints;
160 
161  std::map<std::string, long long> m_filesInQueue;
162 
164  };
165 }
166 
167 #endif
Instantiates Cache and Decision plugins. Parses configuration file.
Definition: XrdFileCacheFactory.hh:73
bool ConfigXeq(char *, XrdOucStream &)
XrdOucCacheStats m_stats
passed to cache, currently not used
Definition: XrdFileCacheFactory.hh:156
Definition: XrdFileCache.hh:30
long long m_diskUsageHWM
cache purge high water mark
Definition: XrdFileCacheFactory.hh:61
Definition: XrdOucCache.hh:158
long long m_diskUsageLWM
cache purge low water mark
Definition: XrdFileCacheFactory.hh:60
std::vector< XrdFileCache::Decision * > m_decisionpoints
decision plugins
Definition: XrdFileCacheFactory.hh:159
bool Config(XrdSysLogger *logger, const char *config_filename, const char *parameters)
Parse configuration file.
Definition: XrdOucStream.hh:43
bool ConfigParameters(std::string, XrdOucStream &)
XrdSysError & GetSysError()
Getter for xrootd logger.
Definition: XrdFileCacheFactory.hh:103
static bool VCheck(XrdVersionInfo &urVersion)
Version check.
Definition: XrdFileCacheFactory.hh:139
bool m_hdfsmode
flag for enabling block-level operation
Definition: XrdFileCacheFactory.hh:56
std::string m_username
username passed to oss plugin
Definition: XrdFileCacheFactory.hh:58
Definition: XrdSysError.hh:87
int m_NRamBuffersRead
number of read in-memory cache blocks
Definition: XrdFileCacheFactory.hh:64
static Log * GetLog()
Get default log.
XrdCl::Log * clLog() const
Definition: XrdFileCacheFactory.hh:151
Definition: XrdOucCache.hh:313
Factory()
Constructor.
std::string m_cache_dir
path of disk cache
Definition: XrdFileCacheFactory.hh:57
bool Decide(XrdOucCacheIO *)
Makes decision if the original XrdOucCacheIO should be cached.
const Configuration & RefConfiguration() const
Reference XrdFileCache configuration.
Definition: XrdFileCacheFactory.hh:117
bool xdlib(XrdOucStream &)
virtual XrdOucCacheIO * Attach(XrdOucCacheIO *, int Options=0)
Unused abstract method. This method is implemented in the the Cache class.
Definition: XrdFileCacheFactory.hh:85
Definition: XrdClEnv.hh:28
virtual XrdOucCache * Create(Parms &, XrdOucCacheIO::aprParms *aprP)
Creates XrdFileCache::Cache object.
virtual int isAttached()
Unused abstract method. This information is available in the Cache class.
Definition: XrdFileCacheFactory.hh:91
Contains parameters configurable from the xrootd config file.
Definition: XrdFileCacheFactory.hh:45
Definition: XrdOucCache.hh:278
XrdOss * m_output_fs
disk cache file system
Definition: XrdFileCacheFactory.hh:157
Configuration m_configuration
configurable parameters
Definition: XrdFileCacheFactory.hh:163
int m_NRamBuffersPrefetch
number of prefetch in-memory cache blocks
Definition: XrdFileCacheFactory.hh:65
Definition: XrdSysLogger.hh:50
static Factory * m_factory
this object
Definition: XrdFileCacheFactory.hh:153
Configuration()
Definition: XrdFileCacheFactory.hh:47
std::map< std::string, long long > m_filesInQueue
Definition: XrdFileCacheFactory.hh:161
static Factory & GetInstance()
Singleton access.
Definition: XrdOss.hh:173
void CacheDirCleanup()
Thread function running disk cache purge periodically.
Definition: XrdOucCache.hh:93
XrdSysError m_log
XrdFileCache namespace logger.
Definition: XrdFileCacheFactory.hh:155
XrdOss * GetOss() const
Definition: XrdFileCacheFactory.hh:98
long long m_bufferSize
prefetch buffer size, default 1MB
Definition: XrdFileCacheFactory.hh:63
long long m_hdfsbsize
used with m_hdfsmode, default 128MB
Definition: XrdFileCacheFactory.hh:66