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