save
This commit is contained in:
parent
2b190bdb1d
commit
abea3375ca
9 changed files with 866 additions and 45 deletions
|
|
@ -7,12 +7,32 @@
|
|||
|
||||
#include "client.h"
|
||||
#include "controller.capnp.h"
|
||||
#include "kvmgr.h"
|
||||
#include "objmgr.h"
|
||||
#include "plugin.h"
|
||||
#include "scheduler.h"
|
||||
#include "utils.h"
|
||||
|
||||
static uint64_t pick_job(xce_scheduler_t* sched)
|
||||
{
|
||||
uint64_t jobid = 0;
|
||||
static xce_sched_plugin_t* job_picker = NULL;
|
||||
uint64_t jobid = 0;
|
||||
|
||||
if (job_picker == NULL) {
|
||||
char* job_picker_plugin = "xce_sched_fcfs";
|
||||
|
||||
/* set job_pick_plugin according configuration */
|
||||
job_picker
|
||||
= kvmgr_lock(&(sched->plugins), job_picker_plugin, OBJREF_NOP);
|
||||
if ((job_picker == NULL) || (job_picker->job_elect_fn == NULL)) {
|
||||
/* something wrong */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (job_picker->job_elect_fn != NULL) {
|
||||
jobid = job_picker->job_elect_fn(job_picker);
|
||||
}
|
||||
|
||||
return jobid;
|
||||
}
|
||||
|
|
@ -111,6 +131,13 @@ static void sched_pend_update_killer(data_item_t* it)
|
|||
free(req);
|
||||
}
|
||||
|
||||
static int sched_register_plugins(xce_scheduler_t* sched)
|
||||
{
|
||||
register_fcfs(sched);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sched_init(xce_scheduler_t* sched, xce_client_config_t* config,
|
||||
xce_request_handler_t handler)
|
||||
{
|
||||
|
|
@ -135,6 +162,21 @@ int sched_init(xce_scheduler_t* sched, xce_client_config_t* config,
|
|||
sched->pend_updates[1] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->pend_updates[1], sched_pend_update_killer);
|
||||
|
||||
kvmgr_init(&(sched->plugins), string_hash_key, 8, 8,
|
||||
(zarray_item_killer_t)plugin_unregister);
|
||||
kvmgr_init(&(sched->jobs), int_hash_key, 1000, 1000,
|
||||
(zarray_item_killer_t)kill_sched_job);
|
||||
kvmgr_init(&(sched->queues), string_hash_key, 8, 8,
|
||||
(zarray_item_killer_t)kill_sched_queue);
|
||||
kvmgr_init(&(sched->workers), string_hash_key, 256, 256,
|
||||
(zarray_item_killer_t)kill_sched_worker);
|
||||
kvmgr_init(&(sched->users), string_hash_key, 256, 256,
|
||||
(zarray_item_killer_t)kill_sched_user);
|
||||
kvmgr_init(&(sched->projects), string_hash_key, 8, 8,
|
||||
(zarray_item_killer_t)kill_sched_project);
|
||||
|
||||
sched_register_plugins(sched);
|
||||
|
||||
rc = xcecli_ctx_init(&(sched->apictx), config);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
|
|
@ -194,18 +236,44 @@ void sched_fini(xce_scheduler_t* sched)
|
|||
|
||||
static int sched_update_config(xce_scheduler_t* sched, xce_conf4sched_t* config)
|
||||
{
|
||||
int i;
|
||||
|
||||
plugin_config_update(sched, config);
|
||||
|
||||
for (i = 0; i < config->n_queues; i++) {
|
||||
xce_sched_queue_t* q = make_sched_queue(sched, config->queues[i]);
|
||||
|
||||
plugin_queue_update(sched, q);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sched_update_jobs(xce_scheduler_t* sched, int njobs,
|
||||
xce_job_t** jobs)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < njobs; i++) {
|
||||
xce_sched_job_t* j = make_sched_job(sched, jobs[i]);
|
||||
|
||||
plugin_job_update(sched, j);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sched_update_workers(xce_scheduler_t* sched, int nworkers,
|
||||
xce_worker_t** workers)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nworkers; i++) {
|
||||
xce_sched_worker_t* w = make_sched_worker(sched, workers[i]);
|
||||
|
||||
plugin_worker_update(sched, w);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -266,3 +334,55 @@ void sched_go(xce_scheduler_t* sched)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
int sched_add_job(xce_scheduler_t* sched, xce_sched_job_t* j)
|
||||
{
|
||||
return kvmgr_add(&(sched->jobs), (void*)j->jobid, j);
|
||||
}
|
||||
|
||||
xce_sched_job_t* sched_get_job(xce_scheduler_t* sched, uint64_t jobid)
|
||||
{
|
||||
return kvmgr_lock(&(sched->jobs), (void*)jobid, OBJREF_NOP);
|
||||
}
|
||||
|
||||
int sched_add_queue(xce_scheduler_t* sched, xce_sched_queue_t* q)
|
||||
{
|
||||
return kvmgr_add(&(sched->queues), q->name, q);
|
||||
}
|
||||
|
||||
xce_sched_queue_t* sched_get_queue(xce_scheduler_t* sched, char* name)
|
||||
{
|
||||
return kvmgr_lock(&(sched->queues), (void*)name, OBJREF_NOP);
|
||||
}
|
||||
|
||||
int sched_add_worker(xce_scheduler_t* sched, xce_sched_worker_t* w)
|
||||
{
|
||||
return kvmgr_add(&(sched->workers), w->name, w);
|
||||
}
|
||||
|
||||
xce_sched_worker_t* sched_get_worker(xce_scheduler_t* sched, char* name)
|
||||
{
|
||||
return kvmgr_lock(&(sched->workers), (void*)name, OBJREF_NOP);
|
||||
}
|
||||
|
||||
int sched_add_user(xce_scheduler_t* sched, xce_sched_user_t* u)
|
||||
{
|
||||
return kvmgr_add(&(sched->users), u->name, u);
|
||||
}
|
||||
|
||||
xce_sched_user_t* sched_get_user(xce_scheduler_t* sched, char* name)
|
||||
{
|
||||
return kvmgr_lock(&(sched->users), (void*)name, OBJREF_NOP);
|
||||
}
|
||||
|
||||
int sched_add_project(xce_scheduler_t* sched, xce_sched_project_t* p)
|
||||
{
|
||||
return kvmgr_add(&(sched->projects), p->name, p);
|
||||
}
|
||||
|
||||
xce_sched_project_t* sched_get_project(xce_scheduler_t* sched, char* name)
|
||||
{
|
||||
return kvmgr_lock(&(sched->projects), (void*)name, OBJREF_NOP);
|
||||
}
|
||||
|
||||
int sched_job_is_ready(xce_sched_job_t* j) { return 1; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue