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  /// chooses a server to perform alternate operations
77  /// e.g. tunnelling a gridftp connection
78  /// @param path A path, could be ignored, depending on the implementation
79  virtual Location chooseServer(const std::string& path) ;
80 
81  /// Cancel a write.
82  /// @param path The logical file name.
83  /// @param loc As returned by whereToWrite
84  virtual void cancelWrite(const Location& loc) ;
85 
86  /// Get the estimation of the free/used space for writing into a directory
87  /// @param path The path of the directory to query
88  /// @param totalfree The total number of free bytes (may not be contiguous)
89  /// @param used The total number of used bytes
90  virtual void getDirSpaces(const std::string& path, int64_t &totalfree, int64_t &used) ;
91 
92  /// Write a logical file towards a given URL
93  /// @param localsrcpath The path of the file
94  /// @param remotedesturl The URL to write to
95  /// @return 0 on success, error code otherwise. EAGAIN means performance marker
96  // Beware, the path to the delegated proxy (if any) is stored in the dmlite context
97  virtual DmStatus fileCopyPush(const std::string& localsrcpath, const std::string &remotedesturl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata) ;
98 
99  /// Fetch a file from a given URL
100  /// @param localdestpath The logical name of the file to create
101  /// @param remotesrcurl The URL to read the file from
102  /// @return 0 on success, error code otherwise. EAGAIN means performance marker
103  // Beware, the path to the delegated proxy (if any) is stored in the dmlite context
104  virtual DmStatus fileCopyPull(const std::string& localdestpath, const std::string &remotesrcurl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata) ;
105  };
106 
107  /// Plug-ins must implement a concrete factory to be instantiated.
108  class PoolManagerFactory: public virtual BaseFactory {
109  public:
110  /// Virtual destructor
111  virtual ~PoolManagerFactory();
112 
113  protected:
114  // Stack instance is allowed to instantiate PoolManager
115  friend class StackInstance;
116 
117  /// Children of PoolManagerFactory are allowed to instantiate too (decorator)
119  PluginManager* pm) ;
120 
121  /// Instantiate a implementation of Pool
123  };
124 
125 };
126 
127 #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:108
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)
virtual Location chooseServer(const std::string &path)
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.