CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
magic_xattr.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_MAGIC_XATTR_H_
6 #define CVMFS_MAGIC_XATTR_H_
7 
8 #include <map>
9 #include <string>
10 
11 #include "backoff.h"
12 #include "catalog_counters.h"
13 #include "directory_entry.h"
14 #include "shortstring.h"
15 #include "util/exception.h"
16 #include "util/string.h"
17 
18 class MountPoint;
19 
26 };
27 
41  friend class MagicXattrManager;
42 
43  public:
45  int retval = pthread_mutex_init(&access_mutex_, NULL);
46  assert(retval == 0);
47  }
52  virtual bool PrepareValueFenced() { return true; }
60  virtual std::string GetValue() = 0;
62 
63  void Lock(PathString path, catalog::DirectoryEntry *dirent) {
64  int retval = pthread_mutex_lock(&access_mutex_);
65  assert(retval == 0);
66  path_ = path;
67  dirent_ = dirent;
68  }
69  void Release() {
70  int retval = pthread_mutex_unlock(&access_mutex_);
71  assert(retval == 0);
72  }
73 
74  virtual ~BaseMagicXattr() {}
75 
76  protected:
80 
81  pthread_mutex_t access_mutex_;
82 };
83 
89  public:
90  inline MagicXattrRAIIWrapper() : ptr_(NULL) { }
91 
92  inline explicit MagicXattrRAIIWrapper(
93  BaseMagicXattr *ptr,
94  PathString path,
96  : ptr_(ptr)
97  {
98  if (ptr_ != NULL) ptr_->Lock(path, d);
99  }
101  inline explicit MagicXattrRAIIWrapper(BaseMagicXattr *ptr) : ptr_(ptr) { }
102 
103  inline ~MagicXattrRAIIWrapper() { if (ptr_ != NULL) ptr_->Release(); }
104 
105  inline BaseMagicXattr* operator->() const { return ptr_; }
106  inline bool IsNull() const { return ptr_ == NULL; }
107  inline BaseMagicXattr* Move() {
108  BaseMagicXattr* ret = ptr_;
109  ptr_ = NULL;
110  return ret;
111  }
112 
113  protected:
115 };
116 
119 };
120 
123 };
124 
127 };
128 
143  public:
147  BaseMagicXattr* GetLocked(const std::string &name, PathString path,
149  std::string GetListString(catalog::DirectoryEntry *dirent);
150  void Register(const std::string &name, BaseMagicXattr *magic_xattr);
151 
153 
154  protected:
155  std::map<std::string, BaseMagicXattr *> xattr_list_;
158 };
159 
161  virtual bool PrepareValueFenced();
162  virtual std::string GetValue();
164 };
165 
167  std::string subcatalog_path_;
169 
170  virtual bool PrepareValueFenced();
171  virtual std::string GetValue();
172 };
173 
175  std::string chunk_list_;
176 
177  virtual bool PrepareValueFenced();
178  virtual std::string GetValue();
179 };
180 
182  uint64_t n_chunks_;
183 
184  virtual bool PrepareValueFenced();
185  virtual std::string GetValue();
186 };
187 
189  virtual bool PrepareValueFenced();
190  virtual std::string GetValue();
191 };
192 
194  virtual bool PrepareValueFenced();
195  virtual std::string GetValue();
196 };
197 
199  virtual bool PrepareValueFenced();
200  virtual std::string GetValue();
201 };
202 
204  virtual std::string GetValue();
205 };
206 
208  virtual std::string GetValue();
209 };
210 
212  virtual std::string GetValue();
213 };
214 
216  virtual bool PrepareValueFenced();
217  virtual std::string GetValue();
218 };
219 
221  virtual std::string GetValue();
222 };
223 
225  virtual std::string GetValue();
226 };
227 
229  virtual bool PrepareValueFenced();
230  virtual std::string GetValue();
231 };
232 
234  public:
235  LogBufferXattr();
236 
237  private:
238  // Generating the log buffer report involves 64 string copies. To mitigate
239  // memory fragmentation and performance loss, throttle the use of this
240  // attribute a little.
242 
243  virtual std::string GetValue();
244 };
245 
247  virtual std::string GetValue();
248 };
249 
252 
253  virtual bool PrepareValueFenced();
254  virtual std::string GetValue();
255 };
256 
258  virtual std::string GetValue();
259 };
260 
262  virtual std::string GetValue();
263 };
264 
266  virtual std::string GetValue();
267 };
268 
270  virtual std::string GetValue();
271 };
272 
274  virtual std::string GetValue();
275 };
276 
278  virtual std::string GetValue();
279 };
280 
282  std::string pubkeys_;
283 
284  virtual bool PrepareValueFenced();
285  virtual std::string GetValue();
286 };
287 
289  virtual bool PrepareValueFenced();
290  virtual std::string GetValue();
291 };
292 
295 
296  virtual bool PrepareValueFenced();
297  virtual std::string GetValue();
298 };
299 
301  static uint64_t kMaxMetainfoLength;
302 
304  std::string error_reason_;
305 
306  virtual bool PrepareValueFenced();
307  virtual std::string GetValue();
308 };
309 
311  uint64_t revision_;
312 
313  virtual bool PrepareValueFenced();
314  virtual std::string GetValue();
315 };
316 
319 
320  virtual bool PrepareValueFenced();
321  virtual std::string GetValue();
322 };
323 
324 class RxMagicXattr : public BaseMagicXattr {
325  virtual std::string GetValue();
326 };
327 
329  virtual std::string GetValue();
330 };
331 
333  std::string tag_;
334 
335  virtual bool PrepareValueFenced();
336  virtual std::string GetValue();
337 };
338 
340  virtual std::string GetValue();
341 };
342 
344  virtual std::string GetValue();
345 };
346 
348  virtual std::string GetValue();
349 };
350 
352  virtual std::string GetValue();
353 };
354 
356  virtual std::string GetValue();
357 };
358 
360  virtual std::string GetValue();
361 };
362 
363 #endif // CVMFS_MAGIC_XATTR_H_
virtual std::string GetValue()
Definition: magic_xattr.cc:342
virtual std::string GetValue()=0
MagicXattrManager(MountPoint *mountpoint, bool hide_magic_xattrs)
Definition: magic_xattr.cc:19
MagicXattrFlavor
Definition: magic_xattr.h:20
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:157
void Release()
Definition: magic_xattr.h:69
bool IsNull() const
Definition: magic_xattr.h:106
virtual std::string GetValue()
Definition: magic_xattr.cc:491
std::string subcatalog_path_
Definition: magic_xattr.h:167
void Register(const std::string &name, BaseMagicXattr *magic_xattr)
Definition: magic_xattr.cc:120
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:482
pthread_mutex_t access_mutex_
Definition: magic_xattr.h:81
virtual std::string GetValue()
Definition: magic_xattr.cc:150
BaseMagicXattr * ptr_
Definition: magic_xattr.h:114
virtual std::string GetValue()
Definition: magic_xattr.cc:497
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:118
virtual std::string GetValue()
Definition: magic_xattr.cc:241
catalog::Counters counters_
Definition: magic_xattr.h:168
BaseMagicXattr * GetLocked(const std::string &name, PathString path, catalog::DirectoryEntry *d)
Definition: magic_xattr.cc:104
virtual std::string GetValue()
Definition: magic_xattr.cc:516
std::string error_reason_
Definition: magic_xattr.h:304
virtual std::string GetValue()
Definition: magic_xattr.cc:426
shash::Any root_hash_
Definition: magic_xattr.h:318
virtual std::string GetValue()
Definition: magic_xattr.cc:254
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:507
assert((mem||(size==0))&&"Out Of Memory")
virtual std::string GetValue()
Definition: magic_xattr.cc:537
catalog::DirectoryEntry * dirent_
Definition: magic_xattr.h:79
BaseMagicXattr * operator->() const
Definition: magic_xattr.h:105
virtual std::string GetValue()
Definition: magic_xattr.cc:213
virtual std::string GetValue()
Definition: magic_xattr.cc:284
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:217
virtual std::string GetValue()
Definition: magic_xattr.cc:306
MountPoint * mount_point_
Definition: magic_xattr.h:77
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:144
std::string chunk_list_
Definition: magic_xattr.h:175
virtual std::string GetValue()
Definition: magic_xattr.cc:136
static uint64_t kMaxMetainfoLength
Definition: magic_xattr.h:301
MountPoint * mount_point_
Definition: magic_xattr.h:156
virtual std::string GetValue()
Definition: magic_xattr.cc:379
BaseMagicXattr * Move()
Definition: magic_xattr.h:107
virtual std::string GetValue()
Definition: magic_xattr.cc:331
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:354
std::string GetListString(catalog::DirectoryEntry *dirent)
Definition: magic_xattr.cc:69
virtual std::string GetValue()
Definition: magic_xattr.cc:237
MagicXattrRAIIWrapper(BaseMagicXattr *ptr, PathString path, catalog::DirectoryEntry *d)
Definition: magic_xattr.h:92
virtual std::string GetValue()
Definition: magic_xattr.cc:478
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:473
virtual std::string GetValue()
Definition: magic_xattr.cc:512
virtual std::string GetValue()
Definition: magic_xattr.cc:260
virtual std::string GetValue()
Definition: magic_xattr.cc:375
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:421
virtual std::string GetValue()
Definition: magic_xattr.cc:533
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:302
virtual std::string GetValue()
Definition: magic_xattr.cc:268
bool hide_magic_xattrs()
Definition: magic_xattr.h:152
virtual std::string GetValue()
Definition: magic_xattr.cc:541
virtual std::string GetValue()
Definition: magic_xattr.cc:487
virtual std::string GetValue()
Definition: magic_xattr.cc:363
virtual std::string GetValue()
Definition: magic_xattr.cc:367
virtual std::string GetValue()
Definition: magic_xattr.cc:392
virtual std::string GetValue()
Definition: magic_xattr.cc:371
std::string tag_
Definition: magic_xattr.h:333
MagicXattrRAIIWrapper(BaseMagicXattr *ptr)
Wraps around a BaseMagicXattr* tha is already locked (or NULL)
Definition: magic_xattr.h:101
shash::Any metainfo_hash_
Definition: magic_xattr.h:303
BackoffThrottle throttle_
Definition: magic_xattr.h:241
uint64_t n_chunks_
Definition: magic_xattr.h:182
virtual std::string GetValue()
Definition: magic_xattr.cc:186
virtual std::string GetValue()
Definition: magic_xattr.cc:446
virtual std::string GetValue()
Definition: magic_xattr.cc:359
virtual std::string GetValue()
Definition: magic_xattr.cc:272
PathString path_
Definition: magic_xattr.h:78
virtual std::string GetValue()
Definition: magic_xattr.cc:528
virtual std::string GetValue()
Definition: magic_xattr.cc:221
std::map< std::string, BaseMagicXattr * > xattr_list_
Definition: magic_xattr.h:155
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:264
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:432
virtual bool PrepareValueFenced()
Definition: magic_xattr.h:52
virtual ~BaseMagicXattr()
Definition: magic_xattr.h:74
virtual std::string GetValue()
Definition: magic_xattr.cc:229
catalog::Counters counters_
Definition: magic_xattr.h:294
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:61
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:404
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.cc:140
std::string pubkeys_
Definition: magic_xattr.h:282
virtual std::string GetValue()
Definition: magic_xattr.cc:522
void Lock(PathString path, catalog::DirectoryEntry *dirent)
Definition: magic_xattr.h:63
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:190
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:122
virtual std::string GetValue()
Definition: magic_xattr.cc:409
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:225
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:233
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:132