save
This commit is contained in:
parent
2b190bdb1d
commit
abea3375ca
9 changed files with 866 additions and 45 deletions
56
src/scheduler/include/plugin.h
Normal file
56
src/scheduler/include/plugin.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#if !defined(_PLUGIN_H_)
|
||||
|
||||
#define _PLUGIN_H_ 1
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sched/types.h"
|
||||
|
||||
typedef void* plugin_data_t;
|
||||
|
||||
/* hooker of plugin, the first parameter should be xce_sched_plugin_t */
|
||||
typedef int (*plugin_update_config_hook_t)(void*, xce_conf4sched_t*);
|
||||
typedef int (*plugin_update_queue_hook_t)(void*, xce_sched_queue_t*);
|
||||
typedef int (*plugin_update_job_hook_t)(void*, xce_sched_job_t*);
|
||||
typedef int (*plugin_update_worker_hook_t)(void*, xce_sched_worker_t*);
|
||||
|
||||
/* initialize function of plugin */
|
||||
typedef int (*plugin_init_fn_t)(void*);
|
||||
|
||||
typedef void (*plugin_fini_fn_t)(void*);
|
||||
|
||||
/* plugin function to elect job to be scheduler */
|
||||
typedef int64_t (*plugin_job_election_fn_t)(void*);
|
||||
|
||||
/* allocation function of job */
|
||||
typedef xce_job_alloc_t* (*plugin_job_allocate_fn_t)(void*, int64_t*);
|
||||
|
||||
typedef struct {
|
||||
plugin_update_config_hook_t config_hook;
|
||||
plugin_update_queue_hook_t queue_hook;
|
||||
plugin_update_job_hook_t job_hook;
|
||||
plugin_update_worker_hook_t worker_hook;
|
||||
} plugin_hooks_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
void* sched;
|
||||
plugin_init_fn_t init_fn;
|
||||
plugin_fini_fn_t fini_fn;
|
||||
plugin_job_election_fn_t job_elect_fn;
|
||||
plugin_job_allocate_fn_t job_alloc_fn;
|
||||
plugin_hooks_t hooks;
|
||||
plugin_data_t data;
|
||||
} xce_sched_plugin_t;
|
||||
|
||||
extern int plugin_register(void*, void*);
|
||||
extern void plugin_unregister(void*);
|
||||
extern int plugin_config_update(void*, xce_conf4sched_t*);
|
||||
extern int plugin_queue_update(void*, xce_sched_queue_t*);
|
||||
extern int plugin_job_update(void*, xce_sched_job_t*);
|
||||
extern int plugin_worker_update(void*, xce_sched_worker_t*);
|
||||
|
||||
extern int register_fcfs(void*);
|
||||
|
||||
#endif
|
||||
69
src/scheduler/include/sched/types.h
Normal file
69
src/scheduler/include/sched/types.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#if !defined(_SCHED_TYPES_H_)
|
||||
|
||||
#define _SCHED_TYPES_H_ 1
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "typemap.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
typedef void* host_selection_t;
|
||||
|
||||
typedef struct {
|
||||
host_selection_t* select;
|
||||
int nres;
|
||||
uint32_t* resources;
|
||||
float* amount;
|
||||
} rank_req_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
} xce_sched_user_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
} xce_sched_project_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint32_t attrs;
|
||||
uint32_t status;
|
||||
int32_t priority;
|
||||
int32_t accept_interval;
|
||||
int32_t sched_delay;
|
||||
char* resreq;
|
||||
} xce_sched_queue_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
time_t sub_time;
|
||||
time_t queue_time;
|
||||
time_t start_time;
|
||||
unsigned int state;
|
||||
int32_t priority;
|
||||
xce_sched_queue_t* queue;
|
||||
xce_sched_user_t* user;
|
||||
xce_sched_project_t* project;
|
||||
uint32_t mintasks;
|
||||
uint32_t maxtasks;
|
||||
xce_job_alloc_t* allocs;
|
||||
} xce_sched_job_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
xce_val_t* res_avail; /* resources in worker */
|
||||
xce_val_t* res_in_use; /* used resources in worker */
|
||||
} xce_sched_worker_t;
|
||||
|
||||
extern xce_sched_job_t* make_sched_job(void*, xce_job_t*);
|
||||
extern xce_sched_queue_t* make_sched_queue(void*, xce_queue_t*);
|
||||
extern xce_sched_worker_t* make_sched_worker(void*, xce_worker_t*);
|
||||
extern xce_sched_user_t* make_sched_user(void*, char*);
|
||||
extern xce_sched_project_t* make_sched_project(void*, char*);
|
||||
extern void kill_sched_job(void*);
|
||||
extern void kill_sched_queue(void*);
|
||||
extern void kill_sched_worker(void*);
|
||||
extern void kill_sched_user(void*);
|
||||
extern void kill_sched_project(void*);
|
||||
#endif
|
||||
|
|
@ -9,7 +9,9 @@
|
|||
#include "client.h"
|
||||
#include "dataq.h"
|
||||
#include "decision.h"
|
||||
#include "kvmgr.h"
|
||||
#include "mylock.h"
|
||||
#include "plugin.h"
|
||||
#include "xce/types.h"
|
||||
#include "xlist.h"
|
||||
|
||||
|
|
@ -41,50 +43,17 @@ typedef struct {
|
|||
- offsetof(xce_sched_update_request_t, \
|
||||
link)))
|
||||
|
||||
typedef void* host_selection_t;
|
||||
|
||||
typedef struct {
|
||||
host_selection_t* select;
|
||||
int nres;
|
||||
uint32_t* resources;
|
||||
float* amount;
|
||||
} rank_req_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
time_t sub_time;
|
||||
time_t queue_time;
|
||||
time_t start_time;
|
||||
unsigned int state;
|
||||
char* queue;
|
||||
char* user;
|
||||
char* project;
|
||||
uint32_t mintasks;
|
||||
uint32_t maxtasks;
|
||||
xce_job_alloc_t* allocs;
|
||||
} xce_sched_job_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint32_t attrs;
|
||||
uint32_t status;
|
||||
int32_t priority;
|
||||
int32_t accept_interval;
|
||||
int32_t sched_delay;
|
||||
char* resreq;
|
||||
} xce_sched_queue_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
xce_val_t* res_avail; /* resources in worker */
|
||||
xce_val_t* res_in_use; /* used resources in worker */
|
||||
} xce_sched_worker_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
int stop;
|
||||
xcecli_ctx_t apictx;
|
||||
kvmgr_t plugins;
|
||||
dataq_t* pend_updates[2];
|
||||
kvmgr_t jobs;
|
||||
kvmgr_t queues;
|
||||
kvmgr_t workers;
|
||||
kvmgr_t users;
|
||||
kvmgr_t projects;
|
||||
pthread_t jobpicker;
|
||||
pthread_t allocator;
|
||||
cbuf_t wbuf; /* action to trigger scheduling */
|
||||
|
|
@ -92,10 +61,21 @@ typedef struct {
|
|||
cbuf_t decisions; /* scheduler decisions */
|
||||
} xce_scheduler_t;
|
||||
|
||||
extern int sched_init(xce_scheduler_t*, xce_client_config_t*,
|
||||
xce_request_handler_t);
|
||||
extern void sched_fini(xce_scheduler_t*);
|
||||
extern int sched_update(xce_scheduler_t*);
|
||||
extern void sched_go(xce_scheduler_t*);
|
||||
extern int sched_init(xce_scheduler_t*, xce_client_config_t*,
|
||||
xce_request_handler_t);
|
||||
extern void sched_fini(xce_scheduler_t*);
|
||||
extern int sched_update(xce_scheduler_t*);
|
||||
extern void sched_go(xce_scheduler_t*);
|
||||
extern xce_sched_job_t* sched_get_job(xce_scheduler_t*, uint64_t);
|
||||
extern xce_sched_queue_t* sched_get_queue(xce_scheduler_t*, char*);
|
||||
extern xce_sched_worker_t* sched_get_worker(xce_scheduler_t*, char*);
|
||||
extern xce_sched_user_t* sched_get_user(xce_scheduler_t*, char*);
|
||||
extern xce_sched_project_t* sched_get_project(xce_scheduler_t*, char*);
|
||||
extern int sched_add_job(xce_scheduler_t*, xce_sched_job_t*);
|
||||
extern int sched_add_queue(xce_scheduler_t*, xce_sched_queue_t*);
|
||||
extern int sched_add_user(xce_scheduler_t*, xce_sched_user_t*);
|
||||
extern int sched_add_worker(xce_scheduler_t*, xce_sched_worker_t*);
|
||||
extern int sched_add_project(xce_scheduler_t*, xce_sched_project_t*);
|
||||
extern int sched_job_is_ready(xce_sched_job_t*);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue