Commit 65b151ed authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Important API refactoring

- Rename norns_register_backend to norns_register_namespace
- Rename norns_unregister_backend to norns_unregister_namespace
- Rename norns_update_backend to norns_update_namespace
- API is now more symmetrical: all norns_*_namespace functions
receive an nsid as first parameter (in previous versions this
was not consistent).
- The norns_job_t descriptor now requires a norns_job_limit_t
parameter that defines what the job will be allowed to do, rather
than a norns_backend_t specification as in previous versions.
- Other changes: message passing logic improved
parent 119084c6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -35,11 +35,11 @@ extern "C" {
/* Storage backend types */
//#define NORNS_BACKEND_LOCAL_NVML        0x10000000
//#define NORNS_BACKEND_REMOTE_NVML       0x10000001
//#define NORNS_BACKEND_PROCESS_MEMORY    0x10000005 // deprecated
#define NORNS_BACKEND_NVML              0x10000001
#define NORNS_BACKEND_LUSTRE            0x10000002
#define NORNS_BACKEND_PROCESS_MEMORY    0x10000003
#define NORNS_BACKEND_ECHOFS            0x10000004
#define NORNS_BACKEND_POSIX_FILESYSTEM  0x10000005
#define NORNS_BACKEND_ECHOFS            0x10000003
#define NORNS_BACKEND_POSIX_FILESYSTEM  0x10000004

#ifdef __cplusplus
}
+4 −4
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ typedef struct {

/* Descriptor for a POSIX path */
typedef struct {
    const char* p_nsid;  /* namespace id */
    const char* p_host;  /* hostname (NULL if local) */
    const char* p_path;  /* path to "data" (i.e. file or directory) */
} norns_posix_path_t;
@@ -86,14 +87,13 @@ typedef struct {
    // 5.   echofs          echofs://path/to/dir/[file]             CUSTOM

    norns_flags_t r_flags; /* resource type and flags */
    const char*   r_nsid;  /* namespace id */
    union {
        norns_memory_region_t r_buffer;
        norns_posix_path_t r_posix_path;
    };
} norns_resource_t;

norns_resource_t NORNS_MEMORY_REGION(const char* nsid, void* addr, size_t size);
norns_resource_t NORNS_MEMORY_REGION(void* addr, size_t size);
norns_resource_t NORNS_LOCAL_PATH(const char* nsid, const char* path);
norns_resource_t NORNS_REMOTE_PATH(const char* nsid, const char* host, const char* path);
norns_resource_t NORNS_SHARED_PATH(const char* nsid, const char* path);
+28 −26
Original line number Diff line number Diff line
@@ -46,40 +46,42 @@ extern "C" {
/* will be able to successfully use these)                                */
/**************************************************************************/

/* Descriptor for a storage backend */
/* Descriptor for a storage namespace */
typedef struct {
    const char* b_nsid;     /* namespace ID for this backend (e.g. nvm01, tmpfs02, ...) */
    int         b_type;     /* backend type */
    int         b_type;     /* namespace type */
    const char* b_mount;    /* mount point */
    size_t      b_quota;    /* backend capacity (in megabytes) for writing data */
    uint32_t    b_capacity; /* namespace capacity (in megabytes) for writing data */
} norns_backend_t;

/* Descriptor for a batch job limits w.r.t. a namespace */
typedef struct {
    const char* l_nsid;     /* namespace ID */
    uint32_t    l_quota;    /* job's quota */
} norns_job_limit_t;

/* Descriptor for a batch job */
typedef struct {
    const char**        j_hosts;  /* NULL-terminated list of hostnames participating in the job */
    size_t              j_nhosts; /* entries in hostname list */
    norns_backend_t** j_backends; /* NULL-terminated list of storage backends the job is allowed to use */
    size_t            j_nbackends; /* entries in backend list */
    norns_job_limit_t** j_limits; /* NULL-terminated list of limits for the job */
    size_t              j_nlimits;  /* entries in limits list */
} norns_job_t;

/* Descriptor for a batch job access rights */
typedef struct {
    const char* r_nsid;     /* namespace ID */
    size_t      r_quota;    /* job's quota */
} norns_access_rights_t;
norns_backend_t NORNS_BACKEND(norns_flags_t flags, const char* mount_point, 
                              uint32_t capacity) __THROW;

void norns_backend_init(norns_backend_t* backend, norns_flags_t flags, 
                        const char* mount_point, uint32_t capacity) __THROW;

norns_backend_t NORNS_BACKEND(const char* nsid, norns_flags_t flags, 
                              const char* mount_point, uint32_t quota) __THROW;
norns_job_limit_t NORNS_JOB_LIMIT(const char* nsid, uint32_t quota) __THROW;

void norns_backend_init(norns_backend_t* backend, const char* nsid, 
                        norns_flags_t flags, const char* mount_point,
                        uint32_t quota) __THROW;
void norns_job_limit_init(norns_job_limit_t* limit, const char* nsid, uint32_t quota) __THROW;

norns_job_t NORNS_JOB(const char** hosts, size_t nhosts, 
                      norns_backend_t** backends, size_t nbackends) __THROW;
                      norns_job_limit_t** limits, size_t nlimits) __THROW;

void norns_job_init(norns_job_t* job, const char** hosts, size_t nhosts, 
                    norns_backend_t** backends, size_t nbackends) __THROW;
                    norns_job_limit_t** limits, size_t nlimits) __THROW;

/* Check if the urd daemon is running */
norns_error_t norns_ping() __THROW;
@@ -103,14 +105,14 @@ norns_error_t norns_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid)
/* Remove a process from a registered batch job */
norns_error_t norns_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;

/* Register a backend in the local norns server */
norns_error_t norns_register_backend(norns_backend_t* backend) __THROW;
/* Register a namespace in the local norns server */
norns_error_t norns_register_namespace(const char* nsid, norns_backend_t* backend) __THROW;

/* Update an existing backend in the local norns server */
norns_error_t norns_register_backend(norns_backend_t* backend) __THROW;
/* Update an existing namespace in the local norns server */
norns_error_t norns_update_namespace(const char* nsid, norns_backend_t* backend) __THROW;

/* Unregister a backend from the local norns server */
norns_error_t norns_unregister_backend(const char* prefix) __THROW;
/* Unregister a namespace from the local norns server */
norns_error_t norns_unregister_namespace(const char* nsid) __THROW;

/* Return a string describing the error number */
char* norns_strerror(norns_error_t errnum) __THROW;
+5 −5
Original line number Diff line number Diff line
@@ -35,11 +35,11 @@ lib_LTLIBRARIES = \
	libnornsctl.la \
	libnornsctl_debug.la

include_HEADERS = \
	$(top_srcdir)/include/norns.h
	$(top_srcdir)/include/nornsctl.h
	$(top_srcdir)/include/norns/norns_error.h
	$(top_srcdir)/include/norns/norns_resources.h
#include_HEADERS = \
#	$(top_srcdir)/include/norns.h
#	$(top_srcdir)/include/nornsctl.h
#	$(top_srcdir)/include/norns/norns_error.h
#	$(top_srcdir)/include/norns/norns_resources.h

AM_CPPFLAGS = \
	-I$(top_srcdir)/include \
+13 −13
Original line number Diff line number Diff line
@@ -158,13 +158,13 @@ send_process_request(norns_rpc_type_t type, uint32_t jobid,
}

norns_error_t
send_backend_request(norns_rpc_type_t type, const char* nsid, 
                     norns_backend_t* backend) {
send_namespace_request(norns_rpc_type_t type, const char* nsid, 
                       norns_backend_t* ns) {

    int res;
    norns_response_t resp;

    if((res = send_request(type, &resp, nsid, backend)) 
    if((res = send_request(type, &resp, nsid, ns)) 
            != NORNS_SUCCESS) {
        return res;
    }
@@ -188,8 +188,8 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) {
    if(type == NORNS_PING                 || type == NORNS_JOB_REGISTER     || 
       type == NORNS_JOB_UPDATE           || type == NORNS_JOB_UNREGISTER   || 
       type == NORNS_PROCESS_ADD          || type == NORNS_PROCESS_REMOVE   || 
       type == NORNS_BACKEND_REGISTER || type == NORNS_BACKEND_UPDATE || 
       type == NORNS_BACKEND_UNREGISTER) {
       type == NORNS_NAMESPACE_REGISTER   || type == NORNS_NAMESPACE_UPDATE || 
       type == NORNS_NAMESPACE_UNREGISTER) {
        control_request = true;
    }

@@ -258,16 +258,16 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) {
            break;
        }

        case NORNS_BACKEND_REGISTER:
        case NORNS_BACKEND_UPDATE:
        case NORNS_BACKEND_UNREGISTER:
        case NORNS_NAMESPACE_REGISTER:
        case NORNS_NAMESPACE_UPDATE:
        case NORNS_NAMESPACE_UNREGISTER:
        {
            const char* const prefix =
            const char* const nsid =
                va_arg(ap, const char* const);
            const norns_backend_t* backend = 
                va_arg(ap, const norns_backend_t*);

            if((res = pack_to_buffer(type, &req_buf, prefix, backend)) 
            if((res = pack_to_buffer(type, &req_buf, nsid, backend)) 
                    != NORNS_SUCCESS) {
                return res;
            }
Loading