Commit 4f72c208 authored by Ciarán Ó Rourke's avatar Ciarán Ó Rourke
Browse files

Support newer Phobos version

Changes to Phobos wrapper to reflect updated Phobos API.

Change log:
* make unit test a make target again
* remove deprecated and redundant target_link_directories call
* redesign phobos_cpp_wrapper for new Phobos version
* hardcode request of directory storage in Phobos for now
parent 0d30ac47
Pipeline #2196 failed with stages
in 3 seconds
......@@ -109,8 +109,8 @@ endif(DEIMOS_BUILD_DOCUMENTATION)
# Build tests
if(DEIMOS_BUILD_TESTS)
add_subdirectory(test)
enable_testing()
add_subdirectory(test)
endif(DEIMOS_BUILD_TESTS)
......
......@@ -11,6 +11,6 @@ target_include_directories(
)
target_link_directories(phobos_cpp_wrapper PUBLIC ${PHOBOS_LIBRARY_DIR})
#target_link_directories(phobos_cpp_wrapper PUBLIC ${PHOBOS_LIBRARY_DIR})
target_link_libraries(phobos_cpp_wrapper PUBLIC phobos_store)
......@@ -13,7 +13,51 @@
#ifndef DEIMOS_PHO_CPP_LIB_H
#define DEIMOS_PHO_CPP_LIB_H
#include "pho_attrs.h"
#include <pho_attrs.h>
/**
* Family of resource.
* Families can be seen here as storage technologies.
*/
enum rsc_family {
PHO_RSC_INVAL = -1,
PHO_RSC_DISK = 0, /**< Not supported yet */
PHO_RSC_TAPE = 1, /**< Tape, drive tape or tape library */
PHO_RSC_DIR = 2, /**< Directory */
PHO_RSC_LAST,
PHO_RSC_UNSPEC = PHO_RSC_LAST,
};
static const char * const rsc_family_names[] = {
[PHO_RSC_DISK] = "disk",
[PHO_RSC_TAPE] = "tape",
[PHO_RSC_DIR] = "dir",
};
static inline const char *rsc_family2str(enum rsc_family family)
{
if (family >= PHO_RSC_LAST || family < 0)
return NULL;
return rsc_family_names[family];
}
static inline enum rsc_family str2rsc_family(const char *str)
{
int i;
for (i = 0; i < PHO_RSC_LAST; i++)
if (!strcmp(str, rsc_family_names[i]))
return (rsc_family)i;
return PHO_RSC_INVAL;
}
/**
* A simple array of tags (strings)
*/
struct tags {
char **tags; /**< The array of tags */
size_t n_tags; /**< Number of tags */
};
/**
* Transfer (GET / PUT / MPUT) flags.
......@@ -22,54 +66,63 @@
enum pho_xfer_flags {
/* put: replace the object if it already exists (_not supported_)
* get: replace the target file if it already exists */
PHO_XFER_OBJ_REPLACE = (1 << 0),
PHO_XFER_OBJ_REPLACE = (1 << 0),
};
/**
* Multiop completion notification callback.
* Invoked with:
* - user-data pointer
* - the operation descriptor
* - the return code for this operation: 0 on success, neg. errno on failure
*/
typedef void (*pho_completion_cb_t)(void *u, const struct pho_xfer_desc *, int);
/**
* Phobos XFer operations.
*/
enum pho_xfer_op {
PHO_XFER_OP_PUT, /**< Put operation */
PHO_XFER_OP_GET, /**< Get operation */
PHO_XFER_OP_GETMD /**< Get metadata operation */
PHO_XFER_OP_PUT, /**< PUT operation. */
PHO_XFER_OP_GET, /**< GET operation. */
PHO_XFER_OP_GETMD /**< GET metadata operation. */
};
/**
* A simple array of tags (strings)
* PUT parameters.
*/
struct tags {
char** tags; /**< The array of tags */
size_t n_tags; /**< Number of tags */
struct pho_xfer_put_params {
ssize_t size; /**< Amount of data to write. */
enum rsc_family family; /**< Targeted resource family. */
const char *layout_name; /**< Name of the layout module to use. */
struct tags tags; /**< Tags to select a media to write. */
};
/**
* Operation parameters.
*/
union pho_xfer_params {
struct pho_xfer_put_params put; /**< PUT parameters. */
};
/**
* GET / PUT parameter.
* Xfer descriptor.
* The source/destination semantics of the fields vary
* depending on the nature of the operation.
* See below:
* - pĥobos_getmd()
* - phobos_get()
* - phobos_put()
*/
struct pho_xfer_desc {
char* xd_objid; /**< Object id to read or write */
enum pho_xfer_op xd_op; /**< Operation to perform
* (GET, GETMD or PUT)
*/
int xd_fd; /**< positive fd if xd_id_open */
ssize_t xd_size; /**< Amount of data to write (for the GET
* operation, the size read is equal to
* the size of the retrieved object)
*/
const char* xd_layout_name; /**< Name of the layout module to use
* (for put).
*/
struct pho_attrs xd_attrs; /**< User defined attribute to get / put */
enum pho_xfer_flags xd_flags; /**< See enum pho_xfer_flags doc */
struct tags xd_tags; /**< Tags to select a media to write */
int xd_rc; /**< Outcome of this xfer */
char *xd_objid; /**< Object ID to read or write. */
enum pho_xfer_op xd_op; /**< Operation to perform. */
int xd_fd; /**< FD of the source/destination. */
struct pho_attrs xd_attrs; /**< User defined attributes. */
union pho_xfer_params xd_params; /**< Operation parameters. */
enum pho_xfer_flags xd_flags; /**< See enum pho_xfer_flags doc. */
int xd_rc; /**< Outcome of this xfer. */
};
typedef void (*pho_completion_cb_t)(void* u, const struct pho_xfer_desc*, int);
/**
* Put N files to the object store with minimal overhead.
* Each desc entry contains:
......
......@@ -53,7 +53,9 @@ void Phobos_file::prepare_put(int file_descriptor, std::string object_id)
/* Tell Phobos to start reading from the file */
ssize_t Phobos_file::db_put(size_t size)
{
m_descriptor.xd_size = size;
m_descriptor.xd_params.put.size = size;
/* TODO: don't hardcode dir */
m_descriptor.xd_params.put.family = str2rsc_family("dir");
ssize_t rc = phobos_put_cpp(&m_descriptor, 1, NULL, NULL);
close_file();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment