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
9#include <dmlite/cpp/inode.h>
12
13namespace 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) ;
25
26 std::string getImplId(void) const throw();
27
29
31
32 void changeDir (const std::string&) ;
33 std::string getWorkingDir (void) ;
34
36 const std::string& path,
37 bool followSym) ;
38
39 ExtendedStat extendedStat(const std::string& path,
40 bool followSym = true) ;
41 ExtendedStat extendedStatByRFN(const std::string& rfn) ;
42
43
44
45 bool access(const std::string& path, int mode) ;
46 bool accessReplica(const std::string& replica, int mode) ;
47
48 void addReplica (const Replica& replica) ;
49 void deleteReplica(const Replica& replica) ;
50
51 std::vector<Replica> getReplicas(const std::string& path) ;
52 Location get(const std::string& path) ;
53
54 Location put(const std::string& path) ;
55 void putDone(const std::string& host, const std::string& rfn,
56 const std::map<std::string, std::string>& params) ;
57
58 void symlink(const std::string& oldpath,
59 const std::string& newpath) ;
60 std::string readLink(const std::string& path) ;
61
62 void unlink(const std::string& path) ;
63
64 void create(const std::string& path, mode_t mode) ;
65
66 void makeDir (const std::string& path, mode_t mode) ;
67 void removeDir(const std::string& path) ;
68
69 void rename(const std::string& oldPath,
70 const std::string& newPath) ;
71
72 mode_t umask(mode_t mask);
73
74 void setMode (const std::string& path, mode_t mode) ;
75 void setOwner (const std::string& path, uid_t newUid, gid_t newGid,
76 bool followSymLink = true) ;
77
78 void setSize (const std::string& path, size_t newSize) ;
79
80 void setAcl(const std::string& path, const Acl& acls) ;
81
82 void utime(const std::string& path, const struct utimbuf* buf) ;
83
84 std::string getComment(const std::string& path) ;
85 void setComment(const std::string& path,
86 const std::string& comment) ;
87
88 void setGuid(const std::string& path,
89 const std::string &guid) ;
90
91 void updateExtendedAttributes(const std::string& path,
92 const Extensible& attr) ;
93
94 Directory* openDir (const std::string& path) ;
95 void closeDir(Directory* dir) ;
96 struct dirent* readDir (Directory* dir) ;
98
99 Replica getReplicaByRFN(const std::string& rfn) ;
100 void updateReplica(const Replica& replica) ;
101
102 protected:
103 /// Get the parent of a directory.
104 /// @param path The path to split.
105 /// @param parentPath Where to put the parent path.
106 /// @param name Where to put the file name (stripping last /).
107 /// @return The parent metadata.
108 ExtendedStat getParent(const std::string& path, std::string* parentPath,
109 std::string* name) ;
110
111 /// Update access time (if updateATime is true)
112 void updateAccessTime(const ExtendedStat& meta) ;
113
114 /// Traverse backwards to check permissions.
115 /// @param meta The file at the end
116 /// @note Throws an exception if it is not possible.
117 void traverseBackwards(const ExtendedStat& meta) ;
118
119 /// addFileSizeToParents
120 /// Add (or subtract) the size of the given file from
121 /// all its parent directories
122 /// @param fname The logical file name (SFN) of the file in question
123 /// @param subtract If true then subtract instead of adding
124 void addFileSizeToParents(const std::string &fname, bool subtract) ;
125
126 /// addFileSizeToParents
127 /// Add (or subtract) the size of the given file from
128 /// all its parent directories
129 /// @param st The stat information about the file in question
130 /// @param subtract If true then subtract instead of adding
131 void addFileSizeToParents(const ExtendedStat &statinfo, bool subtract) ;
132
133 private:
135
137
138 std::string cwdPath_;
139 ino_t cwd_;
140
141 mode_t umask_;
144 };
145
146 /// Plug-ins must implement a concrete factory to be instantiated.
148 public:
151
152 void configure(const std::string&, const std::string&) ;
153
155
156 private:
159 };
160
161};
162
163#endif // BUILTIN_CATALOG_H
Definition: security.h:52
Plug-ins must implement a concrete factory to be instantiated.
Definition: Catalog.h:147
unsigned symLinkLimit_
Definition: Catalog.h:158
void configure(const std::string &, const std::string &)
bool updateATime_
Definition: Catalog.h:157
Catalog * createCatalog(PluginManager *)
Instantiate a implementation of Catalog.
Definition: Catalog.h:21
mode_t umask_
Definition: Catalog.h:141
Replica getReplicaByRFN(const std::string &rfn)
BuiltInCatalog(bool updateATime, unsigned symLinkLimit)
bool accessReplica(const std::string &replica, int mode)
void create(const std::string &path, mode_t mode)
std::string getImplId(void) const
String ID of the implementation.
void rename(const std::string &oldPath, const std::string &newPath)
ExtendedStat extendedStat(const std::string &path, bool followSym=true)
void utime(const std::string &path, const struct utimbuf *buf)
Location put(const std::string &path)
mode_t umask(mode_t mask)
void unlink(const std::string &path)
void setAcl(const std::string &path, const Acl &acls)
void updateAccessTime(const ExtendedStat &meta)
Update access time (if updateATime is true)
std::string getWorkingDir(void)
unsigned symLinkLimit_
Definition: Catalog.h:143
void updateExtendedAttributes(const std::string &path, const Extensible &attr)
void updateReplica(const Replica &replica)
bool updateATime_
Definition: Catalog.h:142
std::string cwdPath_
Definition: Catalog.h:138
void setComment(const std::string &path, const std::string &comment)
void addReplica(const Replica &replica)
void symlink(const std::string &oldpath, const std::string &newpath)
void setSecurityContext(const SecurityContext *)
Set the security context.
ExtendedStat getParent(const std::string &path, std::string *parentPath, std::string *name)
void setSize(const std::string &path, size_t newSize)
Directory * openDir(const std::string &path)
bool access(const std::string &path, int mode)
void putDone(const std::string &host, const std::string &rfn, const std::map< std::string, std::string > &params)
StackInstance * si_
Definition: Catalog.h:134
void traverseBackwards(const ExtendedStat &meta)
void setStackInstance(StackInstance *si)
void changeDir(const std::string &)
void setMode(const std::string &path, mode_t mode)
void setOwner(const std::string &path, uid_t newUid, gid_t newGid, bool followSymLink=true)
void makeDir(const std::string &path, mode_t mode)
const SecurityContext * secCtx_
Definition: Catalog.h:136
void closeDir(Directory *dir)
ExtendedStat * readDirx(Directory *dir)
void removeDir(const std::string &path)
std::vector< Replica > getReplicas(const std::string &path)
DmStatus extendedStat(ExtendedStat &xstat, const std::string &path, bool followSym)
Location get(const std::string &path)
std::string getComment(const std::string &path)
std::string readLink(const std::string &path)
ino_t cwd_
Definition: Catalog.h:139
ExtendedStat extendedStatByRFN(const std::string &rfn)
void setGuid(const std::string &path, const std::string &guid)
void addFileSizeToParents(const std::string &fname, bool subtract)
struct dirent * readDir(Directory *dir)
void addFileSizeToParents(const ExtendedStat &statinfo, bool subtract)
void deleteReplica(const Replica &replica)
Plug-ins must implement a concrete factory to be instantiated.
Definition: catalog.h:237
Interface for Catalog (Namespaces).
Definition: catalog.h:30
Definition: status.h:17
File/directory metadata.
Definition: inode.h:29
Helpful typedef for KeyValue containers.
Definition: extensible.h:20
Represent the complete location of a file.
Definition: pooldriver.h:50
CatalogInterface can only be instantiated through this class.
Definition: dmlite.h:42
File replica metadata.
Definition: inode.h:73
Security context. To be created by the Authn.
Definition: authn.h:73
Definition: dmlite.h:161
Low-level access API.
Catalog API.
Namespace for the dmlite C++ API.
Definition: authn.h:16
Pool handling API.
Pool API.
Definition: Catalog.h:15
virtual ~BuiltInDir()
Definition: Catalog.h:16
IDirectory * idir
Definition: Catalog.h:17
ExtendedStat dir
Definition: Catalog.h:18
Typedef for directories.
Definition: catalog.h:27
Typedef for directories.
Definition: inode.h:26