reformat code and job array

This commit is contained in:
Rongsong Shen 2025-11-07 16:14:27 +08:00
parent a665ccd4fe
commit 9ff857db9f
64 changed files with 1497 additions and 2476 deletions

View file

@ -86,9 +86,7 @@ static objtype_t types[] = {
};
/* clang-format on */
static void* xjob_create(objmgr_t* mgr,
objtype_t* type,
va_list ap)
static void* xjob_create(objmgr_t* mgr, objtype_t* type, va_list ap)
{
jobmgr_t* jobmgr = &(((cluster_t*)type->typedata)->jobmgr);
xce_job_t* submit = va_arg(ap, xce_job_t*);
@ -117,32 +115,29 @@ static void* xjob_create(objmgr_t* mgr,
job = MYOBJ_TO_OBJ(job_t*, obj);
/* fill job data */
job->job.jobid = submit->jobid;
job->job.queue = create_obj_by_typename(mgr, "xstring",
submit->queue);
job->job.queue = create_obj_by_typename(mgr, "xstring", submit->queue);
job->job.sub_time = submit->sub_time;
job->job.queue_time = submit->queue_time;
if (job->job.queue_time == 0) {
job->job.queue_time = job->job.sub_time;
}
job->job.state = submit->state;
job->job.user = create_obj_by_typename(mgr, "xstring",
submit->user);
job->job.start_time = submit->start_time;
job->job.finish_time = submit->finish_time;
job->job.job_name = create_obj_by_typename(mgr, "xstring",
submit->job_name);
job->job.project_name = create_obj_by_typename(mgr, "xstring",
submit->project_name);
job->job.user_group = create_obj_by_typename(mgr, "xstring",
submit->user_group);
job->job.job_description = create_obj_by_typename(mgr, "xstring",
submit->job_description);
job->job.resreq = create_obj_by_typename(mgr, "xstring",
submit->resreq);
job->job.run_time = submit->run_time;
job->job.mintasks = submit->mintasks;
job->job.maxtasks = submit->maxtasks;
job->job.pending_ctrl = submit->pending_ctrl;
job->job.state = submit->state;
job->job.user = create_obj_by_typename(mgr, "xstring", submit->user);
job->job.start_time = submit->start_time;
job->job.finish_time = submit->finish_time;
job->job.job_name
= create_obj_by_typename(mgr, "xstring", submit->job_name);
job->job.project_name
= create_obj_by_typename(mgr, "xstring", submit->project_name);
job->job.user_group
= create_obj_by_typename(mgr, "xstring", submit->user_group);
job->job.job_description
= create_obj_by_typename(mgr, "xstring", submit->job_description);
job->job.resreq = create_obj_by_typename(mgr, "xstring", submit->resreq);
job->job.run_time = submit->run_time;
job->job.mintasks = submit->mintasks;
job->job.maxtasks = submit->maxtasks;
job->job.pending_ctrl = submit->pending_ctrl;
job->job.pidinfo = NULL;
@ -152,44 +147,47 @@ static void* xjob_create(objmgr_t* mgr,
SET_ERROR(ENOMEM);
goto clean_job;
}
job->job.pidinfo->npids = copy_int_list((int**)&(job->job.pidinfo->pids),
(int*)submit->pidinfo->pids, submit->pidinfo->npids);
job->job.pidinfo->npgids = copy_int_list((int**)&(job->job.pidinfo->pgids),
(int*)submit->pidinfo->pgids, submit->pidinfo->npgids);
job->job.pidinfo->npids = copy_int_list(
(int**)&(job->job.pidinfo->pids), (int*)submit->pidinfo->pids,
submit->pidinfo->npids);
job->job.pidinfo->npgids = copy_int_list(
(int**)&(job->job.pidinfo->pgids), (int*)submit->pidinfo->pgids,
submit->pidinfo->npgids);
if (submit->pidinfo->exdata) {
job->job.pidinfo->exdata = create_obj_by_typename(mgr, "xstring",
submit->pidinfo->exdata);
job->job.pidinfo->exdata = create_obj_by_typename(
mgr, "xstring", submit->pidinfo->exdata);
}
}
job->job.start_info = NULL;
if (submit->start_info != NULL) {
job->job.start_info = (job_startinfo_t*)calloc(1, sizeof(job_startinfo_t));
job->job.start_info
= (job_startinfo_t*)calloc(1, sizeof(job_startinfo_t));
if (job->job.start_info == NULL) {
SET_ERROR(ENOMEM);
goto clean_job;
}
job->job.start_info->cmdline = create_obj_by_typename(mgr, "xstring",
submit->start_info->cmdline);
job->job.start_info->exdata = create_obj_by_typename(mgr, "xstring",
submit->start_info->exdata);
job->job.start_info->execcwd = create_obj_by_typename(mgr, "xstring",
submit->start_info->execcwd);
job->job.start_info->exechome = create_obj_by_typename(mgr, "xstring",
submit->start_info->exechome);
job->job.start_info->execuser = create_obj_by_typename(mgr, "xstring",
submit->start_info->execuser);
job->job.start_info->launch_type = create_obj_by_typename(mgr, "xstring",
submit->start_info->launch_type);
job->job.start_info->cmdline = create_obj_by_typename(
mgr, "xstring", submit->start_info->cmdline);
job->job.start_info->exdata = create_obj_by_typename(
mgr, "xstring", submit->start_info->exdata);
job->job.start_info->execcwd = create_obj_by_typename(
mgr, "xstring", submit->start_info->execcwd);
job->job.start_info->exechome = create_obj_by_typename(
mgr, "xstring", submit->start_info->exechome);
job->job.start_info->execuser = create_obj_by_typename(
mgr, "xstring", submit->start_info->execuser);
job->job.start_info->launch_type = create_obj_by_typename(
mgr, "xstring", submit->start_info->launch_type);
if (submit->start_info->job_pre_exec != NULL) {
job->job.start_info->job_pre_exec = create_obj_by_typename(mgr, "xstring",
submit->start_info->job_pre_exec);
job->job.start_info->job_pre_exec = create_obj_by_typename(
mgr, "xstring", submit->start_info->job_pre_exec);
}
if (submit->start_info->job_post_exec != NULL) {
job->job.start_info->job_post_exec = create_obj_by_typename(mgr, "xstring",
submit->start_info->job_post_exec);
job->job.start_info->job_post_exec = create_obj_by_typename(
mgr, "xstring", submit->start_info->job_post_exec);
}
}
@ -263,7 +261,8 @@ void job_obj_killer(job_t* job)
for (int i = 0; i < job->job.allocs->nhosts; i++) {
FREEUP(job->job.allocs->allocs[i]->host);
for (int k = 0; k < job->job.allocs->allocs[i]->nallocs; k++) {
xce_alloc_t* alloc = (xce_alloc_t*)job->job.allocs->allocs[i]->allocs[k];
xce_alloc_t* alloc
= (xce_alloc_t*)job->job.allocs->allocs[i]->allocs[k];
if (alloc == NULL) {
continue;
}
@ -329,10 +328,7 @@ static void xjob_fini(void* j)
return;
}
static void xjob_type_fini(objtype_t* typeval)
{
return;
}
static void xjob_type_fini(objtype_t* typeval) { return; }
int register_types(cluster_t* c)
{
@ -351,13 +347,8 @@ int register_types(cluster_t* c)
return 0;
}
void resval_obj_killer(xce_resval_t* v)
{
return;
}
static void* xres_create(objmgr_t* mgr,
objtype_t* type,
va_list ap)
void resval_obj_killer(xce_resval_t* v) { return; }
static void* xres_create(objmgr_t* mgr, objtype_t* type, va_list ap)
{
resmgr_t* resmgr = &(((cluster_t*)type->typedata)->resmgr);
xce_resource_t* r = va_arg(ap, xce_resource_t*);
@ -478,10 +469,7 @@ static void xres_fini(void* p)
return;
}
static void xres_type_fini(objtype_t* typeval)
{
return;
}
static void xres_type_fini(objtype_t* typeval) { return; }
void worker_obj_killer(worker_t* w)
{
@ -496,8 +484,7 @@ void worker_obj_killer(worker_t* w)
DEREF_OBJ(w->host.name);
if ((w->host.thresholds != NULL) && (w->host.nthresholds > 0)) {
free_resource_thresholds(w->host.thresholds,
w->host.nthresholds);
free_resource_thresholds(w->host.thresholds, w->host.nthresholds);
w->host.thresholds = NULL;
w->host.nthresholds = 0;
}
@ -529,9 +516,7 @@ static void kill_resval(void* p)
free(p);
}
static void* xworker_create(objmgr_t* mgr,
objtype_t* typeval,
va_list ap)
static void* xworker_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
{
workermgr_t* workermgr = &(((cluster_t*)typeval->typedata)->workermgr);
worker_t* w = va_arg(ap, worker_t*);
@ -560,8 +545,7 @@ static void* xworker_create(objmgr_t* mgr,
return NULL;
}
w1->host.name = create_obj_by_typename(mgr, "xstring",
w->host.name);
w1->host.name = create_obj_by_typename(mgr, "xstring", w->host.name);
idx = workermgr_add(workermgr, w1);
obj_init(mgr, typeval, idx, obj);
@ -571,8 +555,7 @@ static void* xworker_create(objmgr_t* mgr,
w1 = obj_ref(w1, OBJREF_UPDATE);
w1->host.attrs->hosttype = NULL;
w1->host.attrs->hostmodel = NULL;
zarray_init(&(w1->host.resvals), 64,
kill_resval);
zarray_init(&(w1->host.resvals), 64, kill_resval);
}
DEREF_OBJ(w1->host.attrs->hosttype);
@ -581,13 +564,15 @@ static void* xworker_create(objmgr_t* mgr,
if (w->host.attrs) {
memcpy(w1->host.attrs, w->host.attrs, sizeof(*(w1->host.attrs)));
w1->host.attrs->hosttype = create_obj_by_typename(mgr, "xstring",
w->host.attrs->hosttype);
w1->host.attrs->hostmodel = create_obj_by_typename(mgr, "xstring",
w->host.attrs->hostmodel);
w1->host.attrs->hosttype
= create_obj_by_typename(mgr, "xstring", w->host.attrs->hosttype);
w1->host.attrs->hostmodel
= create_obj_by_typename(mgr, "xstring", w->host.attrs->hostmodel);
} else {
w1->host.attrs->hosttype = create_obj_by_typename(mgr, "xstring", "Unknown");
w1->host.attrs->hostmodel = create_obj_by_typename(mgr, "xstring", "Unknown");
w1->host.attrs->hosttype
= create_obj_by_typename(mgr, "xstring", "Unknown");
w1->host.attrs->hostmodel
= create_obj_by_typename(mgr, "xstring", "Unknown");
}
/* clang-format off */
@ -627,10 +612,7 @@ static void xworker_fini(void* p)
return;
}
static void xworker_type_fini(objtype_t* typeval)
{
return;
}
static void xworker_type_fini(objtype_t* typeval) { return; }
void queue_obj_killer(queue_t* q)
{
@ -712,9 +694,7 @@ void queue_obj_killer(queue_t* q)
FREEUP(obj);
}
static void* xqueue_create(objmgr_t* mgr,
objtype_t* typeval,
va_list ap)
static void* xqueue_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
{
qmgr_t* qmgr = &(((cluster_t*)typeval->typedata)->qmgr);
queue_t* q = va_arg(ap, queue_t*);
@ -742,8 +722,7 @@ static void* xqueue_create(objmgr_t* mgr,
}
q1 = MYOBJ_TO_OBJ(queue_t*, obj);
q1->queue.queue = create_obj_by_typename(mgr, "xstring",
q->queue.queue);
q1->queue.queue = create_obj_by_typename(mgr, "xstring", q->queue.queue);
if (q1->queue.queue == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -759,8 +738,8 @@ static void* xqueue_create(objmgr_t* mgr,
q1->queue.post_exec = NULL;
if (q->queue.resreq != NULL) {
q1->queue.resreq = create_obj_by_typename(mgr, "xstring",
q->queue.resreq);
q1->queue.resreq
= create_obj_by_typename(mgr, "xstring", q->queue.resreq);
if (q1->queue.resreq == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -769,8 +748,8 @@ static void* xqueue_create(objmgr_t* mgr,
}
if (q->queue.pre_exec != NULL) {
q1->queue.pre_exec = create_obj_by_typename(mgr, "xstring",
q->queue.pre_exec);
q1->queue.pre_exec
= create_obj_by_typename(mgr, "xstring", q->queue.pre_exec);
if (q1->queue.pre_exec == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -779,8 +758,8 @@ static void* xqueue_create(objmgr_t* mgr,
}
if (q->queue.post_exec != NULL) {
q1->queue.post_exec = create_obj_by_typename(mgr, "xstring",
q->queue.post_exec);
q1->queue.post_exec
= create_obj_by_typename(mgr, "xstring", q->queue.post_exec);
if (q1->queue.post_exec == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -807,11 +786,12 @@ static void* xqueue_create(objmgr_t* mgr,
return NULL;
}
if (q->queue.users->name) {
q1->queue.users->name = create_obj_by_typename(mgr, "xstring",
q->queue.users->name);
q1->queue.users->name
= create_obj_by_typename(mgr, "xstring", q->queue.users->name);
}
q1->queue.users->members.count = q->queue.users->members.count;
q1->queue.users->members.data = (char**)calloc(q1->queue.users->members.count, sizeof(char*));
q1->queue.users->members.data
= (char**)calloc(q1->queue.users->members.count, sizeof(char*));
if (q1->queue.users->members.data == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -821,11 +801,12 @@ static void* xqueue_create(objmgr_t* mgr,
if (q->queue.users->members.data[i] == NULL) {
continue;
}
q1->queue.users->members.data[i] = create_obj_by_typename(mgr, "xstring",
q->queue.users->members.data[i]);
q1->queue.users->members.data[i] = create_obj_by_typename(
mgr, "xstring", q->queue.users->members.data[i]);
}
q1->queue.users->ex_members.count = q->queue.users->ex_members.count;
q1->queue.users->ex_members.data = (char**)calloc(q1->queue.users->ex_members.count, sizeof(char*));
q1->queue.users->ex_members.data
= (char**)calloc(q1->queue.users->ex_members.count, sizeof(char*));
if (q1->queue.users->ex_members.data == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -835,8 +816,8 @@ static void* xqueue_create(objmgr_t* mgr,
if (q->queue.users->ex_members.data[i] == NULL) {
continue;
}
q1->queue.users->ex_members.data[i] = create_obj_by_typename(mgr, "xstring",
q->queue.users->ex_members.data[i]);
q1->queue.users->ex_members.data[i] = create_obj_by_typename(
mgr, "xstring", q->queue.users->ex_members.data[i]);
}
}
if (q->queue.hosts != NULL) {
@ -847,11 +828,12 @@ static void* xqueue_create(objmgr_t* mgr,
return NULL;
}
if (q->queue.hosts->name) {
q1->queue.hosts->name = create_obj_by_typename(mgr, "xstring",
q->queue.hosts->name);
q1->queue.hosts->name
= create_obj_by_typename(mgr, "xstring", q->queue.hosts->name);
}
q1->queue.hosts->members.count = q->queue.hosts->members.count;
q1->queue.hosts->members.data = (char**)calloc(q1->queue.hosts->members.count, sizeof(char*));
q1->queue.hosts->members.data
= (char**)calloc(q1->queue.hosts->members.count, sizeof(char*));
if (q1->queue.hosts->members.data == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -861,11 +843,12 @@ static void* xqueue_create(objmgr_t* mgr,
if (q->queue.hosts->members.data[i] == NULL) {
continue;
}
q1->queue.hosts->members.data[i] = create_obj_by_typename(mgr, "xstring",
q->queue.hosts->members.data[i]);
q1->queue.hosts->members.data[i] = create_obj_by_typename(
mgr, "xstring", q->queue.hosts->members.data[i]);
}
q1->queue.hosts->ex_members.count = q->queue.hosts->ex_members.count;
q1->queue.hosts->ex_members.data = (char**)calloc(q1->queue.hosts->ex_members.count, sizeof(char*));
q1->queue.hosts->ex_members.data
= (char**)calloc(q1->queue.hosts->ex_members.count, sizeof(char*));
if (q1->queue.hosts->ex_members.data == NULL) {
queue_obj_killer(q1);
SET_ERROR(ENOMEM);
@ -875,19 +858,21 @@ static void* xqueue_create(objmgr_t* mgr,
if (q->queue.hosts->ex_members.data[i] == NULL) {
continue;
}
q1->queue.hosts->ex_members.data[i] = create_obj_by_typename(mgr, "xstring",
q->queue.hosts->ex_members.data[i]);
q1->queue.hosts->ex_members.data[i] = create_obj_by_typename(
mgr, "xstring", q->queue.hosts->ex_members.data[i]);
}
}
q1->queue.runwindow_config = NULL;
if (q->queue.runwindow_config != NULL) {
q1->queue.runwindow_config = dup_timewindow_config(q->queue.runwindow_config);
q1->queue.runwindow_config
= dup_timewindow_config(q->queue.runwindow_config);
}
q1->queue.dispatchwindow_config = NULL;
if (q->queue.dispatchwindow_config != NULL) {
q1->queue.dispatchwindow_config = dup_timewindow_config(q->queue.dispatchwindow_config);
q1->queue.dispatchwindow_config
= dup_timewindow_config(q->queue.dispatchwindow_config);
}
/* leave run windows parse & dispatch parse later */
@ -920,25 +905,14 @@ static void xqueue_fini(void* p)
return;
}
static void xqueue_type_fini(objtype_t* typeval)
{
return;
}
static void xqueue_type_fini(objtype_t* typeval) { return; }
static void* xresval_create(objmgr_t* mgr,
objtype_t* typeval,
va_list ap)
static void* xresval_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
{
return NULL;
}
static void xresval_fini(void* r)
{
return;
}
static void xresval_type_fini(objtype_t* typeval)
{
return;
}
static void xresval_fini(void* r) { return; }
static void xresval_type_fini(objtype_t* typeval) { return; }
void config_obj_killer(xce_config_t* c)
{
@ -955,9 +929,7 @@ void config_obj_killer(xce_config_t* c)
FREEUP(obj);
}
static void* xconfig_create(objmgr_t* mgr,
objtype_t* typeval,
va_list ap)
static void* xconfig_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
{
cluster_t* c = (cluster_t*)typeval->typedata;
xce_config_t* kv = va_arg(ap, xce_config_t*);
@ -988,10 +960,8 @@ static void* xconfig_create(objmgr_t* mgr,
}
kv1 = MYOBJ_TO_OBJ(xce_config_t*, obj);
kv1->name = create_obj_by_typename(mgr, "xstring",
kv->name);
kv1->value = create_obj_by_typename(mgr, "xstring",
kv->value);
kv1->name = create_obj_by_typename(mgr, "xstring", kv->name);
kv1->value = create_obj_by_typename(mgr, "xstring", kv->value);
if ((kv1->name == NULL) || (kv1->value == NULL)) {
config_obj_killer(kv1);
SET_ERROR(ENOMEM);
@ -1023,22 +993,11 @@ static void xconfig_fini(void* p)
return;
}
static void xconfig_type_fini(objtype_t* typeval)
{
return;
}
static void xconfig_type_fini(objtype_t* typeval) { return; }
static void* xgroup_create(objmgr_t* mgr,
objtype_t* typeval,
va_list ap)
static void* xgroup_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
{
return NULL;
}
static void xgroup_fini(void* g)
{
return;
}
static void xgroup_type_fini(objtype_t* typeval)
{
return;
}
static void xgroup_fini(void* g) { return; }
static void xgroup_type_fini(objtype_t* typeval) { return; }