dmlite
0.4
Main Page
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 <map>
8
#include <vector>
9
#include "
base.h
"
10
#include "
exceptions.h
"
11
#include "
inode.h
"
12
#include "
utils/extensible.h
"
13
14
namespace
dmlite {
15
16
// Forward declarations.
17
class
Pool;
18
class
StackInstance;
19
20
/// Represents a chunk of a file.
21
struct
Chunk
:
public
Extensible
{
22
std::string
host
;
23
std::string
path
;
24
off_t
offset
;
25
size_t
size
;
26
27
bool
operator ==
(
const
Chunk
&)
const
;
28
bool
operator !=
(
const
Chunk
&)
const
;
29
bool
operator <
(
const
Chunk
&)
const
;
30
bool
operator >
(
const
Chunk
&)
const
;
31
};
32
33
/// Represent the complete location of a file.
34
typedef
std::vector<Chunk>
Location
;
35
36
/// Handler for a pool. Works similary to a file handler.
37
class
PoolHandler
{
38
public
:
39
/// Destructor
40
virtual
~PoolHandler
();
41
42
/// Get the pool type of this pool.
43
virtual
std::string
getPoolType
(
void
)
throw
(
DmException
) = 0;
44
45
/// Get the pool name of this pool.
46
virtual
std::string
getPoolName
(
void
)
throw
(
DmException
) = 0;
47
48
/// Get the total space of this pool.
49
virtual
uint64_t
getTotalSpace
(
void
)
throw
(
DmException
) = 0;
50
51
/// Get the free space of this pool.
52
virtual
uint64_t
getFreeSpace
(
void
)
throw
(
DmException
) = 0;
53
54
/// Check if the pool is actually available
55
virtual
bool
poolIsAvailable
(
bool
write =
true
)
throw
(
DmException
) = 0;
56
57
/// Check if a replica is available
58
virtual
bool
replicaIsAvailable
(
const
Replica
& replica)
throw
(
DmException
) = 0;
59
60
/// Get the actual location of the file replica. This is pool-specific.
61
virtual
Location
whereToRead
(
const
Replica
& replica)
throw
(
DmException
) = 0;
62
63
/// Remove a replica from the pool.
64
virtual
void
removeReplica
(
const
Replica
& replica)
throw
(
DmException
) = 0;
65
66
/// Get where to put a file
67
virtual
Location
whereToWrite
(
const
std::string& path)
throw
(
DmException
) = 0;
68
};
69
70
/// Interface for a pool driver
71
class
PoolDriver
:
public
virtual
BaseInterface
{
72
public
:
73
/// Destructor
74
virtual
~PoolDriver
();
75
76
/// Create a handler.
77
virtual
PoolHandler
*
createPoolHandler
(
const
std::string& poolName)
throw
(
DmException
) = 0;
78
79
/// Called just before adding the pool to the database.
80
/// To be used by a plugin, in case it needs to do some previous preparations.
81
/// (i.e. legacy filesystem will actually create the pool here)
82
virtual
void
toBeCreated
(
const
Pool
& pool)
throw
(
DmException
) = 0;
83
84
/// Called just after a pool is added to the database.
85
virtual
void
justCreated
(
const
Pool
& pool)
throw
(
DmException
) = 0;
86
87
/// Called when updating a pool.
88
virtual
void
update
(
const
Pool
& pool)
throw
(
DmException
) = 0;
89
90
/// Called just before a pool of this type is removed.
91
/// @note The driver may remove the pool itself (i.e. filesystem)
92
virtual
void
toBeDeleted
(
const
Pool
& pool)
throw
(
DmException
) = 0;
93
};
94
95
/// PoolDriver factory
96
class
PoolDriverFactory
:
public
virtual
BaseFactory
{
97
public
:
98
/// Destructor.
99
virtual
~PoolDriverFactory
();
100
101
/// Supported pool type
102
virtual
std::string
implementedPool
()
throw
() = 0;
103
104
protected
:
105
friend
class
StackInstance
;
106
107
/// Instantiate the implemented pool driver.
108
virtual
PoolDriver
*
createPoolDriver
(
void
) throw (
DmException
) = 0;
109
};
110
111
};
112
113
#endif // DMLITE_CPP_POOLDRIVER_H
Generated on Sun Oct 28 2012 12:15:42 for dmlite by
1.8.1.2