dmlite  0.6
poolmanager.h
Go to the documentation of this file.
1 /// @file include/dmlite/cpp/poolmanager.h
2 /// @brief Pool API.
3 /// @author Alejandro Álvarez Ayllón <aalvarez@cern.ch>
4 #ifndef DMLITE_CPP_POOLMANAGER_H
5 #define DMLITE_CPP_POOLMANAGER_H
6 
7 #include "dmlite/common/config.h"
8 #include "base.h"
9 #include "exceptions.h"
10 #include "pooldriver.h"
11 #include "utils/extensible.h"
12 
13 #include <string>
14 #include <vector>
15 
16 namespace dmlite {
17 
18  // Forward declarations.
19  class StackInstance;
20 
21  /// Internal interface for handling pool metadata.
22  struct Pool: public Extensible {
23  std::string name;
24  std::string type;
25 
26  bool operator == (const Pool&) const;
27  bool operator != (const Pool&) const;
28  bool operator < (const Pool&) const;
29  bool operator > (const Pool&) const;
30  };
31 
32  /// Interface for pool types.
33  class PoolManager: public virtual BaseInterface {
34  public:
36 
37  /// Destructor.
38  virtual ~PoolManager();
39 
40  /// Get the list of pools.
41  /// @param availability Filter by availability.
42  virtual std::vector<Pool> getPools(PoolAvailability availability = kAny) throw (DmException);
43 
44  /// Get a specific pool.
45  virtual Pool getPool(const std::string& poolname) throw (DmException);
46 
47  /// Create a new pool.
48  virtual void newPool(const Pool& pool) throw (DmException);
49 
50  /// Update pool metadata.
51  virtual void updatePool(const Pool& pool) throw (DmException);
52 
53  /// Remove a pool.
54  virtual void deletePool(const Pool& pool) throw (DmException);
55 
56  /// Get a location for a logical name.
57  /// @param path The path to get.
58  virtual Location whereToRead(const std::string& path) throw (DmException);
59 
60  /// Get a location for an inode
61  /// @param inode The file inode.
62  virtual Location whereToRead(ino_t inode) throw (DmException);
63 
64  /// Start the PUT of a file.
65  /// @param path The path of the file to create.
66  /// @return The physical location where to write.
67  virtual Location whereToWrite(const std::string& path) throw (DmException);
68 
69  /// Cancel a write.
70  /// @param path The logical file name.
71  /// @param loc As returned by whereToWrite
72  virtual void cancelWrite(const Location& loc) throw (DmException);
73 
74  /// Get the estimation of the free/used space for writing into a directory
75  /// @param path The path of the directory to query
76  /// @param totalfree The total number of free bytes (may not be contiguous)
77  /// @param used The total number of used bytes
78  virtual void getDirSpaces(const std::string& path, int64_t &totalfree, int64_t &used) throw (DmException);
79  };
80 
81  /// Plug-ins must implement a concrete factory to be instantiated.
82  class PoolManagerFactory: public virtual BaseFactory {
83  public:
84  /// Virtual destructor
85  virtual ~PoolManagerFactory();
86 
87  protected:
88  // Stack instance is allowed to instantiate PoolManager
89  friend class StackInstance;
90 
91  /// Children of PoolManagerFactory are allowed to instantiate too (decorator)
93  PluginManager* pm) throw (DmException);
94 
95  /// Instantiate a implementation of Pool
97  };
98 
99 };
100 
101 #endif // DMLITE_CPP_POOLMANAGER_H
virtual Location whereToRead(const std::string &path)
virtual void newPool(const Pool &pool)
Create a new pool.
std::string type
Definition: poolmanager.h:24
Base class for interfaces.
Definition: base.h:18
bool operator<(const Pool &) const
Plug-ins must implement a concrete factory to be instantiated.
Definition: poolmanager.h:82
Definition: dmlite.h:161
PoolAvailability
Definition: poolmanager.h:35
Definition: poolmanager.h:35
Header generated by CMake with the build configuration used.
Represent the complete location of a file.
Definition: pooldriver.h:42
Base exception class.
Definition: exceptions.h:17
static PoolManager * createPoolManager(PoolManagerFactory *factory, PluginManager *pm)
Children of PoolManagerFactory are allowed to instantiate too (decorator)
CatalogInterface can only be instantiated through this class.
Definition: dmlite.h:42
Interface for pool types.
Definition: poolmanager.h:33
virtual std::vector< Pool > getPools(PoolAvailability availability=kAny)
bool operator==(const Pool &) const
virtual ~PoolManagerFactory()
Virtual destructor.
virtual void getDirSpaces(const std::string &path, int64_t &totalfree, int64_t &used)
Exceptions used by the API.
Helpful typedef for KeyValue containers.
Definition: extensible.h:20
bool operator>(const Pool &) const
Base class for factories.
Definition: base.h:48
bool operator!=(const Pool &) const
virtual ~PoolManager()
Destructor.
virtual void updatePool(const Pool &pool)
Update pool metadata.
std::string name
Definition: poolmanager.h:23
Extensible types (hold metadata).
Internal interface for handling pool metadata.
Definition: poolmanager.h:22
Definition: poolmanager.h:35
Base interfaces.
virtual void deletePool(const Pool &pool)
Remove a pool.
virtual Location whereToWrite(const std::string &path)
Definition: poolmanager.h:35
Definition: poolmanager.h:35
virtual void cancelWrite(const Location &loc)
Definition: poolmanager.h:35
Namespace for the dmlite C++ API.
Definition: authn.h:15
virtual Pool getPool(const std::string &poolname)
Get a specific pool.
Pool handling API.