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
dmlite::Pool::type
std::string type
Definition: poolmanager.h:24
exceptions.h
Exceptions used by the API.
dmlite::PoolManager::kForRead
@ kForRead
Definition: poolmanager.h:42
dmlite::BaseFactory
Base class for factories.
Definition: base.h:48
dmlite::PoolManager::newPool
virtual void newPool(const Pool &pool)
Create a new pool.
extensible.h
Extensible types (hold metadata).
dmlite::PoolManager::PoolAvailability
PoolAvailability
Definition: poolmanager.h:42
dmlite::PoolManagerFactory::~PoolManagerFactory
virtual ~PoolManagerFactory()
Virtual destructor.
base.h
Base interfaces.
dmlite::Extensible
Helpful typedef for KeyValue containers.
Definition: extensible.h:20
dmlite::PoolManager::fileCopyPull
virtual DmStatus fileCopyPull(const std::string &localdestpath, const std::string &remotesrcurl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata)
dmlite_xferinfo
Progress markers for file copies. FTS jargon calls these "FTS performance markers".
Definition: pool.h:73
dmlite::Pool::operator==
bool operator==(const Pool &) const
dmlite::xferprogmarker::xferred
int64_t xferred
Definition: poolmanager.h:35
dmlite::PoolManager::getPools
virtual std::vector< Pool > getPools(PoolAvailability availability=kAny)
dmlite::PoolManagerFactory::createPoolManager
static PoolManager * createPoolManager(PoolManagerFactory *factory, PluginManager *pm)
Children of PoolManagerFactory are allowed to instantiate too (decorator)
dmlite::PoolManagerFactory
Plug-ins must implement a concrete factory to be instantiated.
Definition: poolmanager.h:108
dmlite::StackInstance
Definition: dmlite.h:161
pooldriver.h
Pool handling API.
dmlite::Pool::operator<
bool operator<(const Pool &) const
pool.h
C wrapper for DMLite Pool API.
dmlite::PoolManager::fileCopyPush
virtual DmStatus fileCopyPush(const std::string &localsrcpath, const std::string &remotedesturl, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata)
dmlite::Location
Represent the complete location of a file.
Definition: pooldriver.h:49
dmlite::PoolManager::getDirSpaces
virtual void getDirSpaces(const std::string &path, int64_t &totalfree, int64_t &used)
dmlite::PluginManager
CatalogInterface can only be instantiated through this class.
Definition: dmlite.h:42
dmlite::PoolManager::~PoolManager
virtual ~PoolManager()
Destructor.
dmlite::Pool::name
std::string name
Definition: poolmanager.h:23
dmlite::DmStatus
Definition: status.h:17
dmlite::PoolManager::updatePool
virtual void updatePool(const Pool &pool)
Update pool metadata.
dmlite::PoolManager::kAny
@ kAny
Definition: poolmanager.h:42
dmlite::PoolManager::kNone
@ kNone
Definition: poolmanager.h:42
config.h
Header generated by CMake with the build configuration used.
dmlite::PoolManager::deletePool
virtual void deletePool(const Pool &pool)
Remove a pool.
dmlite::PoolManager::whereToWrite
virtual Location whereToWrite(const std::string &path)
dmlite::BaseInterface
Base class for interfaces.
Definition: base.h:18
dmlite::PoolManager
Interface for pool types.
Definition: poolmanager.h:40
dmlite::xferprogmarker
struct dmlite::xferprogmarker xferprogmarker
Progress markers for file copies. FTS jargon calls these "FTS performance markers" beware,...
dmlite
Namespace for the dmlite C++ API.
Definition: authn.h:15
dmlite::PoolManager::getPool
virtual Pool getPool(const std::string &poolname)
Get a specific pool.
dmlite::PoolManager::cancelWrite
virtual void cancelWrite(const Location &loc)
dmlite::PoolManager::kForWrite
@ kForWrite
Definition: poolmanager.h:42
dmlite::Pool
Internal interface for handling pool metadata.
Definition: poolmanager.h:22
dmlite::PoolManager::chooseServer
virtual Location chooseServer(const std::string &path)
dmlite::PoolManager::kForBoth
@ kForBoth
Definition: poolmanager.h:42
dmlite::Pool::operator>
bool operator>(const Pool &) const
dmlite::PoolManager::whereToRead
virtual Location whereToRead(const std::string &path)
dmlite::Pool::operator!=
bool operator!=(const Pool &) const
dmlite::xferprogmarker
Progress markers for file copies. FTS jargon calls these "FTS performance markers" beware,...
Definition: poolmanager.h:34