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

@ -9,23 +9,17 @@
#include "utils.h"
#include "xce/cluster_def.h"
static int
do_reply_reslist(cluster_t* c,
endpoint_t* ep,
xce_request_t* request)
static int do_reply_reslist(cluster_t* c, endpoint_t* ep,
xce_request_t* request)
{
xce_reply_t reply;
xce_resource_data_t resdata;
xce_data_t getdata = {
.table = request->body.getmsg->table,
.data = {
.resources = &resdata }
};
int rc = 0;
xce_data_t getdata = { .table = request->body.getmsg->table,
.data = { .resources = &resdata } };
int rc = 0;
init_reply_by_req(&reply, request);
collect_resources(c, NULL, &(resdata.n_total),
&(resdata.resources));
collect_resources(c, NULL, &(resdata.n_total), &(resdata.resources));
reply.status = 0;
reply.data_which = RequestReply_data_getdata;
@ -39,24 +33,17 @@ do_reply_reslist(cluster_t* c,
return rc;
}
static int
do_reply_resvals(cluster_t* c,
endpoint_t* ep,
xce_request_t* request)
static int do_reply_resvals(cluster_t* c, endpoint_t* ep,
xce_request_t* request)
{
xce_reply_t reply;
xce_resval_data_t resvaldata;
xce_get_t* getmsg = request->body.getmsg;
xce_data_t getdata = {
.data = {
.resvals = &resvaldata }
};
int rc = 0;
xce_val_t val;
xce_resval_t resval;
xce_resval_t* vals[] = {
&resval
};
xce_data_t getdata = { .data = { .resvals = &resvaldata } };
int rc = 0;
xce_val_t val;
xce_resval_t resval;
xce_resval_t* vals[] = { &resval };
init_reply_by_req(&reply, request);
@ -69,8 +56,7 @@ do_reply_resvals(cluster_t* c,
if (condition != NULL) {
getdata.table = getmsg->table;
rc = get_resval(c, condition->condition.reskey->resname,
condition->condition.reskey->hostname,
&val);
condition->condition.reskey->hostname, &val);
if (rc >= 0) {
resval.val = &val;
resval.name = condition->condition.reskey->resname;
@ -103,10 +89,8 @@ int check_worker_(xce_worker_t* w)
return 1;
}
static int
do_reply_workerlist(cluster_t* c,
endpoint_t* ep,
xce_request_t* request)
static int do_reply_workerlist(cluster_t* c, endpoint_t* ep,
xce_request_t* request)
{
xce_reply_t reply;
xce_workers_data_t workerdata;
@ -121,21 +105,19 @@ do_reply_workerlist(cluster_t* c,
int i;
init_reply_by_req(&reply, request);
collect_workers(c, (collect_check_fn_t)check_worker_,
&(workerdata.n_total), &(workerdata.workers));
collect_workers(c, (collect_check_fn_t)check_worker_, &(workerdata.n_total),
&(workerdata.workers));
reply.status = 0;
reply.data_which = RequestReply_data_getdata;
reply.data.getdata = &getdata;
rc = xce_reply_get(ep, c->myhost, &reply,
check_controller, c, 100);
rc = xce_reply_get(ep, c->myhost, &reply, check_controller, c, 100);
for (i = 0; i < workerdata.n_total; i++) {
xce_worker_t* w = workerdata.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(workerdata.n_total, (void**)workerdata.workers);
@ -153,30 +135,24 @@ static int check_job_(xce_job_t* j)
return 1;
}
static int
do_reply_joblist(cluster_t* c,
endpoint_t* ep,
xce_request_t* request)
static int do_reply_joblist(cluster_t* c, endpoint_t* ep,
xce_request_t* request)
{
xce_reply_t reply;
xce_jobs_data_t jobdata;
xce_data_t getdata = {
.table = request->body.getmsg->table,
.data = {
.jobs = &jobdata }
};
int rc = 0;
xce_data_t getdata = { .table = request->body.getmsg->table,
.data = { .jobs = &jobdata } };
int rc = 0;
init_reply_by_req(&reply, request);
collect_jobs(c, (collect_check_fn_t)check_job_,
&(jobdata.n_total), &(jobdata.jobs));
collect_jobs(c, (collect_check_fn_t)check_job_, &(jobdata.n_total),
&(jobdata.jobs));
reply.status = 0;
reply.data_which = RequestReply_data_getdata;
reply.data.getdata = &getdata;
rc = xce_reply_get(ep, c->myhost, &reply,
check_controller, c, 100);
rc = xce_reply_get(ep, c->myhost, &reply, check_controller, c, 100);
deref_objs(jobdata.n_total, (void**)jobdata.jobs);
FREEUP(jobdata.jobs);
@ -184,15 +160,12 @@ do_reply_joblist(cluster_t* c,
return rc;
}
int do_get_op(cluster_t* c,
endpoint_t* ep,
xce_request_t* request)
int do_get_op(cluster_t* c, endpoint_t* ep, xce_request_t* request)
{
int rc = 0;
xce_reply_t reply;
TRACE("%s table %d",
__func__, request->body.getmsg->table);
TRACE("%s table %d", __func__, request->body.getmsg->table);
init_reply_by_req(&reply, request);