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#define CHUNK_ID_MAX 16
16#define CHUNK_URL_ALT_MAX 512
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/** @brief Pool data */
23typedef struct dmlite_pool {
26
29
30/** @brief Chunk of data */
31typedef struct dmlite_chunk {
32 off_t offset;
33 size_t size;
38
39/** @brief Collection of chunks that form a replica
40 * @details On read, there may be duplicated chunks.
41 */
42typedef struct dmlite_location {
44 unsigned nchunks;
46
47/**
48 * @brief Gets the list of pools.
49 * @param context The DM context.
50 * @param nPools The number of pools.
51 * @param pools An array with the pools. <b>Use dmlite_freepools to free</b>.
52 * @return 0 on success, error code otherwise.
53 */
54int dmlite_getpools(dmlite_context* context, unsigned* nPools, dmlite_pool** pools);
55
56/**
57 * @brief Frees an array of pools.
58 * @param nPools The number of pools in the array.
59 * @param pools The array to free.
60 * @return 0 on success, error code otherwise.
61 */
62int dmlite_pools_free(unsigned nPools, dmlite_pool* pools);
63
64/**
65 * @brief Gets a single replica (synchronous).
66 * @param context The DM context.
67 * @param path The logical file name.
68 * @return A pointer to a dmlite_location struct, or NULL on error.
69 */
70dmlite_location* dmlite_get(dmlite_context* context, const char* path);
71
72/** @brief Progress markers for file copies. FTS jargon calls these "FTS performance markers" */
73typedef struct dmlite_xferinfo {
74
75 // These are the performance markers to be passes
76 time_t timestamp;
80
81 // Other fields I have no idea, the ones from FTS look weird to me
83
84/**
85 * @brief Copy a file to a remote location (synchronous).
86 * @param context The DM context.
87 * @param path The logical file name.
88 * @param dest An URL, that must be a remote destination
89 * @param cksumcheck Tell the copy process to check the final checksums
90 * @param cksumtype Type of checksum that must be checked (e.g. adler32)
91 * @return 0 on success, error code otherwise. EAGAIN means performance marker
92 *
93 * Beware, the path to the delegated proxy (if any) is stored in the dmlite context
94 */
95int dmlite_copypush(dmlite_context* context, const char* path, const char* dest, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata);
96
97/**
98 * @brief Copy a file from a remote location (synchronous).
99 * Allows copying to this head node, may add a replica to an
100 * existing logical file entry
101 * @param context The DM context.
102 * @param path The logical file name.
103 * @param source An URL, that may be a remote destination
104 * @param cksumcheck Tell the copy process to check the final checksums
105 * @param cksumtype Type of checksum that must be checked (e.g. adler32)
106 * @return 0 on success, error code otherwise. EAGAIN means performance marker
107 *
108 * Beware, the path to the delegated proxy (if any) is stored in the dmlite context
109 */
110
111int dmlite_copypull(dmlite_context* context, const char* path, const char* source, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata);
112
113/**
114 * @brief Gets a single replica (synchronous).
115 * @param context The DM context.
116 * @param inode The file inode.
117 * @return A pointer to a dmlite_location struct, or NULL on error.
118 */
120
121/**
122 * @brief Gets the location of a replica.
123 * @param context The DM context.
124 * @param replica The replica to translate.
125 * @return A pointer to a dmlite_location struct, or NULL on error.
126 */
128
129/**
130 * @brief Puts a file (synchronous).
131 * @param context The DM context.
132 * @param path The logical file name to put.
133 * @return A pointer to a dmlite_location struct, or NULL on error.
134 */
135dmlite_location* dmlite_put(dmlite_context* context, const char* path);
136
137
138/**
139 * @brief Choose a server where to perform generic actions (e.g. a tunnel)
140 * @param context The DM context.
141 * @param path The logical file name to put.
142 * @return A pointer to a dmlite_location struct, or NULL on error.
143 */
145
146
147/**
148 * @brief Aborts a put request.
149 * @param context The DM context.
150 * @param loc As returned by dmlite_put.
151 * @return 0 on success, error code otherwise.
152 */
154
155/**
156 * @brief Frees a location struct.
157 * @param loc The struct to free.
158 * @return 0 on success, error code otherwise.
159 */
161
162/**
163 * @brief Get the estimation of the free/used space for writing into a directory
164 * @param path The path of the directory to query
165 * @param totalfree The total number of free bytes (may not be contiguous)
166 * @param used The total number of used bytes
167 * @return 0 on success, error code otherwise.
168 */
169int dmlite_getdirspaces(dmlite_context* context, const char *logicaldir, int64_t *freespace, int64_t *used);
170
171
172#ifdef __cplusplus
173}
174#endif
175
176#endif /* DMLITE_POOL_H */
Opaque handler to pass different types of values to the API.
struct dmlite_any_dict dmlite_any_dict
Handles key->value pairs.
Definition: any.h:25
struct dmlite_context dmlite_context
Handle for a initialized context.
Definition: dmlite.h:23
Entry point for DMLite.
Low-level access API.
dmlite_location * dmlite_getlocation(dmlite_context *context, const dmlite_replica *replica)
Gets the location of a replica.
dmlite_location * dmlite_get(dmlite_context *context, const char *path)
Gets a single replica (synchronous).
#define CHUNK_URL_ALT_MAX
Definition: pool.h:16
int dmlite_pools_free(unsigned nPools, dmlite_pool *pools)
Frees an array of pools.
int dmlite_copypull(dmlite_context *context, const char *path, const char *source, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata)
Copy a file from a remote location (synchronous). Allows copying to this head node,...
int dmlite_copypush(dmlite_context *context, const char *path, const char *dest, int cksumcheck, char *cksumtype, dmlite_xferinfo *progressdata)
Copy a file to a remote location (synchronous).
dmlite_location * dmlite_iget(dmlite_context *context, ino_t inode)
Gets a single replica (synchronous).
int dmlite_location_free(dmlite_location *loc)
Frees a location struct.
#define POOL_TYPE_MAX
Definition: pool.h:13
int dmlite_getpools(dmlite_context *context, unsigned *nPools, dmlite_pool **pools)
Gets the list of pools.
int dmlite_getdirspaces(dmlite_context *context, const char *logicaldir, int64_t *freespace, int64_t *used)
Get the estimation of the free/used space for writing into a directory.
int dmlite_put_abort(dmlite_context *context, const dmlite_location *loc)
Aborts a put request.
dmlite_location * dmlite_put(dmlite_context *context, const char *path)
Puts a file (synchronous).
#define CHUNK_ID_MAX
Definition: pool.h:15
#define POOL_MAX
Definition: pool.h:14
dmlite_location * dmlite_chooseserver(dmlite_context *context, const char *path)
Choose a server where to perform generic actions (e.g. a tunnel)
Chunk of data.
Definition: pool.h:31
char url_alt[CHUNK_URL_ALT_MAX]
Definition: pool.h:34
dmlite_url url
Definition: pool.h:36
char chunkid[CHUNK_ID_MAX]
Definition: pool.h:35
size_t size
Definition: pool.h:33
off_t offset
Definition: pool.h:32
Collection of chunks that form a replica.
Definition: pool.h:42
dmlite_chunk * chunks
Definition: pool.h:43
unsigned nchunks
Definition: pool.h:44
Pool data.
Definition: pool.h:23
char pool_type[POOL_TYPE_MAX]
Definition: pool.h:24
dmlite_any_dict * extra
Definition: pool.h:27
char pool_name[POOL_MAX]
Definition: pool.h:25
Definition: inode.h:33
Handles URL.
Definition: utils.h:39
Progress markers for file copies. FTS jargon calls these "FTS performance markers".
Definition: pool.h:73
int stripeindex
Definition: pool.h:77
int64_t stripexferred
Definition: pool.h:78
int totstripecount
Definition: pool.h:79
time_t timestamp
Definition: pool.h:76
C wrapper for DMLite utils.