Loading Makefile.am +1 −79 Original line number Diff line number Diff line Loading @@ -23,84 +23,6 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = etc lib examples src SUBDIRS = etc lib include examples src DIST_SUBDIRS = lib examples #bin_PROGRAMS = src/urd #MOSTLYCLEANFILES = \ # $(builddir)/src/defaults.cpp \ # $(builddir)/src/messages.pb.cc \ # $(builddir)/src/messages.pb.h #src_urd_SOURCES = \ # rpc/norns-rpc.h \ # src/ipc-listener.hpp \ # src/backends.cpp \ # src/backends.hpp \ # src/defaults.hpp \ # src/nvml-dax.cpp \ # src/nvml-dax.hpp \ # src/main.cpp \ # src/posix-fs.cpp \ # src/posix-fs.hpp \ # src/settings.cpp \ # src/settings.hpp \ # src/urd.cpp \ # src/urd.hpp \ # src/utils.cpp \ # src/utils.hpp # #nodist_src_urd_SOURCES = \ # src/defaults.cpp \ # src/messages.pb.cc \ # src/messages.pb.h #BUILT_SOURCES = \ # src/defaults.hpp \ # src/messages.pb.cc \ # src/messages.pb.h # #src_urd_CXXFLAGS = \ # @TBB_CFLAGS@ \ # -std=gnu++11 -Wall -Wextra # #src_urd_CPPFLAGS = \ # -DSPDLOG_ENABLE_SYSLOG \ # @BOOST_CPPFLAGS@ \ # -I$(top_srcdir)/include \ # -I$(top_srcdir)/src \ # -I$(top_srcdir)/rpc \ # -I$(top_builddir)/rpc # # #src_urd_LDFLAGS = \ # @TBB_LIBS@ \ # @BOOST_LDFLAGS@ \ # @BOOST_SYSTEM_LIB@ \ # @BOOST_ASIO_LIB@ \ # @BOOST_PROGRAM_OPTIONS_LIB@ \ # -pthread # #src_urd_LDADD = \ # -lboost_system # #$(builddir)/src/defaults.cpp: Makefile # @( echo "/* This file autogenerated by Makefile */"; \ # echo "#include \"defaults.hpp\""; \ # echo ""; \ # echo "namespace defaults {"; \ # echo " const char* progname = \"urd\";"; \ # echo " const bool daemonize = true;"; \ # echo " const char* running_dir = \"/tmp\";"; \ # echo " const char* ipc_sockfile = \"/tmp/urd.socket\";"; \ # echo " const char* daemon_pidfile = \"/tmp/urd.pid\";"; \ # echo " const uint32_t workers_in_pool = std::thread::hardware_concurrency();"; \ # echo " const char* config_file = \"$(sysconfdir)/norns.conf\";"; \ # echo "} // namespace defaults"; \ # ) > $@ # #$(builddir)/src/%.pb.cc %.pb.h: %.proto # $(PROTOC) --proto_path=$(srcdir) --cpp_out=$(builddir) $^ configure.ac +2 −1 Original line number Diff line number Diff line Loading @@ -103,8 +103,9 @@ AC_CHECK_HEADER_STDBOOL AC_CONFIG_FILES([ Makefile etc/Makefile lib/Makefile examples/Makefile include/Makefile lib/Makefile src/Makefile ]) AC_OUTPUT examples/job_registration.c +40 −17 Original line number Diff line number Diff line Loading @@ -41,14 +41,22 @@ int main(int argc, char* argv[]) { (void) argc; (void) argv; struct norns_cred cred; // create job descriptor from example data // 1. fill in hostnames int num_hosts = 3; const char** hosts = NORNS_PLIST_ALLOC(const char*, num_hosts); int num_hosts1 = 3; const char** hosts1 = NORNS_PLIST_ALLOC(const char*, num_hosts1); for(int i=0; i<num_hosts1; ++i) { hosts1[i] = ex_hosts[i]; } int num_hosts2 = 2; const char** hosts2 = NORNS_PLIST_ALLOC(const char*, num_hosts2); for(int i=0; i<num_hosts; ++i) { hosts[i] = ex_hosts[i]; for(int i=0; i<num_hosts2; ++i) { hosts2[i] = ex_hosts[num_hosts1+i]; } // 2. declare which backends the job is authorized to use Loading @@ -71,28 +79,43 @@ int main(int argc, char* argv[]) { } struct norns_job job = { .jb_hosts = hosts, .jb_nhosts = num_hosts, .jb_hosts = hosts1, .jb_nhosts = num_hosts1, .jb_backends = backends, .jb_nbackends = num_backends }; struct norns_cred cred; int rv; // try to register a duplicate jobid for(int i=0; i<2; ++i) { // register a job with ID 42 if((rv = norns_register_job(&cred, 42, &job)) != NORNS_SUCCESS) { fprintf(stderr, "norns_register_job failed!\n"); fprintf(stderr, "ERROR: norns_register_job failed!\n"); } else { fprintf(stdout, "norns_register_job succeded!\n"); } // update the job description job.jb_hosts = hosts2; job.jb_nhosts = num_hosts2; if((rv = norns_update_job(&cred, 42, &job)) != NORNS_SUCCESS) { fprintf(stderr, "norns_update_job failed!\n"); } else { fprintf(stdout, "norns_update_job succeded!\n"); } // unregister the job if((rv = norns_unregister_job(&cred, 42)) != NORNS_SUCCESS) { fprintf(stderr, "norns_unregister_job failed!\n"); } else { fprintf(stdout, "norns_unregister_job succeded!\n"); } NORNS_PLIST_FREE(hosts); NORNS_PLIST_FREE(hosts1); NORNS_PLIST_FREE(hosts2); NORNS_PLIST_FREE(backends); } include/Makefile.am 0 → 100644 +34 −0 Original line number Diff line number Diff line # Copyright (C) 2017 Barcelona Supercomputing Center # Centro Nacional de Supercomputacion # # This file is part of the Data Scheduler, a daemon for tracking and managing # requests for asynchronous data transfer in a hierarchical storage environment. # # See AUTHORS file in the top level directory for information # regarding developers and contributors. # # The Data Scheduler is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Data Scheduler is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Data Scheduler. If not, see <http://www.gnu.org/licenses/>. # ACLOCAL_AMFLAGS = -I m4 nornsincludedir=$(includedir)/norns nornsinclude_HEADERS = \ norns/norns.h \ norns/norns_backends.h \ norns/norns_error.h include_HEADERS = \ norns.h include/norns.h +1 −185 Original line number Diff line number Diff line Loading @@ -21,188 +21,4 @@ * along with Data Scheduler. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __NORNS_LIB_H__ #define __NORNS_LIB_H__ 1 #include <features.h> #include <sys/types.h> #include <stdint.h> #include <assert.h> __BEGIN_DECLS /* Error codes */ #define NORNS_SUCCESS 0 #define NORNS_EBADPARAMS -1 #define NORNS_ENOMEM -2 #define NORNS_ECONNFAILED -3 #define NORNS_ERPCSENDFAILED -4 #define NORNS_ERPCRECVFAILED -5 #define NORNS_EJOBEXISTS -6 typedef uint32_t jobid_t; /* Process credentials */ struct norns_cred { // TODO: to be completed, but at least... pid_t cr_pid; /* PID of the process */ gid_t cr_gid; /* GID of the process */ }; /* Data resource descriptor */ struct norns_resource { const char* r_hostname; /* hostname */ const char* r_path; /* path to "data" (i.e. file or directory) */ uint32_t r_type; /* type of resource */ }; /* I/O task descriptor */ struct norns_iotd { uint32_t ni_tid; /* task identifier */ struct norns_resource ni_src; /* data source */ struct norns_resource ni_dst; /* data destination */ uint32_t ni_type; /* operation to be performed */ struct norns_cred* ni_auth; /* process credentials (NULL if unprivileged) */ /* Internal members. */ pid_t __pid; /* pid of the process that made the request */ uint32_t __jobid; /* job id of the process that made the request (XXX Slurm dependent)*/ }; /* Storage resource types */ #define NORNS_NVML 0x1000 #define NORNS_POSIX 0x1001 /* Task types */ //enum { // NORNS_COPY = 00000000, // NORNS_MOVE = 00000001, // NORNS_LOCAL = 00000010, // NORNS_REMOTE = 00000020 //}; #define NORNS_COPY 00000000 #define NORNS_MOVE 00000001 #define NORNS_LOCAL 00000010 #define NORNS_REMOTE 00000020 /* I/O task status descriptor */ struct norns_iotst { int ni_status; /* current status */ }; /* Status codes */ enum { NORNS_WAITING, NORNS_INPROGRESS, NORNS_COMPLETE }; //void norns_init() __THROW; //int norns_getconf() __THROW; /**************************************************************************/ /* Client API */ /**************************************************************************/ /* Enqueue an asynchronous I/O task */ int norns_transfer(struct norns_iotd* iotdp) __THROW; /* wait for the completion of the task associated to iotdp */ int norns_wait(struct norns_iotd* iotdp) __THROW; /* Try to cancel an asynchronous I/O task associated with iotdp */ ssize_t norns_cancel(struct norns_iotd* iotdp) __THROW; /* Retrieve return status associated with iotdp */ ssize_t norns_return(struct norns_iotd* iotdp, struct norns_iotst* statp) __THROW; /* Retrieve current status associated with iotdp (if iotdp is NULL, retrieve status for all running tasks) */ ssize_t norns_progress(struct norns_iotd* iotdp, struct norns_iotst* statp) __THROW; /* Retrieve error status associated with iotdp */ int norns_error(struct norns_iotd* iotdp) __THROW; /**************************************************************************/ /* Administrative API */ /* (only authenticated processes will be able to successfully call these) */ /**************************************************************************/ #define NORNS_LOCAL_NVML 0x10000000 #define NORNS_REMOTE_NVML 0x10000001 #define NORNS_LUSTRE 0x10000002 /* Storage backend descriptor */ struct norns_backend { int b_type; const char* b_mount; /* mount point */ size_t b_quota; /* backend capacity (in megabytes) allocated to the job */ }; #define NORNS_ALLOC(size) \ ({ \ size_t __n = (size); \ void* __p = malloc(__n); \ assert(__p != NULL); \ __p; \ }) #define NORNS_FREE(p) \ ({ \ free(__p;) \ }) #define NORNS_PLIST_ALLOC(type, size) \ ({ \ size_t __n = (size); \ void** __plist = (void**) malloc(sizeof(type) * (__n + 1)); \ memset(__plist, 0, __n + 1); \ (type*) __plist; \ }) #define NORNS_PLIST_FREE(plist) \ ({ \ free((plist)); \ }) /* Batch job descriptor */ struct norns_job { const char** jb_hosts; /* NULL-terminated list of hostnames participating in the job */ size_t jb_nhosts; /* entries in hostname list */ struct norns_backend** jb_backends; /* NULL-terminated list of storage backends the job will use */ size_t jb_nbackends; /* entries in backend list */ }; /* Send a command to the daemon (e.g. stop accepting new tasks) */ int norns_command(struct norns_cred* auth); /* Register and describe a batch job */ int norns_register_job(struct norns_cred* auth, uint32_t jobid, struct norns_job* job); /* Update the description of an existing batch job */ int norns_update_job(struct norns_cred* auth, uint32_t jobid, struct norns_job* job); /* Remove the description of a batch job */ int norns_remove_job(struct norns_cred* auth, uint32_t jobid, struct norns_job* job); /* Add a process to a registered batch job */ int norns_add_process(struct norns_cred* auth, uint32_t jobid, pid_t pid); /* Remove a process from a registered batch job */ int norns_remove_process(struct norns_cred* auth, uint32_t jobid, pid_t pid); __END_DECLS #endif /* __NORNS_LIB_H__ */ #include "norns/norns.h" Loading
Makefile.am +1 −79 Original line number Diff line number Diff line Loading @@ -23,84 +23,6 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = etc lib examples src SUBDIRS = etc lib include examples src DIST_SUBDIRS = lib examples #bin_PROGRAMS = src/urd #MOSTLYCLEANFILES = \ # $(builddir)/src/defaults.cpp \ # $(builddir)/src/messages.pb.cc \ # $(builddir)/src/messages.pb.h #src_urd_SOURCES = \ # rpc/norns-rpc.h \ # src/ipc-listener.hpp \ # src/backends.cpp \ # src/backends.hpp \ # src/defaults.hpp \ # src/nvml-dax.cpp \ # src/nvml-dax.hpp \ # src/main.cpp \ # src/posix-fs.cpp \ # src/posix-fs.hpp \ # src/settings.cpp \ # src/settings.hpp \ # src/urd.cpp \ # src/urd.hpp \ # src/utils.cpp \ # src/utils.hpp # #nodist_src_urd_SOURCES = \ # src/defaults.cpp \ # src/messages.pb.cc \ # src/messages.pb.h #BUILT_SOURCES = \ # src/defaults.hpp \ # src/messages.pb.cc \ # src/messages.pb.h # #src_urd_CXXFLAGS = \ # @TBB_CFLAGS@ \ # -std=gnu++11 -Wall -Wextra # #src_urd_CPPFLAGS = \ # -DSPDLOG_ENABLE_SYSLOG \ # @BOOST_CPPFLAGS@ \ # -I$(top_srcdir)/include \ # -I$(top_srcdir)/src \ # -I$(top_srcdir)/rpc \ # -I$(top_builddir)/rpc # # #src_urd_LDFLAGS = \ # @TBB_LIBS@ \ # @BOOST_LDFLAGS@ \ # @BOOST_SYSTEM_LIB@ \ # @BOOST_ASIO_LIB@ \ # @BOOST_PROGRAM_OPTIONS_LIB@ \ # -pthread # #src_urd_LDADD = \ # -lboost_system # #$(builddir)/src/defaults.cpp: Makefile # @( echo "/* This file autogenerated by Makefile */"; \ # echo "#include \"defaults.hpp\""; \ # echo ""; \ # echo "namespace defaults {"; \ # echo " const char* progname = \"urd\";"; \ # echo " const bool daemonize = true;"; \ # echo " const char* running_dir = \"/tmp\";"; \ # echo " const char* ipc_sockfile = \"/tmp/urd.socket\";"; \ # echo " const char* daemon_pidfile = \"/tmp/urd.pid\";"; \ # echo " const uint32_t workers_in_pool = std::thread::hardware_concurrency();"; \ # echo " const char* config_file = \"$(sysconfdir)/norns.conf\";"; \ # echo "} // namespace defaults"; \ # ) > $@ # #$(builddir)/src/%.pb.cc %.pb.h: %.proto # $(PROTOC) --proto_path=$(srcdir) --cpp_out=$(builddir) $^
configure.ac +2 −1 Original line number Diff line number Diff line Loading @@ -103,8 +103,9 @@ AC_CHECK_HEADER_STDBOOL AC_CONFIG_FILES([ Makefile etc/Makefile lib/Makefile examples/Makefile include/Makefile lib/Makefile src/Makefile ]) AC_OUTPUT
examples/job_registration.c +40 −17 Original line number Diff line number Diff line Loading @@ -41,14 +41,22 @@ int main(int argc, char* argv[]) { (void) argc; (void) argv; struct norns_cred cred; // create job descriptor from example data // 1. fill in hostnames int num_hosts = 3; const char** hosts = NORNS_PLIST_ALLOC(const char*, num_hosts); int num_hosts1 = 3; const char** hosts1 = NORNS_PLIST_ALLOC(const char*, num_hosts1); for(int i=0; i<num_hosts1; ++i) { hosts1[i] = ex_hosts[i]; } int num_hosts2 = 2; const char** hosts2 = NORNS_PLIST_ALLOC(const char*, num_hosts2); for(int i=0; i<num_hosts; ++i) { hosts[i] = ex_hosts[i]; for(int i=0; i<num_hosts2; ++i) { hosts2[i] = ex_hosts[num_hosts1+i]; } // 2. declare which backends the job is authorized to use Loading @@ -71,28 +79,43 @@ int main(int argc, char* argv[]) { } struct norns_job job = { .jb_hosts = hosts, .jb_nhosts = num_hosts, .jb_hosts = hosts1, .jb_nhosts = num_hosts1, .jb_backends = backends, .jb_nbackends = num_backends }; struct norns_cred cred; int rv; // try to register a duplicate jobid for(int i=0; i<2; ++i) { // register a job with ID 42 if((rv = norns_register_job(&cred, 42, &job)) != NORNS_SUCCESS) { fprintf(stderr, "norns_register_job failed!\n"); fprintf(stderr, "ERROR: norns_register_job failed!\n"); } else { fprintf(stdout, "norns_register_job succeded!\n"); } // update the job description job.jb_hosts = hosts2; job.jb_nhosts = num_hosts2; if((rv = norns_update_job(&cred, 42, &job)) != NORNS_SUCCESS) { fprintf(stderr, "norns_update_job failed!\n"); } else { fprintf(stdout, "norns_update_job succeded!\n"); } // unregister the job if((rv = norns_unregister_job(&cred, 42)) != NORNS_SUCCESS) { fprintf(stderr, "norns_unregister_job failed!\n"); } else { fprintf(stdout, "norns_unregister_job succeded!\n"); } NORNS_PLIST_FREE(hosts); NORNS_PLIST_FREE(hosts1); NORNS_PLIST_FREE(hosts2); NORNS_PLIST_FREE(backends); }
include/Makefile.am 0 → 100644 +34 −0 Original line number Diff line number Diff line # Copyright (C) 2017 Barcelona Supercomputing Center # Centro Nacional de Supercomputacion # # This file is part of the Data Scheduler, a daemon for tracking and managing # requests for asynchronous data transfer in a hierarchical storage environment. # # See AUTHORS file in the top level directory for information # regarding developers and contributors. # # The Data Scheduler is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Data Scheduler is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Data Scheduler. If not, see <http://www.gnu.org/licenses/>. # ACLOCAL_AMFLAGS = -I m4 nornsincludedir=$(includedir)/norns nornsinclude_HEADERS = \ norns/norns.h \ norns/norns_backends.h \ norns/norns_error.h include_HEADERS = \ norns.h
include/norns.h +1 −185 Original line number Diff line number Diff line Loading @@ -21,188 +21,4 @@ * along with Data Scheduler. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __NORNS_LIB_H__ #define __NORNS_LIB_H__ 1 #include <features.h> #include <sys/types.h> #include <stdint.h> #include <assert.h> __BEGIN_DECLS /* Error codes */ #define NORNS_SUCCESS 0 #define NORNS_EBADPARAMS -1 #define NORNS_ENOMEM -2 #define NORNS_ECONNFAILED -3 #define NORNS_ERPCSENDFAILED -4 #define NORNS_ERPCRECVFAILED -5 #define NORNS_EJOBEXISTS -6 typedef uint32_t jobid_t; /* Process credentials */ struct norns_cred { // TODO: to be completed, but at least... pid_t cr_pid; /* PID of the process */ gid_t cr_gid; /* GID of the process */ }; /* Data resource descriptor */ struct norns_resource { const char* r_hostname; /* hostname */ const char* r_path; /* path to "data" (i.e. file or directory) */ uint32_t r_type; /* type of resource */ }; /* I/O task descriptor */ struct norns_iotd { uint32_t ni_tid; /* task identifier */ struct norns_resource ni_src; /* data source */ struct norns_resource ni_dst; /* data destination */ uint32_t ni_type; /* operation to be performed */ struct norns_cred* ni_auth; /* process credentials (NULL if unprivileged) */ /* Internal members. */ pid_t __pid; /* pid of the process that made the request */ uint32_t __jobid; /* job id of the process that made the request (XXX Slurm dependent)*/ }; /* Storage resource types */ #define NORNS_NVML 0x1000 #define NORNS_POSIX 0x1001 /* Task types */ //enum { // NORNS_COPY = 00000000, // NORNS_MOVE = 00000001, // NORNS_LOCAL = 00000010, // NORNS_REMOTE = 00000020 //}; #define NORNS_COPY 00000000 #define NORNS_MOVE 00000001 #define NORNS_LOCAL 00000010 #define NORNS_REMOTE 00000020 /* I/O task status descriptor */ struct norns_iotst { int ni_status; /* current status */ }; /* Status codes */ enum { NORNS_WAITING, NORNS_INPROGRESS, NORNS_COMPLETE }; //void norns_init() __THROW; //int norns_getconf() __THROW; /**************************************************************************/ /* Client API */ /**************************************************************************/ /* Enqueue an asynchronous I/O task */ int norns_transfer(struct norns_iotd* iotdp) __THROW; /* wait for the completion of the task associated to iotdp */ int norns_wait(struct norns_iotd* iotdp) __THROW; /* Try to cancel an asynchronous I/O task associated with iotdp */ ssize_t norns_cancel(struct norns_iotd* iotdp) __THROW; /* Retrieve return status associated with iotdp */ ssize_t norns_return(struct norns_iotd* iotdp, struct norns_iotst* statp) __THROW; /* Retrieve current status associated with iotdp (if iotdp is NULL, retrieve status for all running tasks) */ ssize_t norns_progress(struct norns_iotd* iotdp, struct norns_iotst* statp) __THROW; /* Retrieve error status associated with iotdp */ int norns_error(struct norns_iotd* iotdp) __THROW; /**************************************************************************/ /* Administrative API */ /* (only authenticated processes will be able to successfully call these) */ /**************************************************************************/ #define NORNS_LOCAL_NVML 0x10000000 #define NORNS_REMOTE_NVML 0x10000001 #define NORNS_LUSTRE 0x10000002 /* Storage backend descriptor */ struct norns_backend { int b_type; const char* b_mount; /* mount point */ size_t b_quota; /* backend capacity (in megabytes) allocated to the job */ }; #define NORNS_ALLOC(size) \ ({ \ size_t __n = (size); \ void* __p = malloc(__n); \ assert(__p != NULL); \ __p; \ }) #define NORNS_FREE(p) \ ({ \ free(__p;) \ }) #define NORNS_PLIST_ALLOC(type, size) \ ({ \ size_t __n = (size); \ void** __plist = (void**) malloc(sizeof(type) * (__n + 1)); \ memset(__plist, 0, __n + 1); \ (type*) __plist; \ }) #define NORNS_PLIST_FREE(plist) \ ({ \ free((plist)); \ }) /* Batch job descriptor */ struct norns_job { const char** jb_hosts; /* NULL-terminated list of hostnames participating in the job */ size_t jb_nhosts; /* entries in hostname list */ struct norns_backend** jb_backends; /* NULL-terminated list of storage backends the job will use */ size_t jb_nbackends; /* entries in backend list */ }; /* Send a command to the daemon (e.g. stop accepting new tasks) */ int norns_command(struct norns_cred* auth); /* Register and describe a batch job */ int norns_register_job(struct norns_cred* auth, uint32_t jobid, struct norns_job* job); /* Update the description of an existing batch job */ int norns_update_job(struct norns_cred* auth, uint32_t jobid, struct norns_job* job); /* Remove the description of a batch job */ int norns_remove_job(struct norns_cred* auth, uint32_t jobid, struct norns_job* job); /* Add a process to a registered batch job */ int norns_add_process(struct norns_cred* auth, uint32_t jobid, pid_t pid); /* Remove a process from a registered batch job */ int norns_remove_process(struct norns_cred* auth, uint32_t jobid, pid_t pid); __END_DECLS #endif /* __NORNS_LIB_H__ */ #include "norns/norns.h"