dmlite
0.6
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
include
dmlite
cpp
pooldriver.h
Go to the documentation of this file.
1
/// @file include/dmlite/cpp/pooldriver.h
2
/// @brief Pool handling API.
3
/// @author Alejandro Álvarez Ayllón <aalvarez@cern.ch>
4
#ifndef DMLITE_CPP_POOLDRIVER_H
5
#define DMLITE_CPP_POOLDRIVER_H
6
7
#include "
dmlite/common/config.h
"
8
#include "
base.h
"
9
#include "
exceptions.h
"
10
#include "
inode.h
"
11
#include "
utils/urls.h
"
12
13
#include <map>
14
#include <vector>
15
16
namespace
dmlite {
17
18
// Forward declarations.
19
class
Pool;
20
class
StackInstance;
21
22
/// Represents a chunk of a file.
23
struct
Chunk
{
24
Chunk
();
25
Chunk
(
const
std::string&
url
, uint64_t
offset
, uint64_t
size
);
26
/// Chunk from a serialized string
27
explicit
Chunk
(
const
std::string& str);
28
29
uint64_t
offset
;
30
uint64_t
size
;
31
Url
url
;
32
33
bool
operator ==
(
const
Chunk
&)
const
;
34
bool
operator !=
(
const
Chunk
&)
const
;
35
bool
operator <
(
const
Chunk
&)
const
;
36
bool
operator >
(
const
Chunk
&)
const
;
37
38
std::string
toString
(
void
)
const
;
39
};
40
41
/// Represent the complete location of a file.
42
struct
Location
:
public
std::vector<Chunk> {
43
Location
() {}
44
Location
(
int
nitems,
const
Chunk
& proto): std::vector<
Chunk
>(nitems, proto) {}
45
46
Location
(
const
Location
& l): std::vector<
Chunk
>(l) {}
47
48
// Location from serialized string
49
explicit
Location
(
const
std::string& str);
50
51
std::string
toString
(
void
)
const
;
52
};
53
54
/// Handler for a pool. Works similary to a file handler.
55
class
PoolHandler
{
56
public
:
57
/// Destructor
58
virtual
~PoolHandler
();
59
60
/// Get the pool type of this pool.
61
virtual
std::string
getPoolType
(
void
)
throw
(
DmException
);
62
63
/// Get the pool name of this pool.
64
virtual
std::string
getPoolName
(
void
)
throw
(
DmException
);
65
66
/// Get the total space of this pool.
67
virtual
uint64_t
getTotalSpace
(
void
)
throw
(
DmException
);
68
69
/// Get the free space of this pool.
70
virtual
uint64_t
getFreeSpace
(
void
)
throw
(
DmException
);
71
72
/// Check if the pool is actually available.
73
virtual
bool
poolIsAvailable
(
bool
write =
true
)
throw
(
DmException
);
74
75
/// Check if a replica is available.
76
virtual
bool
replicaIsAvailable
(
const
Replica
& replica)
throw
(
DmException
);
77
78
/// Get the actual location of the file replica. This is pool-specific.
79
virtual
Location
whereToRead
(
const
Replica
& replica)
throw
(
DmException
);
80
81
/// Remove a replica from the pool.
82
virtual
void
removeReplica
(
const
Replica
& replica)
throw
(
DmException
);
83
84
/// Get where to put a file.
85
virtual
Location
whereToWrite
(
const
std::string& path)
throw
(
DmException
);
86
87
/// Cancel a write.
88
virtual
void
cancelWrite
(
const
Location
& loc)
throw
(
DmException
);
89
};
90
91
/// Interface for a pool driver
92
class
PoolDriver
:
public
virtual
BaseInterface
{
93
public
:
94
/// Destructor
95
virtual
~PoolDriver
();
96
97
/// Create a handler.
98
virtual
PoolHandler
*
createPoolHandler
(
const
std::string& poolName)
throw
(
DmException
);
99
100
/// Called just before adding the pool to the database.
101
/// To be used by a plugin, in case it needs to do some previous preparations.
102
/// (i.e. legacy filesystem will actually create the pool here)
103
virtual
void
toBeCreated
(
const
Pool
& pool)
throw
(
DmException
);
104
105
/// Called just after a pool is added to the database.
106
virtual
void
justCreated
(
const
Pool
& pool)
throw
(
DmException
);
107
108
/// Called when updating a pool.
109
virtual
void
update
(
const
Pool
& pool)
throw
(
DmException
);
110
111
/// Called just before a pool of this type is removed.
112
/// @note The driver may remove the pool itself (i.e. filesystem)
113
virtual
void
toBeDeleted
(
const
Pool
& pool)
throw
(
DmException
);
114
};
115
116
/// PoolDriver factory
117
class
PoolDriverFactory
:
public
virtual
BaseFactory
{
118
public
:
119
/// Destructor.
120
virtual
~PoolDriverFactory
();
121
122
/// Supported pool type
123
virtual
std::string
implementedPool
()
throw
();
124
125
protected
:
126
friend
class
StackInstance
;
127
128
/// Instantiate the implemented pool driver.
129
virtual
PoolDriver
*
createPoolDriver
(
void
) throw (
DmException
);
130
};
131
132
};
133
134
#endif // DMLITE_CPP_POOLDRIVER_H
Generated on Wed Oct 8 2014 02:52:35 for dmlite by
1.8.3.1