pool.h

Go to the documentation of this file.
00001 /** @file   include/dmlite/c/pool.h
00002  *  @brief  C wrapper for DMLite Pool API.
00003  *  @author Alejandro Álvarez Ayllon <aalvarez@cern.ch>
00004  */
00005 #ifndef DMLITE_POOL_H
00006 #define DMLITE_POOL_H
00007 
00008 #include "any.h"
00009 #include "inode.h"
00010 #include "dmlite.h"
00011 #include "utils.h"
00012 
00013 #define POOL_TYPE_MAX 16
00014 #define POOL_MAX      16
00015 
00016 #ifdef  __cplusplus
00017 extern "C" {
00018 #endif
00019   
00020 /** @brief Pool data */
00021 typedef struct dmlite_pool {
00022   char pool_type[POOL_TYPE_MAX];
00023   char pool_name[POOL_MAX];
00024   
00025   dmlite_any_dict* extra;
00026 } dmlite_pool;
00027 
00028 /** @brief Chunk of data */
00029 typedef struct dmlite_chunk {
00030   char host[HOST_NAME_MAX];
00031   char path[PATH_MAX];
00032   
00033   off_t  offset;
00034   size_t size;
00035   
00036   dmlite_any_dict* extra;
00037 } dmlite_chunk;
00038 
00039 /** @brief Collection of chunks that form a replica
00040  * @details There may be duplicated chunks.
00041  */
00042 typedef struct dmlite_location {
00043   dmlite_chunk* chunks;
00044   unsigned      nchunks;
00045 } dmlite_location;
00046 
00047 /**
00048  * @brief         Gets the list of pools.
00049  * @param context The DM context.
00050  * @param nPools  The number of pools.
00051  * @param pools   An array with the pools. <b>Use dmlite_freepools to free</b>.
00052  * @return        0 on succes, -1 on failure.
00053  */
00054 int dmlite_getpools(dmlite_context* context, unsigned* nPools, dmlite_pool** pools);
00055 
00056 /**
00057  * @brief         Frees an array of pools.
00058  * @param context The DM context.
00059  * @param nPools  The number of pools in the array.
00060  * @param pools   The array to free.
00061  * @return        0 on succes, -1 on failure.
00062  */
00063 int dmlite_pools_free(dmlite_context* context, unsigned nPools, dmlite_pool* pools);
00064 
00065 /**
00066  * @brief         Gets a single replica (synchronous).
00067  * @param context The DM context.
00068  * @param path    The logical file name.
00069  * @return        A pointer to a dmlite_location struct, or NULL on error.
00070  */
00071 dmlite_location* dmlite_get(dmlite_context* context, const char* path);
00072 
00073 /**
00074  * @brief         Gets a single replica (synchronous).
00075  * @param context The DM context.
00076  * @param inode   The file inode.
00077  * @return        A pointer to a dmlite_location struct, or NULL on error.
00078  */
00079 dmlite_location* dmlite_iget(dmlite_context* context, ino_t inode);
00080 
00081 /**
00082  * @brief         Gets the location of a replica.
00083  * @param context The DM context.
00084  * @param replica The replica to translate.
00085  * @return        A pointer to a dmlite_location struct, or NULL on error.
00086  */
00087 dmlite_location* dmlite_getlocation(dmlite_context* context, const dmlite_replica* replica);
00088 
00089 /**
00090  * @brief         Puts a file (synchronous).
00091  * @param context The DM context.
00092  * @param path    The logical file name to put.
00093  * @return        A pointer to a dmlite_location struct, or NULL on error.
00094  */
00095 dmlite_location* dmlite_put(dmlite_context* context, const char* path);
00096 
00097 /**
00098  * @brief         Frees a location struct.
00099  * @param context The DM context.
00100  * @param loc     The struct to free.
00101  * @return        0 on success, error code otherwise.
00102  */
00103 int dmlite_location_free(dmlite_context* context, dmlite_location* loc);
00104 
00105 #ifdef  __cplusplus
00106 }
00107 #endif
00108 
00109 #endif /* DMLITE_POOL_H */

Generated on 3 Mar 2013 for dmlite by  doxygen 1.4.7