reformat code and job array
This commit is contained in:
parent
a665ccd4fe
commit
9ff857db9f
64 changed files with 1497 additions and 2476 deletions
|
|
@ -9,50 +9,44 @@
|
|||
#include "xce/cluster_def.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
extern void collect_shared_resvals(cluster_t*, collect_check_fn_t,
|
||||
int*, xce_val_with_idx_t***);
|
||||
extern void collect_shared_resvals(cluster_t*, collect_check_fn_t, int*,
|
||||
xce_val_with_idx_t***);
|
||||
|
||||
static int xcesched_push_joblist(cluster_t* c,
|
||||
xlist_t* l)
|
||||
static int xcesched_push_joblist(cluster_t* c, xlist_t* l)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_jobs_data_t jobs = {
|
||||
.n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.jobs = (xce_job_t**)l->data
|
||||
};
|
||||
int rc = 0;
|
||||
xce_jobs_data_t jobs = { .n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.jobs = (xce_job_t**)l->data };
|
||||
int rc = 0;
|
||||
|
||||
memset(&data, 0x0, sizeof(data));
|
||||
|
||||
data.table = Data_data_schedjobs;
|
||||
data.data.jobs = &jobs;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int xcesched_push_workerlist(cluster_t* c,
|
||||
xlist_t* l)
|
||||
static int xcesched_push_workerlist(cluster_t* c, xlist_t* l)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_workers_data_t workers = {
|
||||
.n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.workers = (xce_worker_t**)l->data
|
||||
};
|
||||
int rc = 0;
|
||||
xce_workers_data_t workers = { .n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.workers = (xce_worker_t**)l->data };
|
||||
int rc = 0;
|
||||
|
||||
memset(&data, 0x0, sizeof(data));
|
||||
|
||||
data.table = Data_data_schedworkers;
|
||||
data.data.workers = &workers;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +57,8 @@ static int xcesched_push_configs(cluster_t* c)
|
|||
|
||||
memset(&configdata, 0x0, sizeof(configdata));
|
||||
|
||||
configdata.data.conf4sched = (xce_conf4sched_t*)calloc(1, sizeof(xce_conf4sched_t));
|
||||
configdata.data.conf4sched
|
||||
= (xce_conf4sched_t*)calloc(1, sizeof(xce_conf4sched_t));
|
||||
if (configdata.data.conf4sched == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -83,11 +78,11 @@ static int xcesched_push_configs(cluster_t* c)
|
|||
configdata.data.conf4sched->hgroups = c->myconf->cluster_config->hgroups;
|
||||
|
||||
/* add resources */
|
||||
configdata.data_which = ConfigData_data_schedconfig;
|
||||
configdata.data.conf4sched->clustername = c->myconf->cluster_config->clustername;
|
||||
configdata.data_which = ConfigData_data_schedconfig;
|
||||
configdata.data.conf4sched->clustername
|
||||
= c->myconf->cluster_config->clustername;
|
||||
|
||||
rc = xce_pushconfig_req(c->sched.ep, c->myhost,
|
||||
&configdata);
|
||||
rc = xce_pushconfig_req(c->sched.ep, c->myhost, &configdata);
|
||||
|
||||
free_resval_with_idx_list(&(configdata.data.conf4sched->resvals),
|
||||
configdata.data.conf4sched->nresvals);
|
||||
|
|
@ -120,25 +115,20 @@ static int check_job_(xce_job_t* j)
|
|||
static int xcesched_push_jobs(cluster_t* c)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_jobs_data_t jobs = {
|
||||
.n_total = 0,
|
||||
.pos = 0,
|
||||
.count = 0,
|
||||
.jobs = NULL
|
||||
};
|
||||
int rc = 0;
|
||||
xce_jobs_data_t jobs = { .n_total = 0, .pos = 0, .count = 0, .jobs = NULL };
|
||||
int rc = 0;
|
||||
|
||||
memset(&data, 0x0, sizeof(data));
|
||||
|
||||
data.table = Data_data_schedjobs;
|
||||
data.data.jobs = &jobs;
|
||||
|
||||
collect_jobs(c, (collect_check_fn_t)check_job_,
|
||||
&(jobs.n_total), &(jobs.jobs));
|
||||
collect_jobs(c, (collect_check_fn_t)check_job_, &(jobs.n_total),
|
||||
&(jobs.jobs));
|
||||
jobs.count = jobs.n_total;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
deref_objs(jobs.n_total, (void**)jobs.jobs);
|
||||
FREEUP(jobs.jobs);
|
||||
|
||||
|
|
@ -148,12 +138,8 @@ static int xcesched_push_jobs(cluster_t* c)
|
|||
static int xcesched_push_workers(cluster_t* c)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_workers_data_t workers = {
|
||||
.n_total = 0,
|
||||
.pos = 0,
|
||||
.count = 0,
|
||||
.workers = NULL
|
||||
};
|
||||
xce_workers_data_t workers
|
||||
= { .n_total = 0, .pos = 0, .count = 0, .workers = NULL };
|
||||
int rc = 0;
|
||||
int i;
|
||||
|
||||
|
|
@ -162,12 +148,12 @@ static int xcesched_push_workers(cluster_t* c)
|
|||
data.table = Data_data_schedworkers;
|
||||
data.data.workers = &workers;
|
||||
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_,
|
||||
&(workers.n_total), &(workers.workers));
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_, &(workers.n_total),
|
||||
&(workers.workers));
|
||||
workers.count = workers.n_total;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
|
||||
/* free up collected resource value which used
|
||||
passed to scheduler
|
||||
|
|
@ -175,8 +161,7 @@ static int xcesched_push_workers(cluster_t* c)
|
|||
for (i = 0; i < workers.n_total; i++) {
|
||||
xce_worker_t* w = workers.workers[i];
|
||||
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched),
|
||||
w->nresvals_to_sched);
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched), w->nresvals_to_sched);
|
||||
}
|
||||
|
||||
deref_objs(workers.n_total, (void**)workers.workers);
|
||||
|
|
@ -185,10 +170,7 @@ static int xcesched_push_workers(cluster_t* c)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_new_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_new_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
xlist_t* l = va_arg(ap, xlist_t*);
|
||||
|
|
@ -212,10 +194,7 @@ static int sched_job_new_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_start_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_start_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
job_pidinfo_t* info = va_arg(ap, job_pidinfo_t*);
|
||||
|
|
@ -245,10 +224,7 @@ static int sched_job_start_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_exit_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_exit_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
xce_jobfinish_t* info = va_arg(ap, xce_jobfinish_t*);
|
||||
|
|
@ -278,10 +254,7 @@ static int sched_job_exit_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_fail_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_fail_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
job_failinfo_t* info = va_arg(ap, job_failinfo_t*);
|
||||
|
|
@ -311,10 +284,7 @@ static int sched_job_fail_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_update_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_update_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
job_t* job = va_arg(ap, job_t*);
|
||||
|
|
@ -344,47 +314,34 @@ static int sched_job_update_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
static int sched_job_hook_fun(int type, int situation, int detail, void* data,
|
||||
va_list ap)
|
||||
{
|
||||
switch (detail) {
|
||||
case HOOK_DETAIL_JOB_NEW:
|
||||
return sched_job_new_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_new_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_START:
|
||||
return sched_job_start_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_start_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_EXIT:
|
||||
return sched_job_exit_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_exit_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_UPDATE:
|
||||
return sched_job_update_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_update_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_FAIL:
|
||||
return sched_job_fail_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_fail_fun(type, situation, data, ap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int sched_worker_change(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
cluster_t* c,
|
||||
worker_t* w)
|
||||
static int sched_worker_change(int type, int situation, void* data,
|
||||
cluster_t* c, worker_t* w)
|
||||
{
|
||||
int rc = 0;
|
||||
xlist_t wlist;
|
||||
|
||||
TRACE("%s worker %s idx %d situation %d",
|
||||
__func__, w->host.name,
|
||||
w->idx, situation);
|
||||
TRACE("%s worker %s idx %d situation %d", __func__, w->host.name, w->idx,
|
||||
situation);
|
||||
|
||||
collect_resval_with_idx(&(w->host.resvals),
|
||||
&(w->host.nresvals_to_sched),
|
||||
collect_resval_with_idx(&(w->host.resvals), &(w->host.nresvals_to_sched),
|
||||
&(w->host.resvals_to_sched));
|
||||
|
||||
mylock_lock(&(c->sched.lock));
|
||||
|
|
@ -408,10 +365,7 @@ static int sched_worker_change(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_worker_join(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_join(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
char* name = va_arg(ap, char*);
|
||||
|
|
@ -423,11 +377,9 @@ static int sched_worker_join(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
w = workermgr_lock(&(c->workermgr), name,
|
||||
OBJREF_READ);
|
||||
w = workermgr_lock(&(c->workermgr), name, OBJREF_READ);
|
||||
|
||||
rc = sched_worker_change(type, situation, data,
|
||||
c, w);
|
||||
rc = sched_worker_change(type, situation, data, c, w);
|
||||
|
||||
/* FIXME: need to mark the jobs in this worker */
|
||||
obj_deref(w);
|
||||
|
|
@ -435,10 +387,7 @@ static int sched_worker_join(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_worker_dead(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_dead(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
worker_t* w = va_arg(ap, worker_t*);
|
||||
|
|
@ -448,14 +397,10 @@ static int sched_worker_dead(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return sched_worker_change(type, situation, data,
|
||||
c, w);
|
||||
return sched_worker_change(type, situation, data, c, w);
|
||||
}
|
||||
|
||||
static int sched_worker_update(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_update(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
worker_t* w = va_arg(ap, worker_t*);
|
||||
|
|
@ -464,44 +409,31 @@ static int sched_worker_update(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return sched_worker_change(type, situation, data,
|
||||
c, w);
|
||||
return sched_worker_change(type, situation, data, c, w);
|
||||
}
|
||||
static int sched_worker_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_hook_fun(int type, int situation, int detail,
|
||||
void* data, va_list ap)
|
||||
{
|
||||
switch (detail) {
|
||||
case HOOK_DETAIL_WORKER_JOIN:
|
||||
return sched_worker_join(type, situation,
|
||||
data, ap);
|
||||
return sched_worker_join(type, situation, data, ap);
|
||||
case HOOK_DETAIL_WORKER_DEAD:
|
||||
return sched_worker_dead(type, situation,
|
||||
data, ap);
|
||||
return sched_worker_dead(type, situation, data, ap);
|
||||
case HOOK_DETAIL_WORKER_UPDATE:
|
||||
return sched_worker_update(type, situation,
|
||||
data, ap);
|
||||
return sched_worker_update(type, situation, data, ap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sched_resource_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_resource_hook_fun(int type, int situation, int detail,
|
||||
void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
xce_resval_list_t* resvals = va_arg(ap, xce_resval_list_t*);
|
||||
/* clang-format on */
|
||||
xce_notify_data_t xdata = {
|
||||
.event = NotifyData_data_schedUpdateResvals,
|
||||
.data = {
|
||||
.sched_update_resvals = resvals }
|
||||
};
|
||||
xce_notify_data_t xdata = { .event = NotifyData_data_schedUpdateResvals,
|
||||
.data = { .sched_update_resvals = resvals } };
|
||||
/* clang-format off */
|
||||
int rc = 0;
|
||||
|
||||
|
|
@ -557,10 +489,7 @@ static int sched_queue_update(int type,
|
|||
|
||||
return rc;
|
||||
}
|
||||
static int sched_queue_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
static int sched_queue_hook_fun(int type, int situation, int detail, void* data,
|
||||
va_list ap)
|
||||
{
|
||||
switch (detail) {
|
||||
|
|
@ -588,22 +517,14 @@ int on_scheduler_join(cluster_t* c)
|
|||
if (!hook_installed) {
|
||||
hook_installed = 1;
|
||||
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
(hook_fn_t)sched_job_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
(hook_fn_t)sched_worker_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
(hook_fn_t)sched_resource_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_QUEUE,
|
||||
(hook_fn_t)sched_queue_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB,
|
||||
(hook_fn_t)sched_job_hook_fun, NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER,
|
||||
(hook_fn_t)sched_worker_hook_fun, NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
(hook_fn_t)sched_resource_hook_fun, NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_QUEUE,
|
||||
(hook_fn_t)sched_queue_hook_fun, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -611,8 +532,7 @@ int on_scheduler_join(cluster_t* c)
|
|||
int handle_scheduler_leave(cluster_t* c)
|
||||
{
|
||||
/* we need to mark the cluster status */
|
||||
TRACE("%s scheduler leave",
|
||||
__func__);
|
||||
TRACE("%s scheduler leave", __func__);
|
||||
mylock_lock(&(c->sched.lock));
|
||||
c->sched.ep = NULL;
|
||||
mylock_unlock(&(c->sched.lock));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue