Loading include/norns/nornsctl.h +37 −22 Original line number Diff line number Diff line Loading @@ -61,15 +61,15 @@ typedef struct { typedef struct { const char* l_nsid; /* namespace ID */ uint32_t l_quota; /* job's quota */ } norns_job_limit_t; } nornsctl_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_job_limit_t** j_limits; /* NULL-terminated list of limits for the job */ nornsctl_job_limit_t** j_limits; /* NULL-terminated list of limits for the job */ size_t j_nlimits; /* entries in limits list */ } norns_job_t; } nornsctl_job_t; nornsctl_backend_t NORNSCTL_BACKEND(norns_flags_t flags, const char* mount_point, Loading @@ -79,49 +79,64 @@ void nornsctl_backend_init(nornsctl_backend_t* backend, norns_flags_t flags, const char* mount_point, uint32_t capacity) __THROW; norns_job_limit_t NORNS_JOB_LIMIT(const char* nsid, uint32_t quota) __THROW; nornsctl_job_limit_t NORNSCTL_JOB_LIMIT(const char* nsid, uint32_t quota) __THROW; void norns_job_limit_init(norns_job_limit_t* limit, const char* nsid, uint32_t quota) __THROW; void nornsctl_job_limit_init(nornsctl_job_limit_t* limit, const char* nsid, uint32_t quota) __THROW; norns_job_t NORNS_JOB(const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) __THROW; nornsctl_job_t NORNSCTL_JOB(const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) __THROW; void norns_job_init(norns_job_t* job, const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) __THROW; void nornsctl_job_init(nornsctl_job_t* job, const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) __THROW; /* Check if the urd daemon is running */ norns_error_t nornsctl_ping() __THROW; norns_error_t nornsctl_ping(void) __THROW; /* Send a command to the daemon (e.g. stop accepting new tasks) */ //norns_error_t norns_command(); /* Register a batch job into the system */ norns_error_t nornsctl_register_job(uint32_t jobid, norns_job_t* job) __THROW; norns_error_t nornsctl_register_job(uint32_t jobid, nornsctl_job_t* job) __THROW; /* Update an existing batch job */ /* XXX: At the moment this invalidates all registered processes for this job */ norns_error_t nornsctl_update_job(uint32_t jobid, norns_job_t* job) __THROW; norns_error_t nornsctl_update_job(uint32_t jobid, nornsctl_job_t* job) __THROW; /* Remove a batch job from the system */ norns_error_t nornsctl_unregister_job(uint32_t jobid) __THROW; norns_error_t nornsctl_unregister_job(uint32_t jobid) __THROW; /* Add a process to a registered batch job */ norns_error_t nornsctl_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; norns_error_t nornsctl_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; /* Remove a process from a registered batch job */ norns_error_t nornsctl_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; norns_error_t nornsctl_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; /* Register a namespace in the local norns server */ norns_error_t nornsctl_register_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; norns_error_t nornsctl_register_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; /* Update an existing namespace in the local norns server */ norns_error_t nornsctl_update_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; norns_error_t nornsctl_update_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; /* Unregister a namespace from the local norns server */ norns_error_t nornsctl_unregister_namespace(const char* nsid) __THROW; norns_error_t nornsctl_unregister_namespace(const char* nsid) __THROW; /* Return a string describing the error number */ char* norns_strerror(norns_error_t errnum) __THROW; char* norns_strerror(norns_error_t errnum) __THROW; #ifdef __cplusplus } Loading lib/communication.c +3 −3 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ send_ping_request() { } norns_error_t send_job_request(norns_rpc_type_t type, uint32_t jobid, norns_job_t* job) { send_job_request(norns_rpc_type_t type, uint32_t jobid, nornsctl_job_t* job) { int res; norns_response_t resp; Loading Loading @@ -225,8 +225,8 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { { const uint32_t jobid = va_arg(ap, const uint32_t); const norns_job_t* job = va_arg(ap, const norns_job_t*); const nornsctl_job_t* job = va_arg(ap, const nornsctl_job_t*); if((res = pack_to_buffer(type, &req_buf, jobid, job)) != NORNS_SUCCESS) { Loading lib/communication.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ norns_error_t send_submit_request(norns_iotask_t* task); norns_error_t send_status_request(norns_iotask_t* task, norns_stat_t* stats); norns_error_t send_job_request(norns_rpc_type_t type, uint32_t jobid, norns_job_t* job); nornsctl_job_t* job); norns_error_t send_process_request(norns_rpc_type_t type, uint32_t jobid, uid_t uid, gid_t gid, pid_t pid); norns_error_t send_namespace_request(norns_rpc_type_t type, const char* nsid, Loading lib/libnornsctl.c +16 −16 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ #define LIBNORNSCTL_LOG_PREFIX "libnornsctl" static bool validate_job(norns_job_t* job); static bool validate_job(nornsctl_job_t* job); static bool validate_namespace(nornsctl_backend_t* backend); static void Loading Loading @@ -126,7 +126,7 @@ nornsctl_ping() { /* Register and describe a batch job */ norns_error_t nornsctl_register_job(uint32_t jobid, norns_job_t* job) { nornsctl_register_job(uint32_t jobid, nornsctl_job_t* job) { if(!validate_job(job)) { return NORNS_EBADARGS; Loading @@ -137,7 +137,7 @@ nornsctl_register_job(uint32_t jobid, norns_job_t* job) { /* Update an existing batch job */ norns_error_t nornsctl_update_job(uint32_t jobid, norns_job_t* job) { nornsctl_update_job(uint32_t jobid, nornsctl_job_t* job) { if(!validate_job(job)) { return NORNS_EBADARGS; Loading Loading @@ -226,14 +226,14 @@ nornsctl_backend_init(nornsctl_backend_t* backend, norns_flags_t flags, backend->b_capacity = capacity; } norns_job_limit_t NORNS_JOB_LIMIT(const char* nsid, uint32_t quota) { nornsctl_job_limit_t NORNSCTL_JOB_LIMIT(const char* nsid, uint32_t quota) { norns_job_limit_t limit; norns_job_limit_init(&limit, nsid, quota); nornsctl_job_limit_t limit; nornsctl_job_limit_init(&limit, nsid, quota); return limit; } void norns_job_limit_init(norns_job_limit_t* limit, const char* nsid, void nornsctl_job_limit_init(nornsctl_job_limit_t* limit, const char* nsid, uint32_t quota) { if(limit == NULL) { Loading @@ -249,18 +249,18 @@ void norns_job_limit_init(norns_job_limit_t* limit, const char* nsid, limit->l_quota = quota; } norns_job_t NORNS_JOB(const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) { nornsctl_job_t NORNSCTL_JOB(const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) { norns_job_t job; norns_job_init(&job, hosts, nhosts, limits, nlimits); nornsctl_job_t job; nornsctl_job_init(&job, hosts, nhosts, limits, nlimits); return job; } void norns_job_init(norns_job_t* job, const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) { nornsctl_job_init(nornsctl_job_t* job, const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) { if(job == NULL) { return; Loading Loading @@ -291,7 +291,7 @@ validate_namespace(nornsctl_backend_t* backend) { static bool validate_job(norns_job_t* job) { validate_job(nornsctl_job_t* job) { return (job != NULL) && (job->j_hosts != NULL) && Loading lib/requests.c +5 −5 Original line number Diff line number Diff line Loading @@ -53,12 +53,12 @@ static void free_backend_message(Norns__Rpc__Request__Namespace__Backend* msg); static Norns__Rpc__Request__JobLimits* build_job_limits_msg(const norns_job_limit_t* lim); build_job_limits_msg(const nornsctl_job_limit_t* lim); static void free_job_limits_msg(Norns__Rpc__Request__JobLimits* msg); static Norns__Rpc__Request__Job* build_job_msg(const norns_job_t* job); build_job_msg(const nornsctl_job_t* job); static void free_job_msg(Norns__Rpc__Request__Job* msg); Loading Loading @@ -182,7 +182,7 @@ build_request_msg(norns_rpc_type_t type, va_list ap) { case NORNS_JOB_UNREGISTER: { const uint32_t jobid = va_arg(ap, uint32_t); const norns_job_t* job = va_arg(ap, norns_job_t*); const nornsctl_job_t* job = va_arg(ap, nornsctl_job_t*); req_msg->has_jobid = true; req_msg->jobid = jobid; Loading Loading @@ -389,7 +389,7 @@ error_cleanup: } static Norns__Rpc__Request__JobLimits* build_job_limits_msg(const norns_job_limit_t* lim) { build_job_limits_msg(const nornsctl_job_limit_t* lim) { assert(lim != NULL); Loading Loading @@ -423,7 +423,7 @@ error_cleanup: static Norns__Rpc__Request__Job* build_job_msg(const norns_job_t* job) { build_job_msg(const nornsctl_job_t* job) { assert(job != NULL); Loading Loading
include/norns/nornsctl.h +37 −22 Original line number Diff line number Diff line Loading @@ -61,15 +61,15 @@ typedef struct { typedef struct { const char* l_nsid; /* namespace ID */ uint32_t l_quota; /* job's quota */ } norns_job_limit_t; } nornsctl_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_job_limit_t** j_limits; /* NULL-terminated list of limits for the job */ nornsctl_job_limit_t** j_limits; /* NULL-terminated list of limits for the job */ size_t j_nlimits; /* entries in limits list */ } norns_job_t; } nornsctl_job_t; nornsctl_backend_t NORNSCTL_BACKEND(norns_flags_t flags, const char* mount_point, Loading @@ -79,49 +79,64 @@ void nornsctl_backend_init(nornsctl_backend_t* backend, norns_flags_t flags, const char* mount_point, uint32_t capacity) __THROW; norns_job_limit_t NORNS_JOB_LIMIT(const char* nsid, uint32_t quota) __THROW; nornsctl_job_limit_t NORNSCTL_JOB_LIMIT(const char* nsid, uint32_t quota) __THROW; void norns_job_limit_init(norns_job_limit_t* limit, const char* nsid, uint32_t quota) __THROW; void nornsctl_job_limit_init(nornsctl_job_limit_t* limit, const char* nsid, uint32_t quota) __THROW; norns_job_t NORNS_JOB(const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) __THROW; nornsctl_job_t NORNSCTL_JOB(const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) __THROW; void norns_job_init(norns_job_t* job, const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) __THROW; void nornsctl_job_init(nornsctl_job_t* job, const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) __THROW; /* Check if the urd daemon is running */ norns_error_t nornsctl_ping() __THROW; norns_error_t nornsctl_ping(void) __THROW; /* Send a command to the daemon (e.g. stop accepting new tasks) */ //norns_error_t norns_command(); /* Register a batch job into the system */ norns_error_t nornsctl_register_job(uint32_t jobid, norns_job_t* job) __THROW; norns_error_t nornsctl_register_job(uint32_t jobid, nornsctl_job_t* job) __THROW; /* Update an existing batch job */ /* XXX: At the moment this invalidates all registered processes for this job */ norns_error_t nornsctl_update_job(uint32_t jobid, norns_job_t* job) __THROW; norns_error_t nornsctl_update_job(uint32_t jobid, nornsctl_job_t* job) __THROW; /* Remove a batch job from the system */ norns_error_t nornsctl_unregister_job(uint32_t jobid) __THROW; norns_error_t nornsctl_unregister_job(uint32_t jobid) __THROW; /* Add a process to a registered batch job */ norns_error_t nornsctl_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; norns_error_t nornsctl_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; /* Remove a process from a registered batch job */ norns_error_t nornsctl_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; norns_error_t nornsctl_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW; /* Register a namespace in the local norns server */ norns_error_t nornsctl_register_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; norns_error_t nornsctl_register_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; /* Update an existing namespace in the local norns server */ norns_error_t nornsctl_update_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; norns_error_t nornsctl_update_namespace(const char* nsid, nornsctl_backend_t* backend) __THROW; /* Unregister a namespace from the local norns server */ norns_error_t nornsctl_unregister_namespace(const char* nsid) __THROW; norns_error_t nornsctl_unregister_namespace(const char* nsid) __THROW; /* Return a string describing the error number */ char* norns_strerror(norns_error_t errnum) __THROW; char* norns_strerror(norns_error_t errnum) __THROW; #ifdef __cplusplus } Loading
lib/communication.c +3 −3 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ send_ping_request() { } norns_error_t send_job_request(norns_rpc_type_t type, uint32_t jobid, norns_job_t* job) { send_job_request(norns_rpc_type_t type, uint32_t jobid, nornsctl_job_t* job) { int res; norns_response_t resp; Loading Loading @@ -225,8 +225,8 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { { const uint32_t jobid = va_arg(ap, const uint32_t); const norns_job_t* job = va_arg(ap, const norns_job_t*); const nornsctl_job_t* job = va_arg(ap, const nornsctl_job_t*); if((res = pack_to_buffer(type, &req_buf, jobid, job)) != NORNS_SUCCESS) { Loading
lib/communication.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ norns_error_t send_submit_request(norns_iotask_t* task); norns_error_t send_status_request(norns_iotask_t* task, norns_stat_t* stats); norns_error_t send_job_request(norns_rpc_type_t type, uint32_t jobid, norns_job_t* job); nornsctl_job_t* job); norns_error_t send_process_request(norns_rpc_type_t type, uint32_t jobid, uid_t uid, gid_t gid, pid_t pid); norns_error_t send_namespace_request(norns_rpc_type_t type, const char* nsid, Loading
lib/libnornsctl.c +16 −16 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ #define LIBNORNSCTL_LOG_PREFIX "libnornsctl" static bool validate_job(norns_job_t* job); static bool validate_job(nornsctl_job_t* job); static bool validate_namespace(nornsctl_backend_t* backend); static void Loading Loading @@ -126,7 +126,7 @@ nornsctl_ping() { /* Register and describe a batch job */ norns_error_t nornsctl_register_job(uint32_t jobid, norns_job_t* job) { nornsctl_register_job(uint32_t jobid, nornsctl_job_t* job) { if(!validate_job(job)) { return NORNS_EBADARGS; Loading @@ -137,7 +137,7 @@ nornsctl_register_job(uint32_t jobid, norns_job_t* job) { /* Update an existing batch job */ norns_error_t nornsctl_update_job(uint32_t jobid, norns_job_t* job) { nornsctl_update_job(uint32_t jobid, nornsctl_job_t* job) { if(!validate_job(job)) { return NORNS_EBADARGS; Loading Loading @@ -226,14 +226,14 @@ nornsctl_backend_init(nornsctl_backend_t* backend, norns_flags_t flags, backend->b_capacity = capacity; } norns_job_limit_t NORNS_JOB_LIMIT(const char* nsid, uint32_t quota) { nornsctl_job_limit_t NORNSCTL_JOB_LIMIT(const char* nsid, uint32_t quota) { norns_job_limit_t limit; norns_job_limit_init(&limit, nsid, quota); nornsctl_job_limit_t limit; nornsctl_job_limit_init(&limit, nsid, quota); return limit; } void norns_job_limit_init(norns_job_limit_t* limit, const char* nsid, void nornsctl_job_limit_init(nornsctl_job_limit_t* limit, const char* nsid, uint32_t quota) { if(limit == NULL) { Loading @@ -249,18 +249,18 @@ void norns_job_limit_init(norns_job_limit_t* limit, const char* nsid, limit->l_quota = quota; } norns_job_t NORNS_JOB(const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) { nornsctl_job_t NORNSCTL_JOB(const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) { norns_job_t job; norns_job_init(&job, hosts, nhosts, limits, nlimits); nornsctl_job_t job; nornsctl_job_init(&job, hosts, nhosts, limits, nlimits); return job; } void norns_job_init(norns_job_t* job, const char** hosts, size_t nhosts, norns_job_limit_t** limits, size_t nlimits) { nornsctl_job_init(nornsctl_job_t* job, const char** hosts, size_t nhosts, nornsctl_job_limit_t** limits, size_t nlimits) { if(job == NULL) { return; Loading Loading @@ -291,7 +291,7 @@ validate_namespace(nornsctl_backend_t* backend) { static bool validate_job(norns_job_t* job) { validate_job(nornsctl_job_t* job) { return (job != NULL) && (job->j_hosts != NULL) && Loading
lib/requests.c +5 −5 Original line number Diff line number Diff line Loading @@ -53,12 +53,12 @@ static void free_backend_message(Norns__Rpc__Request__Namespace__Backend* msg); static Norns__Rpc__Request__JobLimits* build_job_limits_msg(const norns_job_limit_t* lim); build_job_limits_msg(const nornsctl_job_limit_t* lim); static void free_job_limits_msg(Norns__Rpc__Request__JobLimits* msg); static Norns__Rpc__Request__Job* build_job_msg(const norns_job_t* job); build_job_msg(const nornsctl_job_t* job); static void free_job_msg(Norns__Rpc__Request__Job* msg); Loading Loading @@ -182,7 +182,7 @@ build_request_msg(norns_rpc_type_t type, va_list ap) { case NORNS_JOB_UNREGISTER: { const uint32_t jobid = va_arg(ap, uint32_t); const norns_job_t* job = va_arg(ap, norns_job_t*); const nornsctl_job_t* job = va_arg(ap, nornsctl_job_t*); req_msg->has_jobid = true; req_msg->jobid = jobid; Loading Loading @@ -389,7 +389,7 @@ error_cleanup: } static Norns__Rpc__Request__JobLimits* build_job_limits_msg(const norns_job_limit_t* lim) { build_job_limits_msg(const nornsctl_job_limit_t* lim) { assert(lim != NULL); Loading Loading @@ -423,7 +423,7 @@ error_cleanup: static Norns__Rpc__Request__Job* build_job_msg(const norns_job_t* job) { build_job_msg(const nornsctl_job_t* job) { assert(job != NULL); Loading