dmlite  0.6
pool.h
Go to the documentation of this file.
1 /** @file include/dmlite/c/pool.h
2  * @brief C wrapper for DMLite Pool API.
3  * @author Alejandro Álvarez Ayllon <aalvarez@cern.ch>
4  */
5 #ifndef DMLITE_POOL_H
6 #define DMLITE_POOL_H
7 
8 #include "dmlite.h"
9 #include "any.h"
10 #include "inode.h"
11 #include "utils.h"
12 
13 #define POOL_TYPE_MAX 16
14 #define POOL_MAX 16
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /** @brief Pool data */
21 typedef struct dmlite_pool {
24 
26 } dmlite_pool;
27 
28 /** @brief Chunk of data */
29 typedef struct dmlite_chunk {
30  off_t offset;
31  size_t size;
33 } dmlite_chunk;
34 
35 /** @brief Collection of chunks that form a replica
36  * @details On read, there may be duplicated chunks.
37  */
38 typedef struct dmlite_location {
40  unsigned nchunks;
42 
43 /**
44  * @brief Gets the list of pools.
45  * @param context The DM context.
46  * @param nPools The number of pools.
47  * @param pools An array with the pools. <b>Use dmlite_freepools to free</b>.
48  * @return 0 on success, error code otherwise.
49  */
50 int dmlite_getpools(dmlite_context* context, unsigned* nPools, dmlite_pool** pools);
51 
52 /**
53  * @brief Frees an array of pools.
54  * @param nPools The number of pools in the array.
55  * @param pools The array to free.
56  * @return 0 on success, error code otherwise.
57  */
58 int dmlite_pools_free(unsigned nPools, dmlite_pool* pools);
59 
60 /**
61  * @brief Gets a single replica (synchronous).
62  * @param context The DM context.
63  * @param path The logical file name.
64  * @return A pointer to a dmlite_location struct, or NULL on error.
65  */
66 dmlite_location* dmlite_get(dmlite_context* context, const char* path);
67 
68 /**
69  * @brief Gets a single replica (synchronous).
70  * @param context The DM context.
71  * @param inode The file inode.
72  * @return A pointer to a dmlite_location struct, or NULL on error.
73  */
74 dmlite_location* dmlite_iget(dmlite_context* context, ino_t inode);
75 
76 /**
77  * @brief Gets the location of a replica.
78  * @param context The DM context.
79  * @param replica The replica to translate.
80  * @return A pointer to a dmlite_location struct, or NULL on error.
81  */
83 
84 /**
85  * @brief Puts a file (synchronous).
86  * @param context The DM context.
87  * @param path The logical file name to put.
88  * @return A pointer to a dmlite_location struct, or NULL on error.
89  */
90 dmlite_location* dmlite_put(dmlite_context* context, const char* path);
91 
92 /**
93  * @brief Aborts a put request.
94  * @param context The DM context.
95  * @param loc As returned by dmlite_put.
96  * @return 0 on success, error code otherwise.
97  */
98 int dmlite_put_abort(dmlite_context* context, const dmlite_location* loc);
99 
100 /**
101  * @brief Frees a location struct.
102  * @param loc The struct to free.
103  * @return 0 on success, error code otherwise.
104  */
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* DMLITE_POOL_H */
int dmlite_pools_free(unsigned nPools, dmlite_pool *pools)
Frees an array of pools.
Definition: inode.h:29
Chunk of data.
Definition: pool.h:29
int dmlite_put_abort(dmlite_context *context, const dmlite_location *loc)
Aborts a put request.
dmlite_location * dmlite_iget(dmlite_context *context, ino_t inode)
Gets a single replica (synchronous).
struct dmlite_location dmlite_location
Collection of chunks that form a replica.
struct dmlite_any_dict dmlite_any_dict
Handles key-&gt;value pairs.
Definition: any.h:25
int dmlite_location_free(dmlite_location *loc)
Frees a location struct.
C wrapper for DMLite.
off_t offset
Definition: pool.h:30
size_t size
Definition: pool.h:31
C wrapper for DMLite utils.
dmlite_location * dmlite_put(dmlite_context *context, const char *path)
Puts a file (synchronous).
struct dmlite_chunk dmlite_chunk
Chunk of data.
unsigned nchunks
Definition: pool.h:40
char pool_name[POOL_MAX]
Definition: pool.h:23
Opaque handler to pass different types of values to the API.
struct dmlite_context dmlite_context
Handle for a initialized context.
Definition: dmlite.h:23
struct dmlite_pool dmlite_pool
Pool data.
dmlite_location * dmlite_getlocation(dmlite_context *context, const dmlite_replica *replica)
Gets the location of a replica.
dmlite_url url
Definition: pool.h:32
#define POOL_TYPE_MAX
Definition: pool.h:13
Handles URL.
Definition: utils.h:39
dmlite_location * dmlite_get(dmlite_context *context, const char *path)
Gets a single replica (synchronous).
dmlite_chunk * chunks
Definition: pool.h:39
#define POOL_MAX
Definition: pool.h:14
char pool_type[POOL_TYPE_MAX]
Definition: pool.h:22
C wrapper for DMLite INode API.
Pool data.
Definition: pool.h:21
dmlite_any_dict * extra
Definition: pool.h:25
Collection of chunks that form a replica.
Definition: pool.h:38
int dmlite_getpools(dmlite_context *context, unsigned *nPools, dmlite_pool **pools)
Gets the list of pools.