CernVM-FS  2.11.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:
145 
149  BaseMagicXattr* GetLocked(const std::string &name, PathString path,
151  std::string GetListString(catalog::DirectoryEntry *dirent);
152  void Register(const std::string &name, BaseMagicXattr *magic_xattr);
153 
155 
156  protected:
157  std::map<std::string, BaseMagicXattr *> xattr_list_;
160 };
161 
163  virtual bool PrepareValueFenced();
164  virtual std::string GetValue();
166 };
167 
169  std::string subcatalog_path_;
172 
173  virtual bool PrepareValueFenced();
174  virtual std::string GetValue();
175 };
176 
178  std::string chunk_list_;
179 
180  virtual bool PrepareValueFenced();
181  virtual std::string GetValue();
182 };
183 
185  uint64_t n_chunks_;
186 
187  virtual bool PrepareValueFenced();
188  virtual std::string GetValue();
189 };
190 
192  virtual bool PrepareValueFenced();
193  virtual std::string GetValue();
194 };
195 
197  virtual bool PrepareValueFenced();
198  virtual std::string GetValue();
199 };
200 
202  virtual bool PrepareValueFenced();
203  virtual std::string GetValue();
204 };
205 
207  virtual std::string GetValue();
208 };
209 
211  virtual std::string GetValue();
212 };
213 
215  virtual std::string GetValue();
216 };
217 
219  virtual bool PrepareValueFenced();
220  virtual std::string GetValue();
221 };
222 
224  virtual std::string GetValue();
225 };
226 
228  virtual std::string GetValue();
229 };
230 
232  virtual bool PrepareValueFenced();
233  virtual std::string GetValue();
234 };
235 
237  public:
238  LogBufferXattr();
239 
240  private:
241  // Generating the log buffer report involves 64 string copies. To mitigate
242  // memory fragmentation and performance loss, throttle the use of this
243  // attribute a little.
245 
246  virtual std::string GetValue();
247 };
248 
250  virtual std::string GetValue();
251 };
252 
255 
256  virtual bool PrepareValueFenced();
257  virtual std::string GetValue();
258 };
259 
261  virtual std::string GetValue();
262 };
263 
265  virtual std::string GetValue();
266 };
267 
269  virtual std::string GetValue();
270 };
271 
273  virtual std::string GetValue();
274 };
275 
277  virtual std::string GetValue();
278 };
279 
281  virtual std::string GetValue();
282 };
283 
285  std::string pubkeys_;
286 
287  virtual bool PrepareValueFenced();
288  virtual std::string GetValue();
289 };
290 
292  virtual bool PrepareValueFenced();
293  virtual std::string GetValue();
294 };
295 
298 
299  virtual bool PrepareValueFenced();
300  virtual std::string GetValue();
301 };
302 
304  static uint64_t kMaxMetainfoLength;
305 
307  std::string error_reason_;
308 
309  virtual bool PrepareValueFenced();
310  virtual std::string GetValue();
311 };
312 
314  uint64_t revision_;
315 
316  virtual bool PrepareValueFenced();
317  virtual std::string GetValue();
318 };
319 
322 
323  virtual bool PrepareValueFenced();
324  virtual std::string GetValue();
325 };
326 
327 class RxMagicXattr : public BaseMagicXattr {
328  virtual std::string GetValue();
329 };
330 
332  virtual std::string GetValue();
333 };
334 
336  std::string tag_;
337 
338  virtual bool PrepareValueFenced();
339  virtual std::string GetValue();
340 };
341 
343  virtual std::string GetValue();
344 };
345 
347  virtual std::string GetValue();
348 };
349 
351  virtual std::string GetValue();
352 };
353 
355  virtual std::string GetValue();
356 };
357 
359  virtual std::string GetValue();
360 };
361 
363  virtual std::string GetValue();
364 };
365 
367  virtual bool PrepareValueFenced();
368  virtual std::string GetValue();
369 };
370 
371 #endif // CVMFS_MAGIC_XATTR_H_
virtual std::string GetValue()
Definition: magic_xattr.cc:349
virtual std::string GetValue()=0
MagicXattrFlavor
Definition: magic_xattr.h:20
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:164
void Release()
Definition: magic_xattr.h:69
bool IsNull() const
Definition: magic_xattr.h:106
virtual std::string GetValue()
Definition: magic_xattr.cc:498
std::string subcatalog_path_
Definition: magic_xattr.h:169
void Register(const std::string &name, BaseMagicXattr *magic_xattr)
Definition: magic_xattr.cc:125
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:489
pthread_mutex_t access_mutex_
Definition: magic_xattr.h:81
virtual std::string GetValue()
Definition: magic_xattr.cc:156
BaseMagicXattr * ptr_
Definition: magic_xattr.h:114
virtual std::string GetValue()
Definition: magic_xattr.cc:504
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:118
virtual std::string GetValue()
Definition: magic_xattr.cc:248
catalog::Counters counters_
Definition: magic_xattr.h:171
BaseMagicXattr * GetLocked(const std::string &name, PathString path, catalog::DirectoryEntry *d)
Definition: magic_xattr.cc:109
virtual std::string GetValue()
Definition: magic_xattr.cc:523
std::string error_reason_
Definition: magic_xattr.h:307
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:567
virtual std::string GetValue()
Definition: magic_xattr.cc:433
shash::Any root_hash_
Definition: magic_xattr.h:321
virtual std::string GetValue()
Definition: magic_xattr.cc:261
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:514
assert((mem||(size==0))&&"Out Of Memory")
virtual std::string GetValue()
Definition: magic_xattr.cc:544
virtual std::string GetValue()
Definition: magic_xattr.cc:552
catalog::DirectoryEntry * dirent_
Definition: magic_xattr.h:79
BaseMagicXattr * operator->() const
Definition: magic_xattr.h:105
virtual std::string GetValue()
Definition: magic_xattr.cc:220
virtual std::string GetValue()
Definition: magic_xattr.cc:291
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:224
virtual std::string GetValue()
Definition: magic_xattr.cc:313
MountPoint * mount_point_
Definition: magic_xattr.h:77
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:149
std::string chunk_list_
Definition: magic_xattr.h:178
virtual std::string GetValue()
Definition: magic_xattr.cc:141
static uint64_t kMaxMetainfoLength
Definition: magic_xattr.h:304
MagicXattrManager(MountPoint *mountpoint, EVisibility visibility)
Definition: magic_xattr.cc:19
MountPoint * mount_point_
Definition: magic_xattr.h:158
virtual std::string GetValue()
Definition: magic_xattr.cc:386
BaseMagicXattr * Move()
Definition: magic_xattr.h:107
virtual std::string GetValue()
Definition: magic_xattr.cc:338
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:361
std::string GetListString(catalog::DirectoryEntry *dirent)
Definition: magic_xattr.cc:70
virtual std::string GetValue()
Definition: magic_xattr.cc:244
MagicXattrRAIIWrapper(BaseMagicXattr *ptr, PathString path, catalog::DirectoryEntry *d)
Definition: magic_xattr.h:92
virtual std::string GetValue()
Definition: magic_xattr.cc:485
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:480
virtual std::string GetValue()
Definition: magic_xattr.cc:519
virtual std::string GetValue()
Definition: magic_xattr.cc:267
virtual std::string GetValue()
Definition: magic_xattr.cc:382
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:428
EVisibility visibility()
Definition: magic_xattr.h:154
virtual std::string GetValue()
Definition: magic_xattr.cc:540
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:309
virtual std::string GetValue()
Definition: magic_xattr.cc:275
virtual std::string GetValue()
Definition: magic_xattr.cc:548
virtual std::string GetValue()
Definition: magic_xattr.cc:494
virtual std::string GetValue()
Definition: magic_xattr.cc:370
virtual std::string GetValue()
Definition: magic_xattr.cc:374
virtual std::string GetValue()
Definition: magic_xattr.cc:399
virtual std::string GetValue()
Definition: magic_xattr.cc:378
std::string tag_
Definition: magic_xattr.h:336
MagicXattrRAIIWrapper(BaseMagicXattr *ptr)
Wraps around a BaseMagicXattr* tha is already locked (or NULL)
Definition: magic_xattr.h:101
EVisibility visibility_
Definition: magic_xattr.h:159
shash::Any metainfo_hash_
Definition: magic_xattr.h:306
BackoffThrottle throttle_
Definition: magic_xattr.h:244
uint64_t n_chunks_
Definition: magic_xattr.h:185
virtual std::string GetValue()
Definition: magic_xattr.cc:193
virtual std::string GetValue()
Definition: magic_xattr.cc:453
virtual std::string GetValue()
Definition: magic_xattr.cc:366
virtual std::string GetValue()
Definition: magic_xattr.cc:279
PathString path_
Definition: magic_xattr.h:78
virtual std::string GetValue()
Definition: magic_xattr.cc:535
virtual std::string GetValue()
Definition: magic_xattr.cc:228
std::map< std::string, BaseMagicXattr * > xattr_list_
Definition: magic_xattr.h:157
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:271
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:439
virtual bool PrepareValueFenced()
Definition: magic_xattr.h:52
virtual ~BaseMagicXattr()
Definition: magic_xattr.h:74
virtual std::string GetValue()
Definition: magic_xattr.cc:236
catalog::Counters counters_
Definition: magic_xattr.h:297
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:61
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:411
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.cc:145
std::string pubkeys_
Definition: magic_xattr.h:285
virtual std::string GetValue()
Definition: magic_xattr.cc:529
void Lock(PathString path, catalog::DirectoryEntry *dirent)
Definition: magic_xattr.h:63
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:197
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:122
virtual std::string GetValue()
Definition: magic_xattr.cc:416
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:232
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:240
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:137