Commit 617bad66 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Significant changes to data resource management

- Add transferor_registry class to manage resource transfer functions
- First implementation of 'local path' to 'local path' transferor using
  fadvice+fallocate+sendfile.
- Add stubs for other converters
- Move dispatch_table from api to common since it's now also used by
  transferor_registry.
- Add get() function to dispatch_table class so that stored functors
  can be retrieved.
- Generic implementation of task::operator()() to transfer resources and
  resource elements between different backends. When constructed, the
  task is provided with the input and ouput resources as well as a
  'transferor' functor that is invoked upon them to perform the actual
  transfer.
- Add new_resource() and get_resource() methods to backends to promote
  resource_info instances to fully qualified resources.
- Implementation of new_resource() and get_resource() for a POSIX
  filesystem. Stubs for other backends.
- New convenience library that aggregates all symbols for resources
- Add name() and is_collection() methods to class resource_info.
- Provide implementation for boost::filesystem::relative() in utils.cpp
  if boost version <= 1.6.0
- Remove resource::buffer, no longer needed (superseeded by transferors).
- Remove resource::stream, no longer needed (superseeded by transferors).
- Remove functions resource::info(), resource::backend(), and
  resource::set_backend().
- Reorganize resources build hierarchy
- Remove self-registration of backends
- Update tests
- Cleanup unused code
parent 65b151ed
Loading
Loading
Loading
Loading
+5 −13
Original line number Diff line number Diff line
@@ -61,7 +61,8 @@ typedef struct {
/* I/O task status descriptor */
typedef struct {
    norns_status_t st_status;     /* task current status */
    norns_error_t  st_error;     /* task return value */
    norns_error_t  st_task_error; /* task return value */
    int            st_sys_errno;  /* errno returned if st_task_error == NORNS_ESYSTEM_ERROR */
    size_t         st_pending;    /* bytes pending in task */
    size_t         st_total;      /* total bytes in task */
} norns_stat_t;
@@ -89,15 +90,6 @@ norns_error_t norns_cancel(norns_iotask_t* task) __THROW;
/* Check the status of a submitted I/O task */
norns_error_t norns_status(norns_iotask_t* task, norns_stat_t* stats) __THROW;

/* Retrieve return status associated with task */
norns_error_t norns_return(norns_iotask_t* task, norns_stat_t* stats) __THROW;

/* Retrieve current status associated with task (if task is NULL, retrieve status for all running tasks) */
//ssize_t norns_progress(norns_iotask_t* task, struct norns_iotst* statp) __THROW;

/* Retrieve error status associated with task */
//int norns_error(norns_iotask_t* task) __THROW;

/* Return a string describing the error number */
char* norns_strerror(norns_error_t errnum) __THROW;

+5 −3
Original line number Diff line number Diff line
@@ -59,9 +59,9 @@ extern "C" {
#define NORNS_EPROCESSEXISTS     -20
#define NORNS_ENOSUCHPROCESS     -21

/* errors about backends */
#define NORNS_EBACKENDEXISTS     -30
#define NORNS_ENOSUCHBACKEND     -31
/* errors about namespaces */
#define NORNS_ENAMESPACEEXISTS   -30
#define NORNS_ENOSUCHNAMESPACE   -31

/* errors about tasks */
#define NORNS_ETASKEXISTS        -40
@@ -72,9 +72,11 @@ extern "C" {
#define NORNS_EPENDING          -100
#define NORNS_EINPROGRESS       -101
#define NORNS_EFINISHED         -102
#define NORNS_EFINISHEDWERROR   -103

/* misc errors */
#define NORNS_ENOTSUPPORTED     -200
#define NORNS_ESYSTEMERROR      -201

#ifdef __cplusplus
}
+4 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#define __NORNS_RESOURCES_H__ 1

#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>     /* For uint32_t et al. */

#ifdef __cplusplus
+6 −2
Original line number Diff line number Diff line
@@ -59,8 +59,10 @@ send_submit_request(norns_iotask_t* task) {
    int res;
    norns_response_t resp;

    // XXX add missing checks
    if(task->t_id != 0) {
    // XXX add missing checks: e.g. validate src resource
    if(task->t_id != 0 || 
       (task->t_op != NORNS_IOTASK_COPY &&
        task->t_op != NORNS_IOTASK_MOVE )) {
        return NORNS_EBADARGS;
    }

@@ -98,6 +100,8 @@ send_status_request(norns_iotask_t* task, norns_stat_t* stats) {
    }

    stats->st_status = resp.r_status;
    stats->st_task_error = resp.r_task_error;
    stats->st_sys_errno = resp.r_errno;

    return resp.r_error_code;
}
+20 −0
Original line number Diff line number Diff line
@@ -30,18 +30,38 @@
#define ERR_REMAP(n) ((n) < 0 ? -(n) : (n))

const char* const norns_errlist[NORNS_ERRMAX + 1] = {
    /* misc errors */
    [ERR_REMAP(NORNS_SUCCESS)] = "Success",
    [ERR_REMAP(NORNS_ESNAFU)] = "Internal error",
    [ERR_REMAP(NORNS_EBADREQUEST)] = "Bad request",
    [ERR_REMAP(NORNS_EBADARGS)] = "Bad arguments",
    [ERR_REMAP(NORNS_ENOMEM)] = "Cannot allocate memory",
    [ERR_REMAP(NORNS_ENOTSUPPORTED)] = "Not supported",
    [ERR_REMAP(NORNS_ESYSTEMERROR)] = "Operating system error",

    /* communication errors */
    [ERR_REMAP(NORNS_ECONNFAILED)] = "Cannot connect to daemon",
    [ERR_REMAP(NORNS_ERPCSENDFAILED)] = "Cannot send requests to daemon",
    [ERR_REMAP(NORNS_ERPCRECVFAILED)] = "Cannot receive responses from daemon",

    /* job errors */
    [ERR_REMAP(NORNS_EJOBEXISTS)] = "Job already exists",
    [ERR_REMAP(NORNS_ENOSUCHJOB)] = "Job does not exist",

    /* process errors */
    [ERR_REMAP(NORNS_EPROCESSEXISTS)] = "Process already exists",
    [ERR_REMAP(NORNS_ENOSUCHPROCESS)] = "Process does not exist",
    
    /* backend errors */
    [ERR_REMAP(NORNS_ENAMESPACEEXISTS)] = "Namespace already exists",
    [ERR_REMAP(NORNS_ENOSUCHNAMESPACE)] = "Namespace does not exist",
    
    /* task errors */
    [ERR_REMAP(NORNS_ETASKEXISTS)] = "Task already exists",
    [ERR_REMAP(NORNS_ENOSUCHTASK)] = "Task does not exist",
    [ERR_REMAP(NORNS_ETOOMANYTASKS)] = "Too many pending tasks",

    /* fallback */
    [ERR_REMAP(NORNS_ERRMAX)] = "Unknown error",

};
Loading