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 #include "dmlite/c/pool.h"
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  /** @brief Progress markers for file copies. FTS jargon calls these "FTS performance markers"
33  beware, we assume that this structure is identical to the one defined in the C API*/
34  typedef struct xferprogmarker {
35  int64_t xferred;
36  // Other fields I have no idea, the ones from FTS look weird to me
38 
39  /// Interface for pool types.
40  class PoolManager: public virtual BaseInterface {
41  public:
43 
44  /// Destructor.
45  virtual ~PoolManager();
46 
47  /// Get the list of pools.
48  /// @param availability Filter by availability.
49  virtual std::vector<Pool> getPools(PoolAvailability availability = kAny) ;
50 
51  /// Get a specific pool.
52  virtual Pool getPool(const std::string& poolname) ;
53 
54  /// Create a new pool.
55  virtual void newPool(const Pool& pool) ;
56 
57  /// Update pool metadata.
58  virtual void updatePool(const Pool& pool) ;
59 
60  /// Remove a pool.
61  virtual void deletePool(const Pool& pool) ;
62 
63  /// Get a location for a logical name.
64  /// @param path The path to get.
65  virtual Location whereToRead(const std::string& path) ;
66 
67  /// Get a location for an inode
68  /// @param inode The file inode.
69  virtual Location whereToRead(ino_t inode) ;
70 
71  /// Start the PUT of a file.
72  /// @param path The path of the file to create.
73  /// @return The physical location where to write.
74  virtual Location whereToWrite(const std::string& path) ;
75 
76  /// Cancel a write.
77  /// @param path The logical file name.
78  /// @param loc As returned by whereToWrite
79  virtual void cancelWrite(const Location& loc) ;
80 
81  /// Get the estimation of the free/used space for writing into a directory
82  /// @param path The path of the directory to query
83  /// @param totalfree The total number of free bytes (may not be contiguous)
84  /// @param used The total number of used bytes
85  virtual void getDirSpaces(const std::string& path, int64_t &totalfree, int64_t &used) ;
86 
87  /// Write a logical file towards a given URL
88  /// @param localsrcpath The path of the file
89  /// @param remotedesturl The URL to write to
90  /// @return 0 on success, error code otherwise. EAGAIN means performance marker
91  // Beware, the path to the delegated proxy (if any) is stored in the dmlite context
92  virtual DmStatus fileCopyPush(const std::string& localsrcpath, const std::string &remotedesturl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata) ;
93 
94  /// Fetch a file from a given URL
95  /// @param localdestpath The logical name of the file to create
96  /// @param remotesrcurl The URL to read the file from
97  /// @return 0 on success, error code otherwise. EAGAIN means performance marker
98  // Beware, the path to the delegated proxy (if any) is stored in the dmlite context
99  virtual DmStatus fileCopyPull(const std::string& localdestpath, const std::string &remotesrcurl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata) ;
100  };
101 
102  /// Plug-ins must implement a concrete factory to be instantiated.
103  class PoolManagerFactory: public virtual BaseFactory {
104  public:
105  /// Virtual destructor
106  virtual ~PoolManagerFactory();
107 
108  protected:
109  // Stack instance is allowed to instantiate PoolManager
110  friend class StackInstance;
111 
112  /// Children of PoolManagerFactory are allowed to instantiate too (decorator)
114  PluginManager* pm) ;
115 
116  /// Instantiate a implementation of Pool
118  };
119 
120 };
121 
122 #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
C wrapper for DMLite Pool API.
Definition: status.h:17
Plug-ins must implement a concrete factory to be instantiated.
Definition: poolmanager.h:103
Definition: dmlite.h:161
PoolAvailability
Definition: poolmanager.h:42
Definition: poolmanager.h:42
Header generated by CMake with the build configuration used.
Represent the complete location of a file.
Definition: pooldriver.h:49
virtual DmStatus fileCopyPull(const std::string &localdestpath, const std::string &remotesrcurl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata)
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:40
bool operator==(const Pool &) const
virtual std::vector< Pool > getPools(PoolAvailability availability=kAny)
struct dmlite::xferprogmarker xferprogmarker
Progress markers for file copies. FTS jargon calls these &quot;FTS performance markers&quot; beware...
virtual DmStatus fileCopyPush(const std::string &localsrcpath, const std::string &remotedesturl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata)
Progress markers for file copies. FTS jargon calls these &quot;FTS performance markers&quot;.
Definition: pool.h:73
Progress markers for file copies. FTS jargon calls these &quot;FTS performance markers&quot; beware...
Definition: poolmanager.h:34
virtual ~PoolManagerFactory()
Virtual destructor.
virtual void getDirSpaces(const std::string &path, int64_t &totalfree, int64_t &used)
Exceptions used by the API.
bool operator>(const Pool &) const
Helpful typedef for KeyValue containers.
Definition: extensible.h:20
bool operator!=(const Pool &) const
Base class for factories.
Definition: base.h:48
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:42
Base interfaces.
virtual void deletePool(const Pool &pool)
Remove a pool.
virtual Location whereToWrite(const std::string &path)
Definition: poolmanager.h:42
Definition: poolmanager.h:42
virtual void cancelWrite(const Location &loc)
Definition: poolmanager.h:42
int64_t xferred
Definition: poolmanager.h:35
bool operator<(const Pool &) const
virtual Pool getPool(const std::string &poolname)
Get a specific pool.
Pool handling API.