use nix build & meson & zlog
This commit is contained in:
parent
0123623742
commit
346768a144
60 changed files with 13739 additions and 0 deletions
81
src/include/client.h
Normal file
81
src/include/client.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#if !defined(_CLIENT_H_)
|
||||
|
||||
#define _CLIENT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "netio.h"
|
||||
#include "request.h"
|
||||
#include "xce/types.h"
|
||||
#include "xceapi.h"
|
||||
|
||||
typedef int (*xce_request_handler_t)(xce_request_t*);
|
||||
typedef void* xcecli_ctx_t;
|
||||
|
||||
#define N_MAX_MASTERS (3)
|
||||
|
||||
typedef struct {
|
||||
int nmasters;
|
||||
char* masters[N_MAX_MASTERS];
|
||||
int master_ports[N_MAX_MASTERS];
|
||||
char* from;
|
||||
char* key;
|
||||
} xce_client_config_t;
|
||||
|
||||
#define xcecli_jobfinish(ctx, finish) \
|
||||
xcecli_notify_jobfinish(ctx, finish)
|
||||
|
||||
extern int xcecli_ctx_init(xcecli_ctx_t*, xce_client_config_t*);
|
||||
extern void xcecli_ctx_fini(xcecli_ctx_t);
|
||||
extern int xcecli_set_handler(xcecli_ctx_t, xce_request_handler_t);
|
||||
extern int xcecli_start(xcecli_ctx_t);
|
||||
extern int xcecli_stop(xcecli_ctx_t);
|
||||
extern int xcecli_wakeup(xcecli_ctx_t, int);
|
||||
extern int xcecli_hello(xcecli_ctx_t, char*);
|
||||
extern int xcecli_shutdown(xcecli_ctx_t);
|
||||
extern int xcecli_reslist(xcecli_ctx_t, xce_resource_t***);
|
||||
extern int xcecli_join(xcecli_ctx_t, int, hostattrs_t*);
|
||||
extern int xcecli_workerlist(xcecli_ctx_t, xce_worker_t***);
|
||||
extern int xcecli_jobdispatch(xcecli_ctx_t, xce_job_dispatch_t*);
|
||||
extern int xcecli_joblist(xcecli_ctx_t, xce_job_t***);
|
||||
extern int xcecli_clusterconf(xcecli_ctx_t, xce_clusterconf_t**);
|
||||
extern int xcecli_notify_jobfinish(xcecli_ctx_t, xce_jobfinish_t*);
|
||||
extern int xcecli_notify_jobstart(xcecli_ctx_t, job_pidinfo_t*);
|
||||
extern int xcecli_notify_jobfail(xcecli_ctx_t c, job_failinfo_t*);
|
||||
extern int xcecli_notify_jobstop(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_notify_jobresume(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_notify_jobpostdone(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_jobsubmit(xcecli_ctx_t, xce_job_submit_t*,
|
||||
uint64_t*);
|
||||
extern int xcecli_update_resvals(xcecli_ctx_t, int, xce_resval_t**);
|
||||
extern int xcecli_resval(xcecli_ctx_t, char*,
|
||||
char*, xce_resval_t***);
|
||||
extern int xcecli_update_jusage(xcecli_ctx_t, uint64_t, int, int*,
|
||||
int, int*, int, xce_rusage_t**);
|
||||
extern int xcecli_notify(xcecli_ctx_t, xce_notify_data_t*);
|
||||
extern int xcecli_jobctrl(xcecli_ctx_t, xce_jobctrl_t*);
|
||||
extern int xcecli_notify_jobchkpt(xcecli_ctx_t, uint64_t, char*);
|
||||
extern int xcecli_queuectrl(xcecli_ctx_t, xce_queuectrl_t*);
|
||||
extern int xcecli_runtask(xcecli_ctx_t, xce_taskrun_t*);
|
||||
extern int xcecli_notify_taskstart(xcecli_ctx_t, xce_task_pidinfo_t*);
|
||||
extern int xcecli_notify_taskfail(xcecli_ctx_t, xce_task_failinfo_t*);
|
||||
extern int xcecli_notify_taskfinish(xcecli_ctx_t, xce_task_finish_t*);
|
||||
extern endpoint_t* xcecli_get_my_endpoint(xcecli_ctx_t);
|
||||
extern xce_peerinfo_t* xcecli_get_myinfo(xcecli_ctx_t);
|
||||
extern void xcecli_block_tasks(xcecli_ctx_t);
|
||||
extern void xcecli_unblock_tasks(xcecli_ctx_t);
|
||||
|
||||
#define xcecli_free_ress(nres, ress) \
|
||||
xce_free_ress(nres, ress)
|
||||
#define xcecli_free_workers(nworkers, workers) \
|
||||
xce_free_workers(nworkers, workers)
|
||||
#define xcecli_free_jobs(njobs, jobs) \
|
||||
xce_free_jobs(njobs, jobs)
|
||||
#define xcecli_free_queues(nqueues, queues) \
|
||||
xce_free_queues(nqueues, queues)
|
||||
#define xcecli_free_groups(ngroups, groups) \
|
||||
xce_free_groups(ngroups, groups)
|
||||
#define xcecli_free_clusterconf(conf) \
|
||||
xce_free_clusterconf(conf)
|
||||
|
||||
#endif
|
||||
58
src/include/clusterconfig.h
Normal file
58
src/include/clusterconfig.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#if !defined(_CLUSTERCONFIG_H_)
|
||||
|
||||
#define _CLUSTERCONFIG_H_ 1
|
||||
|
||||
#include "xce/types.h"
|
||||
|
||||
typedef struct {
|
||||
int nhash_slots;
|
||||
int delta;
|
||||
} hash_zarray_config_t;
|
||||
|
||||
typedef hash_zarray_config_t jobmgr_config_t;
|
||||
|
||||
typedef hash_zarray_config_t workermgr_config_t;
|
||||
typedef hash_zarray_config_t qmgr_config_t;
|
||||
|
||||
typedef struct {
|
||||
int nhash_slots;
|
||||
int delta;
|
||||
int inst_delta;
|
||||
} resmgr_config_t;
|
||||
|
||||
typedef hash_zarray_config_t xstrings_config_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
char* host;
|
||||
int port;
|
||||
} master_candidate_t;
|
||||
|
||||
typedef struct {
|
||||
char* clustername;
|
||||
int port;
|
||||
int ncandidates;
|
||||
master_candidate_t** candidates;
|
||||
int heartbeat_interval;
|
||||
int inactive_heartbeat_count;
|
||||
int fetch_job_interval;
|
||||
int netio_timeout;
|
||||
int vcpus;
|
||||
int nres;
|
||||
xce_resource_t** resources;
|
||||
int nqueues;
|
||||
xce_queue_t** queues;
|
||||
int nugroups;
|
||||
xce_group_t** ugroups;
|
||||
int nhgroups;
|
||||
xce_group_t** hgroups;
|
||||
int nhconfigs;
|
||||
xce_hostconfig_t** hconfigs;
|
||||
jobmgr_config_t* jobmgr;
|
||||
workermgr_config_t* workermgr;
|
||||
qmgr_config_t* qmgr;
|
||||
resmgr_config_t* resmgr;
|
||||
xstrings_config_t* xstrings;
|
||||
} cluster_config_t;
|
||||
|
||||
#endif
|
||||
20
src/include/config.h
Normal file
20
src/include/config.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#if !defined(_CONFIG_H_)
|
||||
|
||||
#define _CONFIG_H_
|
||||
|
||||
#define BUG_EMAIL "rshen@shenrs.eu"
|
||||
#define XCE_MAXNAME_LEN (64)
|
||||
#define XCE_MAXHOSTNAME_LEN (256) /* hostname suggest to 256 */
|
||||
#define XCE_MAXDESC_LEN (4096) /* enlarge to 4096 */
|
||||
#define XCE_MAXKEY_LEN (256)
|
||||
#define XCE_MAXMODEL_LEN (32)
|
||||
#define XCE_MAXTYPE_LEN (32)
|
||||
|
||||
#define XCE_WORKER_HTAB_SIZE (673)
|
||||
#define XCE_JOB_HTAB_SIZE (5009)
|
||||
|
||||
#define XCE_MAXPATH_LEN (4096) /* enlarge to 4096 */
|
||||
#define XCE_MAXCMD_LEN (4096)
|
||||
#define XCE_MAX_ERRMSG_LEN (4096)
|
||||
|
||||
#endif
|
||||
28
src/include/dataq.h
Normal file
28
src/include/dataq.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#if !defined(_DATAQ_H_)
|
||||
|
||||
#define _DATAQ_H_ 1
|
||||
|
||||
#include "mylock.h"
|
||||
|
||||
typedef struct _data_item {
|
||||
struct _data_item* next;
|
||||
} data_item_t;
|
||||
|
||||
typedef int (*data_item_match_fn_t)(data_item_t*);
|
||||
typedef void (*data_item_killer_t)(data_item_t*);
|
||||
|
||||
typedef struct {
|
||||
data_item_t* head;
|
||||
data_item_t* tail;
|
||||
data_item_killer_t killer;
|
||||
mylock_t lock;
|
||||
} dataq_t;
|
||||
|
||||
#define DATAQ_EMPTY(q) ((q)->head == NULL)
|
||||
|
||||
extern int dataq_init(dataq_t*, data_item_killer_t);
|
||||
extern data_item_t* dataq_deq(dataq_t*, data_item_match_fn_t);
|
||||
extern int dataq_enq(dataq_t*, data_item_t*);
|
||||
extern void dataq_fini(dataq_t*);
|
||||
|
||||
#endif
|
||||
30
src/include/hook.h
Normal file
30
src/include/hook.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#if !defined(__HOOK_H__)
|
||||
|
||||
#define __HOOK_H__ 1
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "xlist.h"
|
||||
|
||||
#define HOOK_BEFORE_EVENT (0)
|
||||
#define HOOK_AFTER_EVENT (1)
|
||||
|
||||
typedef int (*hook_fn_t)(int, int, int, void*, va_list);
|
||||
typedef struct {
|
||||
hook_fn_t fn;
|
||||
void* data;
|
||||
} hook_item_t;
|
||||
|
||||
typedef struct {
|
||||
int maxtypes;
|
||||
xlist_t* hooks;
|
||||
} hooksys_t;
|
||||
|
||||
extern int xce_hook_init(hooksys_t*, int);
|
||||
extern int xce_add_hook(hooksys_t*, int,
|
||||
hook_fn_t, void*);
|
||||
extern int xce_run_hooks(hooksys_t*, int, int, int, ...);
|
||||
extern void xce_hook_fini(hooksys_t*);
|
||||
|
||||
#endif
|
||||
44
src/include/htab.h
Normal file
44
src/include/htab.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#if !defined(_HTAB_H_)
|
||||
|
||||
#define _HTAB_H_ 1
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mylock.h"
|
||||
|
||||
typedef unsigned int (*hash_key_hash_fn_t)(void*);
|
||||
typedef int (*hash_key_cmp_fn_t)(void*, void*);
|
||||
typedef void* (*hash_key_copy_fn_t)(void*);
|
||||
typedef void (*hash_key_free_fn_t)(void*);
|
||||
|
||||
typedef struct {
|
||||
hash_key_hash_fn_t hash;
|
||||
hash_key_cmp_fn_t cmp;
|
||||
hash_key_copy_fn_t copy;
|
||||
hash_key_free_fn_t free;
|
||||
} hash_key_fn_t;
|
||||
|
||||
typedef struct _hent {
|
||||
struct _hent* next;
|
||||
void* key;
|
||||
int64_t data;
|
||||
} hent_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
int nslots;
|
||||
hash_key_fn_t fn;
|
||||
hent_t** slots;
|
||||
} htab_t;
|
||||
|
||||
extern hash_key_fn_t string_hash_key;
|
||||
extern hash_key_fn_t int_hash_key;
|
||||
|
||||
extern int ht_init(htab_t*, int,
|
||||
hash_key_fn_t);
|
||||
extern void ht_fini(htab_t*);
|
||||
extern hent_t* ht_get(htab_t*, void*);
|
||||
extern hent_t* ht_add(htab_t*, void*);
|
||||
extern int ht_del(htab_t*, void*);
|
||||
|
||||
#endif
|
||||
26
src/include/kvmgr.h
Normal file
26
src/include/kvmgr.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#if !defined(__KVMGR_H__)
|
||||
|
||||
#define __KVMGR_H__ 1
|
||||
|
||||
#include "htab.h"
|
||||
#include "mylock.h"
|
||||
#include "xlist.h"
|
||||
#include "zarray.h"
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
htab_t htab;
|
||||
zarray_t data;
|
||||
} kvmgr_t;
|
||||
|
||||
extern int kvmgr_init(kvmgr_t*, hash_key_fn_t,
|
||||
int, int,
|
||||
zarray_item_killer_t);
|
||||
extern void kvmgr_fini(kvmgr_t*);
|
||||
extern void* kvmgr_lock(kvmgr_t*, void*, int);
|
||||
extern int32_t kvmgr_add(kvmgr_t*, void*, void*);
|
||||
extern void kvmgr_del(kvmgr_t*, void*);
|
||||
extern int kvmgr_publish(kvmgr_t*, xlist_action_fn_t, void*);
|
||||
extern int kvmgr_iter(kvmgr_t*, xlist_t*, void*);
|
||||
|
||||
#endif
|
||||
38
src/include/mylock.h
Normal file
38
src/include/mylock.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#if !defined(_MYLOCK_H_)
|
||||
|
||||
#define _MYLOCK_H_ 1
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
typedef pthread_mutex_t mylock_t;
|
||||
typedef pthread_rwlock_t my_rwlock_t;
|
||||
|
||||
typedef struct {
|
||||
int ncap;
|
||||
int head;
|
||||
int len;
|
||||
int isize;
|
||||
void* data;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t condget;
|
||||
pthread_cond_t condput;
|
||||
} cbuf_t;
|
||||
|
||||
extern int mylock_init(mylock_t*);
|
||||
extern void mylock_fini(mylock_t*);
|
||||
extern int mylock_try(mylock_t*);
|
||||
extern int mylock_lock(mylock_t*);
|
||||
extern int mylock_unlock(mylock_t*);
|
||||
|
||||
extern int my_rwlock_init(my_rwlock_t*);
|
||||
extern void my_rwlock_fini(my_rwlock_t*);
|
||||
extern int my_rwlock_rlock(my_rwlock_t*);
|
||||
extern int my_rwlock_wlock(my_rwlock_t*);
|
||||
extern int my_rwlock_unlock(my_rwlock_t*);
|
||||
|
||||
extern int cbuf_init(cbuf_t*, int, int);
|
||||
extern void cbuf_fini(cbuf_t*);
|
||||
extern int cbuf_put(cbuf_t*, void*);
|
||||
extern int cbuf_tryput(cbuf_t*, void*);
|
||||
extern int cbuf_get(cbuf_t*, void*);
|
||||
#endif
|
||||
73
src/include/netio.h
Normal file
73
src/include/netio.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#if !defined(_NETIO_H_)
|
||||
|
||||
#define _NETIO_H_ 1
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "dataq.h"
|
||||
#include "mylock.h"
|
||||
|
||||
typedef int (*msghandler_t)(struct epoll_event*);
|
||||
|
||||
#define IO_MON_INPUT (0x01)
|
||||
#define IO_MON_OUTPUT (0x02)
|
||||
|
||||
typedef struct {
|
||||
uint16_t sz;
|
||||
char* data;
|
||||
} io_packet_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
int epoll_fd;
|
||||
struct epoll_event ev;
|
||||
pthread_t worker;
|
||||
} iomgr_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
iomgr_t* iomgr;
|
||||
int fd;
|
||||
int idx;
|
||||
int flags;
|
||||
unsigned int busy : 1;
|
||||
unsigned int needfree : 1;
|
||||
uint32_t refcount;
|
||||
dataq_t outq;
|
||||
uint64_t seq;
|
||||
msghandler_t handler;
|
||||
void* owner;
|
||||
void* data;
|
||||
} endpoint_t;
|
||||
|
||||
extern int netio_write(int, char*, int);
|
||||
extern int netio_read(int, char*, int);
|
||||
extern int write_packet(int, io_packet_t*);
|
||||
extern int alloc_packet(io_packet_t*);
|
||||
extern int read_packet(int, io_packet_t*);
|
||||
extern void free_packet(io_packet_t*);
|
||||
|
||||
extern endpoint_t* endpoint_get(void);
|
||||
extern int endpoint_init(endpoint_t*, int, int, int, int);
|
||||
extern int endpoint_connect(endpoint_t*, char*, int);
|
||||
extern int endpoint_accept(endpoint_t*, endpoint_t*);
|
||||
extern int endpoint_set_handler(endpoint_t*, msghandler_t, void*);
|
||||
extern int endpoint_enq(endpoint_t*, data_item_t*);
|
||||
extern data_item_t* endpoint_deq(endpoint_t*);
|
||||
extern endpoint_t* endpoint_ref(endpoint_t*);
|
||||
extern void endpoint_deref(endpoint_t*);
|
||||
extern uint64_t endpoint_getseq(endpoint_t*);
|
||||
extern void endpoint_block_tasks(endpoint_t*);
|
||||
extern void endpoint_unblock_tasks(endpoint_t*);
|
||||
extern int endpoint_is_task_blocked(endpoint_t*);
|
||||
|
||||
extern int iomgr_init(iomgr_t*);
|
||||
extern int iomgr_monitor(iomgr_t*, endpoint_t*);
|
||||
extern int iomgr_unmonitor(iomgr_t*, endpoint_t*);
|
||||
extern int iomgr_start(iomgr_t*);
|
||||
extern int iomgr_fini(iomgr_t*);
|
||||
extern int iomgr_stop(iomgr_t*);
|
||||
#endif
|
||||
78
src/include/objmgr.h
Normal file
78
src/include/objmgr.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#if !defined(__OBJMGR_H__)
|
||||
|
||||
#define __OBJMGR_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "htab.h"
|
||||
#include "mylock.h"
|
||||
#include "zarray.h"
|
||||
|
||||
#define OBJ_MAGIC (0x4a424f58)
|
||||
|
||||
#define OBJREF_NOP (0) /* ref obj without lock, \
|
||||
* just keep object alive */
|
||||
#define OBJREF_READ (1) /* ref obj with read lock */
|
||||
#define OBJREF_UPDATE (2) /* ref obj with write lock */
|
||||
|
||||
typedef void* (*obj_create_fn_t)(void*, void*,
|
||||
va_list);
|
||||
typedef void (*obj_fini_fn_t)(void*);
|
||||
typedef void (*objtype_fini_fn_t)(void*);
|
||||
|
||||
typedef struct {
|
||||
char* type; /* name of type */
|
||||
mylock_t lock;
|
||||
obj_create_fn_t fn_create; /* function to initialize object */
|
||||
obj_fini_fn_t fn_fini; /* function to finalize obj */
|
||||
objtype_fini_fn_t fn_type_fini; /* function to finalize typeinfo */
|
||||
void* typedata; /* extra information for type */
|
||||
} objtype_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
uint32_t nref;
|
||||
my_rwlock_t rwlock;
|
||||
mylock_t lock;
|
||||
objtype_t* type;
|
||||
int32_t exdata;
|
||||
uint32_t nread : 28;
|
||||
uint32_t nwrite : 4;
|
||||
} myobj_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
htab_t names;
|
||||
zarray_t types;
|
||||
} objmgr_t;
|
||||
|
||||
#define MYOBJ_TO_OBJ(type, myobj) \
|
||||
((type)(((char*)myobj) + sizeof(myobj_t)))
|
||||
|
||||
#define TO_MYOBJ(obj) \
|
||||
((myobj_t*)(((char*)obj) - sizeof(myobj_t)))
|
||||
|
||||
#define DEREF_OBJ(obj) \
|
||||
if ((obj) != NULL) { \
|
||||
obj_deref(obj); \
|
||||
(obj) = NULL; \
|
||||
}
|
||||
|
||||
extern int objmgr_init(objmgr_t*);
|
||||
extern void objmgr_fini(objmgr_t*);
|
||||
extern int objmgr_register(objmgr_t*, objtype_t*);
|
||||
extern int obj_init(objmgr_t*, objtype_t*, int32_t, myobj_t*);
|
||||
extern void* create_obj_by_typeid(objmgr_t*, int, ...);
|
||||
extern void* create_obj_by_typename(objmgr_t*, char*, ...);
|
||||
extern void* obj_ref(void*, int);
|
||||
extern void obj_deref(void*);
|
||||
extern int typeid_of_name(objmgr_t*, char*);
|
||||
extern objmgr_t* objmgr_get_default();
|
||||
extern int objmgr_set_default(objmgr_t*);
|
||||
extern myobj_t* obj_alloc(size_t);
|
||||
|
||||
#endif
|
||||
9
src/include/objs.h
Normal file
9
src/include/objs.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#if !defined(_OBJS_H_)
|
||||
|
||||
#define _OBJS_H_ 1
|
||||
|
||||
#include "xce/types.h"
|
||||
|
||||
job_pidinfo_t *new_job_pidinfo(job_pidinfo_t *);
|
||||
|
||||
#endif
|
||||
82
src/include/request.h
Normal file
82
src/include/request.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#if !defined(_REQUEST_H_)
|
||||
|
||||
#define _REQUEST_H_ 1
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "netio.h"
|
||||
#include "typemap.h"
|
||||
#include "utils.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
typedef struct {
|
||||
int wait;
|
||||
} reqbar_t;
|
||||
|
||||
typedef struct {
|
||||
data_item_t link;
|
||||
endpoint_t* ep;
|
||||
xce_peerinfo_t* from;
|
||||
io_packet_t pkt;
|
||||
struct capn c;
|
||||
struct Request rq;
|
||||
uint32_t nrefs;
|
||||
} ioctx_t;
|
||||
|
||||
#define ITPTR_TO_IOCTX(p) \
|
||||
((ioctx_t*)(((char*)p) - offsetof(ioctx_t, link)))
|
||||
|
||||
typedef int (*xce_check_fn_t)(void*);
|
||||
|
||||
extern ioctx_t* ioctx_alloc(endpoint_t*, xce_peerinfo_t*);
|
||||
extern int ioctx_ref(ioctx_t*);
|
||||
extern void ioctx_deref(ioctx_t*, int);
|
||||
extern int ioctx_flush(ioctx_t*, int);
|
||||
extern int ioctx_encode(ioctx_t*, xce_request_t*);
|
||||
extern int ioctx_decode(ioctx_t*, xce_request_t*);
|
||||
|
||||
extern int xce_reply(endpoint_t*, xce_peerinfo_t*, xce_reply_t*);
|
||||
extern int xce_hello_req(ioctx_t*, char*);
|
||||
extern int xce_nop_req(ioctx_t*);
|
||||
extern int xce_shutdown_req(ioctx_t*);
|
||||
extern void init_reply_by_req(xce_reply_t*, xce_request_t*);
|
||||
extern int xce_join_req(ioctx_t*, int, hostattrs_t*);
|
||||
extern int xce_pushconfig_req(endpoint_t*,
|
||||
xce_peerinfo_t*,
|
||||
xce_configdata_t*);
|
||||
extern int xce_push_data_req(endpoint_t*, xce_peerinfo_t*,
|
||||
xce_data_t*, xce_check_fn_t,
|
||||
void*, int);
|
||||
|
||||
extern int xce_workerlist_req(ioctx_t*, xce_peerinfo_t*);
|
||||
extern int xce_reply_workerlist(endpoint_t*, uint64_t, int,
|
||||
xce_peerinfo_t*, xce_workerlist_t*);
|
||||
extern int xce_jobdispatch_req(ioctx_t*, xce_job_dispatch_t*);
|
||||
extern int xce_jobsubmit_req(ioctx_t*, xce_job_submit_t*);
|
||||
extern int xce_reply_jobdispatch(endpoint_t*, uint64_t, int32_t,
|
||||
xce_peerinfo_t*);
|
||||
extern int xce_reply_jobid(endpoint_t*, int,
|
||||
uint64_t, uint64_t,
|
||||
xce_peerinfo_t*);
|
||||
extern int xce_joblist_req(ioctx_t*, xce_peerinfo_t*);
|
||||
extern int xce_reply_joblist(endpoint_t*, uint64_t, int,
|
||||
xce_peerinfo_t*, xce_job_list_t*);
|
||||
extern int xce_startjob_req(ioctx_t*, xce_job_exec_t*);
|
||||
extern int xce_clusterconf_req(ioctx_t*);
|
||||
extern int xce_reply_clusterconf(endpoint_t*, uint64_t, int,
|
||||
xce_peerinfo_t*,
|
||||
xce_clusterconf_t*);
|
||||
extern int xce_get_req(ioctx_t*, xce_get_t*);
|
||||
extern int xce_reply_get(endpoint_t*, xce_peerinfo_t*,
|
||||
xce_reply_t*, xce_check_fn_t,
|
||||
void*, int);
|
||||
extern int xce_notify_req(ioctx_t*, xce_notify_data_t*);
|
||||
extern int extract_data(dataset_t*, xce_data_t*);
|
||||
extern int xce_update_req(ioctx_t*, xce_update_data_t*);
|
||||
extern int xce_jobctrl_req(ioctx_t*, xce_jobctrl_t*);
|
||||
extern int xce_queuectrl_req(ioctx_t*, xce_queuectrl_t*);
|
||||
extern int xce_runtask_req(ioctx_t* , xce_taskrun_t *) ;
|
||||
|
||||
#endif
|
||||
192
src/include/typemap.h
Normal file
192
src/include/typemap.h
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
#if !defined(_TYPEMAP_H_)
|
||||
|
||||
#define _TYPEMAP_H_ 1
|
||||
#include <stdint.h>
|
||||
|
||||
#include "xce/types.h"
|
||||
|
||||
typedef struct {
|
||||
char* resname;
|
||||
char* hostname;
|
||||
} xce_reskey_t;
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
union {
|
||||
uint64_t jobid;
|
||||
char* wname;
|
||||
xce_reskey_t* reskey;
|
||||
} condition;
|
||||
} xce_match_t;
|
||||
|
||||
typedef struct {
|
||||
int table;
|
||||
int nrows;
|
||||
void* rows;
|
||||
} dataset_t;
|
||||
|
||||
typedef struct {
|
||||
int role;
|
||||
int data_which;
|
||||
union {
|
||||
hostattrs_t* attrs;
|
||||
} data;
|
||||
} xce_joindata_t;
|
||||
|
||||
typedef struct {
|
||||
char* clustername;
|
||||
int n_confvars;
|
||||
xce_config_t** confvars;
|
||||
int n_resources;
|
||||
xce_resource_t** resources;
|
||||
int n_queues;
|
||||
xce_queue_t** queues;
|
||||
int n_ugroups;
|
||||
xce_group_t** ugroups;
|
||||
int n_hgroups;
|
||||
xce_group_t** hgroups;
|
||||
int nresvals;
|
||||
xce_val_with_idx_t** resvals;
|
||||
} xce_conf4sched_t;
|
||||
|
||||
typedef struct {
|
||||
char* clustername;
|
||||
int n_confvars;
|
||||
xce_config_t** confvars;
|
||||
} xce_conf4worker_t;
|
||||
|
||||
typedef struct {
|
||||
int data_which;
|
||||
union {
|
||||
xce_conf4sched_t* conf4sched;
|
||||
xce_conf4worker_t* conf4worker;
|
||||
} data;
|
||||
} xce_configdata_t;
|
||||
|
||||
typedef struct {
|
||||
int n_total;
|
||||
int pos;
|
||||
int count;
|
||||
xce_job_t** jobs;
|
||||
} xce_jobs_data_t;
|
||||
|
||||
typedef struct {
|
||||
int n_total;
|
||||
int pos;
|
||||
int count;
|
||||
xce_worker_t** workers;
|
||||
} xce_workers_data_t;
|
||||
|
||||
typedef struct {
|
||||
int n_total;
|
||||
int pos;
|
||||
int count;
|
||||
xce_resource_t** resources;
|
||||
} xce_resource_data_t;
|
||||
|
||||
typedef struct {
|
||||
int n_total;
|
||||
int pos;
|
||||
int count;
|
||||
xce_resval_t** vals;
|
||||
} xce_resval_data_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_resval_t** vals;
|
||||
} xce_resval_list_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
int npids;
|
||||
int* pids;
|
||||
int npgids;
|
||||
int* pgids;
|
||||
int count;
|
||||
xce_rusage_t** usages;
|
||||
} xce_job_rusages_t;
|
||||
|
||||
typedef struct {
|
||||
int table;
|
||||
union {
|
||||
xce_jobs_data_t* jobs;
|
||||
xce_workers_data_t* workers;
|
||||
xce_resource_data_t* resources;
|
||||
xce_resval_data_t* resvals;
|
||||
} data;
|
||||
} xce_data_t;
|
||||
|
||||
typedef struct {
|
||||
int table;
|
||||
xce_match_t* condition;
|
||||
} xce_get_t;
|
||||
|
||||
typedef struct {
|
||||
int event;
|
||||
union {
|
||||
job_pidinfo_t* pidinfo;
|
||||
job_failinfo_t* failinfo;
|
||||
job_failinfo_t* dispatchfail;
|
||||
xce_jobfinish_t* finishinfo;
|
||||
uint64_t sched_start_job;
|
||||
uint64_t sched_exit_job;
|
||||
uint64_t sched_fail_job;
|
||||
xce_job_t* sched_update_job;
|
||||
xce_resval_list_t* sched_update_resvals;
|
||||
uint64_t stopped_job;
|
||||
uint64_t resumed_job;
|
||||
xce_ckptinfo_t* ckptinfo;
|
||||
xce_queue_t* sched_update_queue;
|
||||
xce_task_pidinfo_t* taskinfo;
|
||||
xce_task_failinfo_t* taskfailinfo;
|
||||
xce_task_finish_t* taskfinish;
|
||||
uint64_t pdone_job;
|
||||
} data;
|
||||
} xce_notify_data_t;
|
||||
|
||||
typedef struct {
|
||||
int table;
|
||||
union {
|
||||
xce_resval_list_t* resvals;
|
||||
xce_job_rusages_t* jobrusages;
|
||||
} data;
|
||||
} xce_update_data_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t seq;
|
||||
uint32_t opcode;
|
||||
int32_t status;
|
||||
int data_which;
|
||||
union {
|
||||
char* debugmsg;
|
||||
uint64_t jobid;
|
||||
xce_data_t* getdata;
|
||||
xce_clusterconf_t* clusterconf;
|
||||
} data;
|
||||
} xce_reply_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t opcode;
|
||||
uint64_t seq;
|
||||
xce_peerinfo_t* from;
|
||||
int body_which;
|
||||
union {
|
||||
xce_reply_t* replymsg;
|
||||
char* hellomsg;
|
||||
xce_joindata_t* joinmsg;
|
||||
xce_configdata_t* configpushmsg;
|
||||
xce_data_t* pushmsg;
|
||||
xce_get_t* getmsg;
|
||||
dataset_t* datamsg;
|
||||
xce_job_dispatch_t* dispatchmsg;
|
||||
xce_job_exec_t* jobstartmsg;
|
||||
xce_notify_data_t* notifymsg;
|
||||
xce_job_submit_t* jobsubmsg;
|
||||
xce_update_data_t* updatemsg;
|
||||
xce_jobctrl_t* jobctrlmsg;
|
||||
xce_queuectrl_t* queuectrlmsg;
|
||||
xce_taskrun_t* runtaskmsg;
|
||||
} body;
|
||||
} xce_request_t;
|
||||
|
||||
#endif
|
||||
94
src/include/utils.h
Normal file
94
src/include/utils.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#if !defined(_UTILS_H_)
|
||||
|
||||
#define _UTILS_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <capnp_c.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "controller.capnp.h"
|
||||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
#define xce_use(x) (void)(x)
|
||||
|
||||
#define float_near_zero (0.000001)
|
||||
|
||||
#define float_equal(a, b) (fabs((a) - (b)) < float_near_zero)
|
||||
|
||||
#define STR(x) _STR(x)
|
||||
#define _STR(x) #x
|
||||
|
||||
#define MK_VERSION(ver, commit) ver commit
|
||||
|
||||
#ifndef FREEUP
|
||||
#define FREEUP(p) \
|
||||
if ((p) != NULL) { \
|
||||
free(p); \
|
||||
(p) = NULL; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) \
|
||||
((void*)(((char*)p) + (delta)))
|
||||
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) \
|
||||
((void*)(((char*)p) + (delta)))
|
||||
|
||||
/* move the owner ship of pointer from src to dst */
|
||||
#define MOVE_PTR(dst, src) \
|
||||
do { \
|
||||
(dst) = (src); \
|
||||
(src) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define NULLSTR(p) (((p) == NULL) || (strlen(p) == 0))
|
||||
|
||||
#define SET_ERROR(code) \
|
||||
do { \
|
||||
set_error((char*)__FILE__, \
|
||||
(char*)__func__, \
|
||||
__LINE__, \
|
||||
(code)); \
|
||||
} while (0)
|
||||
|
||||
#define PERROR(s) xce_perror(s)
|
||||
|
||||
typedef struct {
|
||||
char* file;
|
||||
char* func;
|
||||
int line;
|
||||
int code;
|
||||
} ectx_t;
|
||||
|
||||
#define TRACE(...)
|
||||
#define WARN(...)
|
||||
|
||||
extern capn_text chars_to_text(const char*);
|
||||
extern int parse_argv(char*, char***);
|
||||
extern void free_argv(char**, int);
|
||||
extern void freeup_kvs(int, xce_kv_t*);
|
||||
extern int mylog_init(char*, char*, char*, int, int);
|
||||
extern void mylog_fini(void);
|
||||
extern int mylog_setlevel(char*);
|
||||
extern void set_error(char*, char*, int, int);
|
||||
extern ectx_t* get_ectx(void);
|
||||
extern int xce_vprintf(const char*, va_list);
|
||||
extern int xce_strerror_r(int, char*, size_t);
|
||||
extern void xce_perror(const char*);
|
||||
extern char* frame_symbol(int);
|
||||
extern int copy_int_list(int**, int*, int);
|
||||
extern int copy_strlist(xce_strlist_t*, xce_strlist_t);
|
||||
extern void free_timewindow_config(xce_timewindow_config_t*);
|
||||
extern xce_timewindow_config_t* dup_timewindow_config(xce_timewindow_config_t*);
|
||||
extern void free_resource_thresholds(xce_res_threshold_t**, int);
|
||||
extern xce_res_threshold_t** dup_resource_thresholds(xce_res_threshold_t**, int);
|
||||
extern void free_resval_with_idx_list(xce_val_with_idx_t***, int);
|
||||
extern void free_strlist(xce_strlist_t*);
|
||||
|
||||
#endif
|
||||
61
src/include/vtaskmgr.h
Normal file
61
src/include/vtaskmgr.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#if !defined(_VTASKMGR_H_)
|
||||
|
||||
#define _VTASKMGR_H_ 1
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "dataq.h"
|
||||
#include "mylock.h"
|
||||
#include "netio.h"
|
||||
#include "request.h"
|
||||
|
||||
typedef int (*vtask_func_t)(void*);
|
||||
|
||||
typedef struct {
|
||||
void* owner;
|
||||
ioctx_t ctx;
|
||||
int vcpu;
|
||||
vtask_func_t entry;
|
||||
} vtask_t;
|
||||
|
||||
#define ITPTR_TO_VTASK(p) \
|
||||
((vtask_t*)(((char*)p) - offsetof(ioctx_t, link) - offsetof(vtask_t, ctx)))
|
||||
|
||||
typedef enum {
|
||||
VCPU_IDLE = 0,
|
||||
VCPU_BUSY,
|
||||
VCPU_ERR
|
||||
} vcpu_state_t;
|
||||
|
||||
typedef struct {
|
||||
int cpuid;
|
||||
vcpu_state_t state;
|
||||
void* owner;
|
||||
cbuf_t wbuf;
|
||||
vtask_t* task;
|
||||
pthread_t vcpu;
|
||||
} vcpu_t;
|
||||
|
||||
typedef struct {
|
||||
int n_vcpus;
|
||||
pthread_t dispatcher;
|
||||
vcpu_t* vcpus;
|
||||
cbuf_t wbuf;
|
||||
cbuf_t wtbuf; /* used to wake up vtaskmgr to check tasks */
|
||||
dataq_t taskq;
|
||||
} vtaskmgr_t;
|
||||
|
||||
extern vtask_t* vtask_alloc();
|
||||
extern int vtask_init(vtask_t*, vtask_func_t, endpoint_t*);
|
||||
extern void vtask_fini(vtask_t*);
|
||||
|
||||
extern int vtask_enq(vtaskmgr_t*, vtask_t*);
|
||||
|
||||
extern int vtaskmgr_init(vtaskmgr_t*, int);
|
||||
extern int vtaskmgr_start(vtaskmgr_t*);
|
||||
extern void vtaskmgr_fini(vtaskmgr_t*);
|
||||
extern void vtaskmgr_wait(vtaskmgr_t *);
|
||||
extern void vtaskmgr_wakeup(vtaskmgr_t *);
|
||||
|
||||
#endif
|
||||
168
src/include/xce/cluster_def.h
Normal file
168
src/include/xce/cluster_def.h
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#ifndef XCE_CLUSTER_DEF_H
|
||||
#define XCE_CLUSTER_DEF_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hook.h"
|
||||
#include "htab.h"
|
||||
#include "kvmgr.h"
|
||||
#include "myconf.h"
|
||||
#include "mylock.h"
|
||||
#include "netio.h"
|
||||
#include "objmgr.h"
|
||||
#include "vtaskmgr.h"
|
||||
#include "xce/types.h"
|
||||
#include "xlist.h"
|
||||
#include "zarray.h"
|
||||
|
||||
#define N_CONTROLLER_MAX (16)
|
||||
|
||||
enum {
|
||||
XCE_CONTROLLER_HOOK_JOB = 0,
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
XCE_CONTROLLER_HOOK_SCHEDULER,
|
||||
XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
XCE_CONTROLLER_HOOK_CTRL_REQ,
|
||||
XCE_CONTROLLER_HOOK_QUEUE,
|
||||
XCE_CONTROLLER_HOOK_USERGROUP,
|
||||
XCE_CONTROLLER_HOOK_HOSTGROUP,
|
||||
XCE_CONTROLLER_HOOK_MAX /* keep this as the max */
|
||||
};
|
||||
|
||||
enum {
|
||||
HOOK_DETAIL_JOB_NEW = 0,
|
||||
HOOK_DETAIL_JOB_START,
|
||||
HOOK_DETAIL_JOB_EXIT,
|
||||
HOOK_DETAIL_JOB_FAIL,
|
||||
HOOK_DETAIL_JOB_UPDATE,
|
||||
HOOK_DETAIL_JOB_CKPT,
|
||||
HOOK_DETAIL_WORKER_JOIN,
|
||||
HOOK_DETAIL_WORKER_DEAD,
|
||||
HOOK_DETAIL_WORKER_UPDATE,
|
||||
HOOK_DETAIL_SCHEDULER_JOIN,
|
||||
HOOK_DETAIL_SCHEDULER_DEAD,
|
||||
HOOK_DETAIL_CLUSTER_INIT,
|
||||
HOOK_DETAIL_DB_INIT,
|
||||
HOOK_DETAIL_CLUSTER_SHUTDOWN,
|
||||
HOOK_DETAIL_DB_SHUTDOWN,
|
||||
HOOK_DETAIL_RESOURCE_UPDATE,
|
||||
HOOK_DETAIL_RESOURCE_LOC_UPDATE,
|
||||
HOOK_DETAIL_CTRL_REQ_FINISH,
|
||||
HOOK_DETAIL_QUEUE_UPDATE,
|
||||
HOOK_DETAIL_USERGROUP_UPDATE,
|
||||
HOOK_DETAIL_HOSTGROUP_UPDATE
|
||||
};
|
||||
|
||||
#define XCE_NS_CONFIG (0)
|
||||
#define XCE_NS_UGROUP (1)
|
||||
#define XCE_NS_HGROUP (2)
|
||||
#define XCE_NS_MAX (2)
|
||||
|
||||
typedef struct {
|
||||
int role;
|
||||
union {
|
||||
int idx;
|
||||
} u;
|
||||
} ep_private_t;
|
||||
|
||||
typedef struct {
|
||||
endpoint_t* ep;
|
||||
} controller_t;
|
||||
|
||||
typedef struct {
|
||||
} metrics_t;
|
||||
|
||||
typedef struct {
|
||||
xce_queue_t queue;
|
||||
} queue_t;
|
||||
|
||||
typedef struct {
|
||||
xce_job_t job;
|
||||
} job_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
htab_t htab;
|
||||
zarray_t jobs;
|
||||
} jobmgr_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
htab_t htab;
|
||||
int nshared;
|
||||
int nunshared;
|
||||
zarray_t defs;
|
||||
zarray_t sharedinst;
|
||||
} resmgr_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
htab_t htab;
|
||||
zarray_t workers;
|
||||
} workermgr_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
htab_t htab;
|
||||
zarray_t queues;
|
||||
} qmgr_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
endpoint_t* ep;
|
||||
} scheduler_t;
|
||||
|
||||
typedef struct {
|
||||
DBPool* db_pool;
|
||||
DBHandle* db_handle;
|
||||
pthread_t fetch_thread;
|
||||
int64_t fetch_job_pos;
|
||||
int fetch_job_interval;
|
||||
int running;
|
||||
mylock_t db_lock;
|
||||
} db_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
pthread_t thread;
|
||||
int runing;
|
||||
int interval;
|
||||
} ctrlreq_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
ctrlreq_ctx_t ctrlreq_ctx;
|
||||
} ctrl_req_mgr_t;
|
||||
|
||||
typedef struct {
|
||||
myconf_t* myconf;
|
||||
xce_peerinfo_t* myhost;
|
||||
hooksys_t hooksys;
|
||||
iomgr_t iomgr;
|
||||
objmgr_t objmgr;
|
||||
zarray_t endpoints;
|
||||
endpoint_t ep;
|
||||
zarray_t configs;
|
||||
controller_t controllers[N_CONTROLLER_MAX];
|
||||
int myidx;
|
||||
int master;
|
||||
int ncontrollers;
|
||||
scheduler_t sched;
|
||||
jobmgr_t jobmgr;
|
||||
resmgr_t resmgr;
|
||||
workermgr_t workermgr;
|
||||
qmgr_t qmgr;
|
||||
kvmgr_t configmgr;
|
||||
kvmgr_t ugmgr;
|
||||
kvmgr_t hgmgr;
|
||||
vtaskmgr_t vtaskmgr;
|
||||
cbuf_t wbuf;
|
||||
int running;
|
||||
db_ctx_t dbctx;
|
||||
ctrl_req_mgr_t ctrl_req_mgr;
|
||||
} cluster_t;
|
||||
|
||||
#endif /* XCE_CLUSTER_DEF_H */
|
||||
26
src/include/xce/errnox.h
Normal file
26
src/include/xce/errnox.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#if !defined(__XCE_ERRNOX_H__)
|
||||
|
||||
#define __XCE_ERRNOX_H__ 1
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define XCE_ERRNO_BASE (10001)
|
||||
|
||||
enum {
|
||||
E_XCE_BAD_JOB = XCE_ERRNO_BASE,
|
||||
E_XCE_BAD_WORKER,
|
||||
E_XCE_DUP_JOB,
|
||||
E_XCE_DUP_WORKER,
|
||||
E_XCE_BAD_OPCODE,
|
||||
E_XCE_BAD_ROLE,
|
||||
E_XCE_BAD_RES,
|
||||
E_XCE_BAD_QUEUE,
|
||||
E_XCE_BAD_GROUP,
|
||||
E_XCE_INTERNAL,
|
||||
E_XCE_MAX
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
619
src/include/xce/types.h
Normal file
619
src/include/xce/types.h
Normal file
|
|
@ -0,0 +1,619 @@
|
|||
#if !defined(_XCE_TYPES_H_)
|
||||
|
||||
#define _XCE_TYPES_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "xlist.h"
|
||||
#include "zarray.h"
|
||||
|
||||
#define XCE_VAL_STRING (0)
|
||||
#define XCE_VAL_NUMERIC (1)
|
||||
#define XCE_VAL_BOOLEAN (2)
|
||||
|
||||
typedef enum {
|
||||
XCE_ORD_INCR = 0,
|
||||
XCE_ORD_DECR,
|
||||
XCE_ORD_NA
|
||||
} xce_order_t;
|
||||
|
||||
typedef struct {
|
||||
int which;
|
||||
union {
|
||||
int32_t ivalue32;
|
||||
uint32_t uvalue32;
|
||||
int64_t ivalue64;
|
||||
uint64_t uvalue64;
|
||||
char* svalue;
|
||||
double fvalue;
|
||||
int bvalue;
|
||||
} u;
|
||||
} xce_val_t;
|
||||
|
||||
typedef struct {
|
||||
int idx;
|
||||
xce_val_t* val;
|
||||
} xce_val_with_idx_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
char* host;
|
||||
xce_val_t* val;
|
||||
} xce_resval_t;
|
||||
|
||||
typedef struct {
|
||||
int field;
|
||||
xce_val_t value;
|
||||
} xce_kv_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_kv_t* vals;
|
||||
} xce_kv_list_t;
|
||||
|
||||
typedef struct {
|
||||
int day; /* 1 - 7 (Mon to Sun, 0 unspecified) */
|
||||
int hour; /* 0 - 23 */
|
||||
int min; /* 0 - 59 */
|
||||
} xce_timewindow_time_t;
|
||||
|
||||
typedef struct {
|
||||
char* tz;
|
||||
xce_timewindow_time_t* open;
|
||||
xce_timewindow_time_t* close;
|
||||
} xce_timewindow_seg_config_t;
|
||||
|
||||
typedef struct {
|
||||
int nsegs;
|
||||
xce_timewindow_seg_config_t** segs;
|
||||
} xce_timewindow_config_t;
|
||||
|
||||
#define XCE_RESF_BUILTIN (0x01)
|
||||
#define XCE_RESF_DYNAMIC (0x02)
|
||||
#define XCE_RESF_GLOBAL (0x04)
|
||||
#define XCE_RESF_SHARED (0x08)
|
||||
#define XCE_RESF_EXTERNAL (0x10)
|
||||
#define XCE_RESF_RELEASE (0x20)
|
||||
#define XCE_RESF_DEFAULT_HOST (0x40)
|
||||
#define XCE_RESF_CONSUMABLE (0x80)
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
void* data;
|
||||
} xce_list_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
int* data;
|
||||
} xce_intlist_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
char** data;
|
||||
} xce_strlist_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
char* key;
|
||||
} xce_peerinfo_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
char* value;
|
||||
} xce_config_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_config_t** configs;
|
||||
} xce_configlist_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
xce_strlist_t members;
|
||||
xce_strlist_t ex_members;
|
||||
} xce_group_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_group_t** groups;
|
||||
} xce_grouplist_t;
|
||||
|
||||
typedef struct {
|
||||
xce_val_t* value;
|
||||
int nhosts;
|
||||
char** hosts;
|
||||
} res_distribution_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
char* desc;
|
||||
int idx;
|
||||
int valtype;
|
||||
xce_order_t ordtype;
|
||||
int flags;
|
||||
int interval;
|
||||
time_t last_report;
|
||||
int ndistributions;
|
||||
res_distribution_t** distributions;
|
||||
xce_val_t* hbased_defined;
|
||||
} xce_resource_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_resource_t** res;
|
||||
} xce_reslist_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
double sched;
|
||||
double stop;
|
||||
} xce_res_threshold_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
char* hostmodel;
|
||||
char* hosttype;
|
||||
int mxj;
|
||||
int nresources;
|
||||
xce_config_t** resources;
|
||||
int nthresholds;
|
||||
xce_res_threshold_t** thresholds;
|
||||
xce_timewindow_config_t* dispatchwindow;
|
||||
} xce_hostconfig_t;
|
||||
|
||||
#define XCE_WORKER_UNAVAIL (0x00010000)
|
||||
#define XCE_WORKER_LOCKEDU (0x00020000)
|
||||
#define XCE_WORKER_LOCKEDW (0x00040000)
|
||||
#define XCE_WORKER_BUSY (0x00080000)
|
||||
#define XCE_WORKER_CLOSED (0x00100000)
|
||||
|
||||
#define IS_WORKER_UNAVAIL(status) \
|
||||
(((status) & XCE_WORKER_UNAVAIL) != 0)
|
||||
#define IS_WORKER_LOCKEDU(status) \
|
||||
(((status) & XCE_WORKER_LOCKEDU) != 0)
|
||||
#define IS_WORKER_LOCKEDW(status) \
|
||||
(((status) & XCE_WORKER_LOCKEDW) != 0)
|
||||
#define IS_WORKER_LOCKED(status) \
|
||||
(IS_WORKER_LOCKEDU(status) || IS_WORKER_LOCKEDW(status))
|
||||
#define IS_WORKER_BUSY(status) \
|
||||
(((status) & XCE_WORKER_BUSY) != 0)
|
||||
|
||||
typedef struct {
|
||||
char* hosttype;
|
||||
char* hostmodel;
|
||||
double cpufactor;
|
||||
int maxcpus;
|
||||
double maxmem;
|
||||
double maxswap;
|
||||
double maxtmp;
|
||||
int ndisks;
|
||||
} hostattrs_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
} xce_timerange_t;
|
||||
|
||||
typedef struct {
|
||||
int nsegs;
|
||||
xce_timerange_t* ranges;
|
||||
} xce_timewindow_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
hostattrs_t* attrs;
|
||||
uint32_t status;
|
||||
zarray_t resvals;
|
||||
time_t dead_since;
|
||||
int64_t pending_ctrl;
|
||||
xce_timewindow_config_t* dispatch_window_config;
|
||||
int nthresholds;
|
||||
xce_res_threshold_t** thresholds;
|
||||
/* following two vars used to push resource values to sched */
|
||||
int nresvals_to_sched;
|
||||
xce_val_with_idx_t** resvals_to_sched;
|
||||
} xce_worker_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_worker_t** workers;
|
||||
} xce_workerlist_t;
|
||||
|
||||
typedef struct {
|
||||
char* host;
|
||||
int nranks;
|
||||
} xce_host_launch_t;
|
||||
|
||||
typedef struct {
|
||||
int nhosts;
|
||||
xce_host_launch_t** hosts;
|
||||
} xce_launch_t;
|
||||
|
||||
typedef struct {
|
||||
char* exechome;
|
||||
char* execcwd;
|
||||
char* execuser;
|
||||
char* cmdline;
|
||||
char* exdata;
|
||||
char* launch_type;
|
||||
char* q_pre_exec;
|
||||
char* q_post_exec;
|
||||
char* job_pre_exec;
|
||||
char* job_post_exec;
|
||||
} job_startinfo_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
int npids;
|
||||
unsigned int* pids;
|
||||
int npgids;
|
||||
unsigned int* pgids;
|
||||
char* exdata;
|
||||
} job_pidinfo_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
uint32_t stage;
|
||||
int code;
|
||||
char* detail;
|
||||
} job_failinfo_t;
|
||||
|
||||
typedef struct {
|
||||
char* resname;
|
||||
char* reserve;
|
||||
uint32_t instid;
|
||||
double value;
|
||||
uint64_t from;
|
||||
int64_t duration;
|
||||
} xce_alloc_t;
|
||||
|
||||
typedef struct {
|
||||
char* host;
|
||||
int nallocs;
|
||||
xce_alloc_t** allocs;
|
||||
} xce_host_alloc_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
int nhosts;
|
||||
xce_host_alloc_t** allocs;
|
||||
} xce_job_alloc_t;
|
||||
|
||||
typedef struct {
|
||||
int njobs;
|
||||
xce_job_alloc_t** allocs;
|
||||
} xce_job_dispatch_t;
|
||||
|
||||
typedef struct {
|
||||
char* queue;
|
||||
char* user;
|
||||
char* cmdline;
|
||||
char* resreq;
|
||||
char* exdata;
|
||||
char* pre_exec;
|
||||
char* post_exec;
|
||||
uint32_t mintasks;
|
||||
uint32_t maxtasks;
|
||||
} xce_job_submit_t;
|
||||
|
||||
typedef struct {
|
||||
int exitcode;
|
||||
} job_exitinfo_t;
|
||||
|
||||
#define JOB_STAT_NULL 0x00 /**< NULL. */
|
||||
#define JOB_STAT_PEND 0x01 /**< Job is submitted. */
|
||||
#define JOB_STAT_RUN 0x02 /**< Job is running. */
|
||||
#define JOB_STAT_EXIT 0x04 /**< Job is exit. */
|
||||
#define JOB_STAT_DONE 0x08 /**< Job is done. */
|
||||
#define JOB_STAT_PSUSP 0x10 /**< Job is pending and suspend*/
|
||||
#define JOB_STAT_USUSP 0x20 /**< Job is user suspend*/
|
||||
#define JOB_STAT_SSUSP 0x40 /**< Job is system suspend*/
|
||||
|
||||
#define JOB_STAT_PDONE (0x80) /**< Post job process done successfully */
|
||||
#define JOB_STAT_PERR (0x100) /**< Post job process has error */
|
||||
#define JOB_STAT_WAIT (0x200) /**< Chunk job waiting its turn to exec */
|
||||
#define JOB_STAT_RUNKWN 0x8000 /* Flag : Job status is UNKWN caused by losting contact with remote cluster */
|
||||
#define JOB_STAT_UNKWN 0x10000 /**< The worker on the host on which the \
|
||||
* job is processed has lost contact with controller */
|
||||
#define JOB_STAT_PROV (0x20000) /**< this state shows that the job is dispatched to a standby \
|
||||
* power saved host, and this host is \
|
||||
* being waken up or started up */
|
||||
#define JOB_STAT_ERR (0x40000) /**ERROR */
|
||||
|
||||
#define JOB_EXEC_STAGE_Q_PRE_EXEC (0)
|
||||
#define JOB_EXEC_STAGE_PRE_EXEC (1)
|
||||
#define JOB_EXEC_STAGE_MAIN (2)
|
||||
#define JOB_EXEC_STAGE_POST_EXEC (3)
|
||||
#define JOB_EXEC_STAGE_Q_POST_EXEC (4)
|
||||
|
||||
#define QUEUE_STAT_OPEN 0x00 /**< OPEN. */
|
||||
#define QUEUE_STAT_CLOSED 0x01 /**< The queue is closed */
|
||||
#define QUEUE_STAT_INACT_WINDOW 0x02 /**< The queue inactivated due to dispatch or run windows closed */
|
||||
#define QUEUE_STAT_INACT_ADMIN 0x04 /**< The queue inactivated by admin */
|
||||
#define QUEUE_STAT_NOPERM 0x08 /**< Remote queue rejecting jobs. */
|
||||
#define QUEUE_STAT_DISC 0x10 /**< Remote queue status is disconnected. */
|
||||
#define QUEUE_STAT_FAIRSHARE_DEFAULT 0x20 /**< Fairshare queue with null user share defined*/
|
||||
|
||||
typedef enum {
|
||||
NORMAL = 0,
|
||||
TTY,
|
||||
XJOB,
|
||||
DISPLAY
|
||||
} xce_job_type;
|
||||
|
||||
typedef struct {
|
||||
char* host_name;
|
||||
int num_slots;
|
||||
} xce_job_host_slots_t;
|
||||
|
||||
typedef struct {
|
||||
int num_hosts;
|
||||
xce_job_host_slots_t* host_slots;
|
||||
} xce_job_slots_alloc_t;
|
||||
|
||||
typedef struct {
|
||||
char* host_name;
|
||||
int cpu_time;
|
||||
double mem_usage;
|
||||
} xce_host_runusage_t;
|
||||
|
||||
typedef struct {
|
||||
double max_mem;
|
||||
double avg_mem;
|
||||
double used_mem;
|
||||
int cpu_time;
|
||||
int peak_cpu_time;
|
||||
int peak_cpu_duration;
|
||||
float mem_efficiency;
|
||||
float avg_cpu_efficiency;
|
||||
float peak_cpu_efficiency;
|
||||
int num_hosts;
|
||||
xce_host_runusage_t** host_runusage;
|
||||
} xce_job_runusage_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
char* ckptinfo;
|
||||
} xce_ckptinfo_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
uint64_t array_base_id;
|
||||
int array_idx;
|
||||
char* queue;
|
||||
char* user;
|
||||
int64_t idx;
|
||||
time_t sub_time;
|
||||
time_t queue_time;
|
||||
time_t start_time;
|
||||
time_t finish_time;
|
||||
uint32_t mintasks;
|
||||
uint32_t maxtasks;
|
||||
job_pidinfo_t* pidinfo;
|
||||
job_startinfo_t* start_info;
|
||||
unsigned int state;
|
||||
char* job_name;
|
||||
char* project_name;
|
||||
char* user_group;
|
||||
char* job_description;
|
||||
char* resreq;
|
||||
xce_job_alloc_t* allocs;
|
||||
int run_time;
|
||||
xce_job_runusage_t* run_usage;
|
||||
job_exitinfo_t* exit_info;
|
||||
char* ckptinfo;
|
||||
int64_t pending_ctrl;
|
||||
} xce_job_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_job_t** data;
|
||||
} xce_job_list_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
job_startinfo_t* start_info;
|
||||
xce_launch_t* launchinfo;
|
||||
} xce_job_exec_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
job_pidinfo_t pidinfo;
|
||||
} xce_job_runinfo_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
int exit_code;
|
||||
} xce_jobfinish_t;
|
||||
|
||||
typedef struct {
|
||||
char* queue;
|
||||
uint32_t attrs;
|
||||
uint32_t status;
|
||||
int32_t priority;
|
||||
int32_t accept_interval;
|
||||
int32_t sched_delay;
|
||||
char* resreq;
|
||||
xce_group_t* users;
|
||||
xce_group_t* hosts;
|
||||
int32_t nthresholds;
|
||||
xce_res_threshold_t** thresholds;
|
||||
xce_timewindow_t* runwindow;
|
||||
xce_timewindow_t* dispatchwindow;
|
||||
xce_timewindow_config_t* runwindow_config;
|
||||
xce_timewindow_config_t* dispatchwindow_config;
|
||||
int64_t pending_ctrl;
|
||||
char* pre_exec;
|
||||
char* post_exec;
|
||||
} xce_queue_t;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
xce_queue_t** queues;
|
||||
} xce_queuelist_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
xce_reslist_t reslist;
|
||||
xce_queuelist_t qlist;
|
||||
xce_workerlist_t wlist;
|
||||
xce_grouplist_t uglist;
|
||||
xce_grouplist_t hglist;
|
||||
xce_configlist_t cfglist;
|
||||
} xce_clusterconf_t;
|
||||
|
||||
typedef enum {
|
||||
CONTROL_NONE = 0,
|
||||
CONTROL_JOB,
|
||||
CONTROL_HOST,
|
||||
CONTROL_QUEUE,
|
||||
CONTROL_CLUSTER,
|
||||
CONTROL_DEBUG
|
||||
} ctrl_target_type_t;
|
||||
|
||||
typedef enum {
|
||||
JOB_DO_NONE = 0,
|
||||
JOB_STOP,
|
||||
JOB_RESUME,
|
||||
JOB_KILL,
|
||||
JOB_MIG,
|
||||
JOB_REQUEUE,
|
||||
JOB_MODIFY,
|
||||
JOB_SWITCH,
|
||||
JOB_CHKPNT,
|
||||
JOB_POST,
|
||||
JOB_READ,
|
||||
JOB_TOP,
|
||||
JOB_BOT
|
||||
} job_ctrl_type_t;
|
||||
|
||||
typedef enum {
|
||||
HOST_DO_NONE = 0,
|
||||
HOST_OPEN,
|
||||
HOST_CLOSE,
|
||||
HOST_TAG,
|
||||
HOST_UNTAG
|
||||
} host_ctrl_type_t;
|
||||
|
||||
typedef enum {
|
||||
QUEUE_DO_NONE = 0,
|
||||
QUEUE_OPEN,
|
||||
QUEUE_CLOSE,
|
||||
QUEUE_INACTIVE,
|
||||
QUEUE_ACTIVE
|
||||
} queue_ctrl_type_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
int signal;
|
||||
int forcekill;
|
||||
char* method;
|
||||
char* comment;
|
||||
} job_ctrl_content_t;
|
||||
|
||||
typedef struct {
|
||||
char* hostname;
|
||||
char* comment;
|
||||
} host_ctrl_content_t;
|
||||
|
||||
typedef struct {
|
||||
char* queuename;
|
||||
char* comment;
|
||||
} queue_ctrl_content_t;
|
||||
|
||||
typedef struct {
|
||||
int64_t id;
|
||||
int target_type;
|
||||
int action_type;
|
||||
time_t request_time;
|
||||
char* user;
|
||||
void* content;
|
||||
} xce_ctrl_req_t;
|
||||
|
||||
typedef struct {
|
||||
int signo;
|
||||
int force;
|
||||
} xce_signal_t;
|
||||
|
||||
typedef struct {
|
||||
int kill;
|
||||
char* method;
|
||||
} xce_ckpt_options_t;
|
||||
|
||||
typedef struct {
|
||||
int action;
|
||||
uint64_t jobid;
|
||||
union {
|
||||
xce_signal_t* siginfo;
|
||||
xce_ckpt_options_t* ckptoption;
|
||||
} u;
|
||||
} xce_jobctrl_t;
|
||||
|
||||
typedef struct {
|
||||
int action;
|
||||
char* queue;
|
||||
} xce_queuectrl_t;
|
||||
|
||||
typedef struct {
|
||||
int action;
|
||||
char* hostname;
|
||||
} xce_hostctrl_t;
|
||||
|
||||
typedef struct {
|
||||
char* host;
|
||||
char* launch_type; /* MPI ranks or something others */
|
||||
int ntasks;
|
||||
char* exechome;
|
||||
char* execcwd;
|
||||
char* execuser;
|
||||
char* cmdline;
|
||||
char* exdata;
|
||||
} xce_taskhost_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
int nhosts;
|
||||
int clientidx;
|
||||
xce_taskhost_t** taskhosts;
|
||||
} xce_taskrun_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
char* host;
|
||||
int clientidx;
|
||||
int taskidx;
|
||||
int npids;
|
||||
unsigned int* pids;
|
||||
int npgids;
|
||||
unsigned int* pgids;
|
||||
char* exdata;
|
||||
} xce_task_pidinfo_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
char* host;
|
||||
int clientidx;
|
||||
int taskidx; /* taskidx == -1 for fail of all tasks
|
||||
* in the same host of xcecli_runtask()
|
||||
*/
|
||||
int code;
|
||||
char* detail;
|
||||
} xce_task_failinfo_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
char* host;
|
||||
int taskidx;
|
||||
int clientidx;
|
||||
int exit_code;
|
||||
} xce_task_finish_t;
|
||||
|
||||
typedef struct {
|
||||
char* resname;
|
||||
float value;
|
||||
} xce_rusage_t;
|
||||
|
||||
#endif
|
||||
34
src/include/xceapi.h
Normal file
34
src/include/xceapi.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#if !defined(_XCEAPI_H_)
|
||||
|
||||
#define _XCEAPI_H_ 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "xce/types.h"
|
||||
#include "xcectx.h"
|
||||
|
||||
extern int xce_hello(xce_ctx_t*, char*);
|
||||
extern int xce_shutdown(xce_ctx_t*);
|
||||
extern int xce_reslist(xce_ctx_t*, xce_resource_t***);
|
||||
extern int xce_join(xce_ctx_t*, int, hostattrs_t*);
|
||||
extern int xce_workerlist(xce_ctx_t*, xce_worker_t***);
|
||||
extern int xce_jobdispatch(xce_ctx_t*, xce_job_dispatch_t*);
|
||||
extern int xce_jobsubmit(xce_ctx_t*, xce_job_submit_t*,
|
||||
uint64_t*);
|
||||
extern int xce_joblist(xce_ctx_t*, xce_job_t***);
|
||||
extern int xce_clusterconf(xce_ctx_t*, xce_clusterconf_t**);
|
||||
extern int xce_push(xce_ctx_t*, xce_check_fn_t,
|
||||
void*, int, int, int, void**);
|
||||
extern int xce_update_rows(xce_ctx_t*, int, int, xlist_t*);
|
||||
extern int xce_resval(xce_ctx_t*, char*,
|
||||
char*, xce_resval_t***);
|
||||
|
||||
extern int xce_notify(xce_ctx_t*, xce_notify_data_t*);
|
||||
extern int xce_update_resvals(xce_ctx_t*, int, xce_resval_t**);
|
||||
extern int xce_jobctrl(xce_ctx_t*, xce_jobctrl_t*);
|
||||
extern int xce_queuectrl(xce_ctx_t*, xce_queuectrl_t*);
|
||||
extern int xce_runtask(xce_ctx_t*, xce_taskrun_t*);
|
||||
extern int xce_update_jusage(xce_ctx_t*, uint64_t, int,
|
||||
int*, int, int*, int, xce_rusage_t**);
|
||||
|
||||
#endif
|
||||
52
src/include/xcectx.h
Normal file
52
src/include/xcectx.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#if !defined(_XCECTX_H_)
|
||||
|
||||
#define _XCECTX_H_ 1
|
||||
|
||||
#include "netio.h"
|
||||
#include "request.h"
|
||||
#include "vtaskmgr.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
typedef enum {
|
||||
XCE_CTX_INIT = 0,
|
||||
XCE_CTX_RUN,
|
||||
XCE_CTX_DOWN,
|
||||
XCE_CTX_BUSY,
|
||||
XCE_CTX_ERR
|
||||
} xce_ctx_state_t;
|
||||
|
||||
typedef int (*xce_request_handler_t)(xce_request_t*);
|
||||
|
||||
typedef struct {
|
||||
xce_ctx_state_t state;
|
||||
xce_peerinfo_t myinfo;
|
||||
iomgr_t iomgr;
|
||||
vtaskmgr_t vtaskmgr;
|
||||
endpoint_t* ep;
|
||||
xce_request_handler_t handler;
|
||||
cbuf_t wbuf;
|
||||
dataset_t* dataset;
|
||||
|
||||
struct {
|
||||
union {
|
||||
char* debugmsg;
|
||||
dataset_t* get;
|
||||
uint64_t jobid;
|
||||
xce_clusterconf_t* clusterconf;
|
||||
} u;
|
||||
} reply;
|
||||
} xce_ctx_t;
|
||||
|
||||
extern int xce_ctx_init(xce_ctx_t*, char*, char*);
|
||||
extern void xce_ctx_fini(xce_ctx_t*);
|
||||
extern int xce_ctx_set_handler(xce_ctx_t*,
|
||||
xce_request_handler_t);
|
||||
extern int xce_ctx_start(xce_ctx_t*);
|
||||
extern int xce_ctx_stop(xce_ctx_t*);
|
||||
extern int xce_wakeup(xce_ctx_t*, int);
|
||||
extern int xce_try_wakeup(xce_ctx_t*, int);
|
||||
extern int xce_ctx_set_endpoint(xce_ctx_t*, endpoint_t*);
|
||||
extern void xce_block_tasks(xce_ctx_t*);
|
||||
extern void xce_unblock_tasks(xce_ctx_t*);
|
||||
|
||||
#endif
|
||||
21
src/include/xlist.h
Normal file
21
src/include/xlist.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#if !defined(__XLIST_H__)
|
||||
|
||||
#define __XLIST_H__ 1
|
||||
|
||||
typedef int (*xlist_iter_fn_t)(void*, void*);
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
int caps;
|
||||
int delta;
|
||||
void** data;
|
||||
} xlist_t;
|
||||
|
||||
typedef int (*xlist_action_fn_t)(xlist_t*, void*);
|
||||
|
||||
extern int xlist_init(xlist_t*, int);
|
||||
extern int xlist_store(xlist_t*, void*);
|
||||
extern void xlist_clear(xlist_t*);
|
||||
extern int xlist_iter(xlist_t*, xlist_iter_fn_t, void*);
|
||||
extern void xlist_fini(xlist_t*);
|
||||
#endif
|
||||
25
src/include/xstring.h
Normal file
25
src/include/xstring.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#if !defined(__XSTRING_H__)
|
||||
|
||||
#define __XSTRING_H__ 1
|
||||
|
||||
#include "objmgr.h"
|
||||
|
||||
typedef struct {
|
||||
htab_t tab;
|
||||
zarray_t strings;
|
||||
} xstring_typedata_t;
|
||||
|
||||
#define XSTRING_OBJ_TYPE_HTAB(obj) \
|
||||
(((xstring_typedata_t *)obj->type->typedata)->tab)
|
||||
#define XSTRING_OBJ_TYPE_STRINGS(obj) \
|
||||
(((xstring_typedata_t *)obj->type->typedata)->strings)
|
||||
|
||||
#define XSTRING_TYPE_HTAB(type) \
|
||||
(((xstring_typedata_t *)type->typedata)->tab)
|
||||
|
||||
#define XSTRING_TYPE_STRINGS(type) \
|
||||
(((xstring_typedata_t *)type->typedata)->strings)
|
||||
|
||||
extern int register_xstring(objmgr_t*, int,int);
|
||||
|
||||
#endif
|
||||
32
src/include/zarray.h
Normal file
32
src/include/zarray.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#if !defined(_ZARRAY_H_)
|
||||
|
||||
#define _ZARRAY_H_ 1
|
||||
|
||||
#include "mylock.h"
|
||||
#include "xlist.h"
|
||||
|
||||
typedef void (*zarray_item_killer_t)(void*);
|
||||
typedef int (*zarray_iter_fn_t)(void*, void*);
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
int count;
|
||||
int pos;
|
||||
int caps;
|
||||
int delta;
|
||||
zarray_item_killer_t killer;
|
||||
void** data;
|
||||
} zarray_t;
|
||||
|
||||
extern int zarray_init(zarray_t*, int,
|
||||
zarray_item_killer_t);
|
||||
extern int zarray_store(zarray_t*, void*);
|
||||
extern int zarray_clear(zarray_t*, int);
|
||||
extern int zarray_iter_ex(zarray_t*, xlist_t*, void*);
|
||||
extern int zarray_iter(zarray_t*, zarray_iter_fn_t, void*);
|
||||
extern int zarray_del(zarray_t*, int);
|
||||
extern int zarray_put(zarray_t*, int, void*);
|
||||
extern void* zarray_get(zarray_t*, int);
|
||||
extern void zarray_fini(zarray_t*);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue