dmlite  0.6
Catalog.h
Go to the documentation of this file.
1 /// @file core/builtin/Catalog.h
2 /// @brief Implementation of a Catalog using other plugins, as INode.
3 /// @details Intended to ease the development of database backends.
4 /// @author Alejandro Álvarez Ayllon <aalvarez@cern.ch>
5 #ifndef BUILTIN_CATALOG_H
6 #define BUILTIN_CATALOG_H
7 
8 #include <dmlite/cpp/catalog.h>
9 #include <dmlite/cpp/inode.h>
10 #include <dmlite/cpp/poolmanager.h>
11 #include <dmlite/cpp/pooldriver.h>
12 
13 namespace dmlite {
14 
15  struct BuiltInDir: public Directory {
16  virtual ~BuiltInDir() {};
19  };
20 
21  class BuiltInCatalog: public Catalog {
22  public:
23  BuiltInCatalog(bool updateATime, unsigned symLinkLimit) throw (DmException);
25 
26  std::string getImplId(void) const throw();
27 
28  void setStackInstance(StackInstance* si) throw (DmException);
29 
30  void setSecurityContext(const SecurityContext*) throw (DmException);
31 
32  void changeDir (const std::string&) throw (DmException);
33  std::string getWorkingDir (void) throw (DmException);
34 
35  ExtendedStat extendedStat(const std::string& path,
36  bool followSym = true) throw (DmException);
37  ExtendedStat extendedStatByRFN(const std::string& rfn) throw (DmException);
38 
39  bool access(const std::string& path, int mode) throw (DmException);
40  bool accessReplica(const std::string& replica, int mode) throw (DmException);
41 
42  void addReplica (const Replica& replica) throw (DmException);
43  void deleteReplica(const Replica& replica) throw (DmException);
44 
45  std::vector<Replica> getReplicas(const std::string& path) throw (DmException);
46  Location get(const std::string& path) throw (DmException);
47 
48  Location put(const std::string& path) throw (DmException);
49  void putDone(const std::string& host, const std::string& rfn,
50  const std::map<std::string, std::string>& params) throw (DmException);
51 
52  void symlink(const std::string& oldpath,
53  const std::string& newpath) throw (DmException);
54  std::string readLink(const std::string& path) throw (DmException);
55 
56  void unlink(const std::string& path) throw (DmException);
57 
58  void create(const std::string& path, mode_t mode) throw (DmException);
59 
60  void makeDir (const std::string& path, mode_t mode) throw (DmException);
61  void removeDir(const std::string& path) throw (DmException);
62 
63  void rename(const std::string& oldPath,
64  const std::string& newPath) throw (DmException);
65 
66  mode_t umask(mode_t mask) throw ();
67 
68  void setMode (const std::string& path, mode_t mode) throw (DmException);
69  void setOwner (const std::string& path, uid_t newUid, gid_t newGid,
70  bool followSymLink = true) throw (DmException);
71 
72  void setSize (const std::string& path, size_t newSize) throw (DmException);
73  void setChecksum(const std::string& path, const std::string& csumtype,
74  const std::string& csumvalue) throw (DmException);
75 
76  void setAcl(const std::string& path, const Acl& acls) throw (DmException);
77 
78  void utime(const std::string& path, const struct utimbuf* buf) throw (DmException);
79 
80  std::string getComment(const std::string& path) throw (DmException);
81  void setComment(const std::string& path,
82  const std::string& comment) throw (DmException);
83 
84  void setGuid(const std::string& path,
85  const std::string &guid) throw (DmException);
86 
87  void updateExtendedAttributes(const std::string& path,
88  const Extensible& attr) throw (DmException);
89 
90  Directory* openDir (const std::string& path) throw (DmException);
91  void closeDir(Directory* dir) throw (DmException);
92  struct dirent* readDir (Directory* dir) throw (DmException);
94 
95  Replica getReplicaByRFN(const std::string& rfn) throw (DmException);
96  void updateReplica(const Replica& replica) throw (DmException);
97 
98  protected:
99  /// Get the parent of a directory.
100  /// @param path The path to split.
101  /// @param parentPath Where to put the parent path.
102  /// @param name Where to put the file name (stripping last /).
103  /// @return The parent metadata.
104  ExtendedStat getParent(const std::string& path, std::string* parentPath,
105  std::string* name) throw (DmException);
106 
107  /// Update access time (if updateATime is true)
108  void updateAccessTime(const ExtendedStat& meta) throw (DmException);
109 
110  /// Traverse backwards to check permissions.
111  /// @param meta The file at the end
112  /// @note Throws an exception if it is not possible.
113  void traverseBackwards(const ExtendedStat& meta) throw (DmException);
114 
115  private:
117 
119 
120  std::string cwdPath_;
121  ino_t cwd_;
122 
123  mode_t umask_;
125  unsigned symLinkLimit_;
126  };
127 
128  /// Plug-ins must implement a concrete factory to be instantiated.
130  public:
133 
134  void configure(const std::string&, const std::string&) throw (DmException);
135 
137 
138  private:
140  unsigned symLinkLimit_;
141  };
142 
143 };
144 
145 #endif // BUILTIN_CATALOG_H
BuiltInCatalog(bool updateATime, unsigned symLinkLimit)
void updateReplica(const Replica &replica)
std::string readLink(const std::string &path)
File/directory metadata.
Definition: inode.h:27
struct dirent * readDir(Directory *dir)
mode_t umask(mode_t mask)
void putDone(const std::string &host, const std::string &rfn, const std::map< std::string, std::string > &params)
unsigned symLinkLimit_
Definition: Catalog.h:125
Definition: security.h:51
void symlink(const std::string &oldpath, const std::string &newpath)
void closeDir(Directory *dir)
Plug-ins must implement a concrete factory to be instantiated.
Definition: catalog.h:216
Directory * openDir(const std::string &path)
bool accessReplica(const std::string &replica, int mode)
void updateAccessTime(const ExtendedStat &meta)
Update access time (if updateATime is true)
void rename(const std::string &oldPath, const std::string &newPath)
virtual ~BuiltInDir()
Definition: Catalog.h:16
Definition: dmlite.h:161
void setOwner(const std::string &path, uid_t newUid, gid_t newGid, bool followSymLink=true)
std::string getComment(const std::string &path)
Security context. To be created by the Authn.
Definition: authn.h:64
void utime(const std::string &path, const struct utimbuf *buf)
void setComment(const std::string &path, const std::string &comment)
Represent the complete location of a file.
Definition: pooldriver.h:42
Base exception class.
Definition: exceptions.h:17
File replica metadata.
Definition: inode.h:59
Plug-ins must implement a concrete factory to be instantiated.
Definition: Catalog.h:129
Definition: Catalog.h:21
void setChecksum(const std::string &path, const std::string &csumtype, const std::string &csumvalue)
CatalogInterface can only be instantiated through this class.
Definition: dmlite.h:42
Interface for Catalog (Namespaces).
Definition: catalog.h:29
ino_t cwd_
Definition: Catalog.h:121
bool updateATime_
Definition: Catalog.h:139
void traverseBackwards(const ExtendedStat &meta)
IDirectory * idir
Definition: Catalog.h:16
Pool API.
std::string getWorkingDir(void)
ExtendedStat extendedStat(const std::string &path, bool followSym=true)
bool access(const std::string &path, int mode)
Replica getReplicaByRFN(const std::string &rfn)
unsigned symLinkLimit_
Definition: Catalog.h:140
ExtendedStat extendedStatByRFN(const std::string &rfn)
Catalog API.
Helpful typedef for KeyValue containers.
Definition: extensible.h:20
void changeDir(const std::string &)
void removeDir(const std::string &path)
bool updateATime_
Definition: Catalog.h:124
Definition: Catalog.h:15
std::string getImplId(void) const
String ID of the implementation.
void makeDir(const std::string &path, mode_t mode)
std::string cwdPath_
Definition: Catalog.h:120
Location put(const std::string &path)
mode_t umask_
Definition: Catalog.h:123
void setGuid(const std::string &path, const std::string &guid)
const SecurityContext * secCtx_
Definition: Catalog.h:118
void updateExtendedAttributes(const std::string &path, const Extensible &attr)
void configure(const std::string &, const std::string &)
void unlink(const std::string &path)
void create(const std::string &path, mode_t mode)
ExtendedStat * readDirx(Directory *dir)
void setSecurityContext(const SecurityContext *)
Set the security context.
std::vector< Replica > getReplicas(const std::string &path)
void setAcl(const std::string &path, const Acl &acls)
ExtendedStat getParent(const std::string &path, std::string *parentPath, std::string *name)
void setSize(const std::string &path, size_t newSize)
void setMode(const std::string &path, mode_t mode)
void addReplica(const Replica &replica)
void deleteReplica(const Replica &replica)
StackInstance * si_
Definition: Catalog.h:116
Catalog * createCatalog(PluginManager *)
Instantiate a implementation of Catalog.
Low-level access API.
void setStackInstance(StackInstance *si)
ExtendedStat dir
Definition: Catalog.h:18
Pool handling API.
Typedef for directories.
Definition: inode.h:24
Typedef for directories.
Definition: catalog.h:26