save works
This commit is contained in:
parent
f4b1ba4cd7
commit
acfbec875b
51 changed files with 622 additions and 1175 deletions
|
|
@ -17,9 +17,14 @@ static int do_reply_reslist(cluster_t* c, endpoint_t* ep,
|
|||
xce_data_t getdata = { .table = request->body.getmsg->table,
|
||||
.data = { .resources = &resdata } };
|
||||
int rc = 0;
|
||||
xlist_t rlist;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
collect_resources(c, NULL, &(resdata.n_total), &(resdata.resources));
|
||||
xlist_init(&rlist, 512);
|
||||
|
||||
collect_resources(c, NULL, &rlist);
|
||||
resdata.n_total = rlist.count;
|
||||
resdata.resources = (xce_resource_t**)rlist.data;
|
||||
|
||||
reply.status = 0;
|
||||
reply.data_which = RequestReply_data_getdata;
|
||||
|
|
@ -27,8 +32,7 @@ static int do_reply_reslist(cluster_t* c, endpoint_t* ep,
|
|||
|
||||
rc = xce_reply_get(ep, c->myhost, &reply, NULL, NULL, -1);
|
||||
|
||||
deref_objs(resdata.n_total, (void**)resdata.resources);
|
||||
FREEUP(resdata.resources);
|
||||
xlist_fini(&rlist);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -101,12 +105,16 @@ static int do_reply_workerlist(cluster_t* c, endpoint_t* ep,
|
|||
.workers = &workerdata }
|
||||
};
|
||||
/* clang-format on */
|
||||
int rc = 0;
|
||||
int i;
|
||||
int rc = 0;
|
||||
int i;
|
||||
xlist_t wlist;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_, &(workerdata.n_total),
|
||||
&(workerdata.workers));
|
||||
xlist_init(&wlist, 1024);
|
||||
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_, &wlist);
|
||||
workerdata.n_total = wlist.count;
|
||||
workerdata.workers = (xce_worker_t**)wlist.data;
|
||||
|
||||
reply.status = 0;
|
||||
reply.data_which = RequestReply_data_getdata;
|
||||
|
|
@ -120,21 +128,13 @@ static int do_reply_workerlist(cluster_t* c, endpoint_t* ep,
|
|||
free_resval_with_idx_list(&(w->resvals_to_sched), w->nresvals_to_sched);
|
||||
}
|
||||
|
||||
deref_objs(workerdata.n_total, (void**)workerdata.workers);
|
||||
FREEUP(workerdata.workers);
|
||||
unlock_collect_workers(&wlist);
|
||||
|
||||
xlist_fini(&wlist);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int check_job_(xce_job_t* j)
|
||||
{
|
||||
if (j == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int do_reply_joblist(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
|
|
@ -144,9 +144,12 @@ static int do_reply_joblist(cluster_t* c, endpoint_t* ep,
|
|||
.data = { .jobs = &jobdata } };
|
||||
int rc = 0;
|
||||
xce_match_t* match = request->body.getmsg->condition;
|
||||
xlist_t jlist;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
xlist_init(&jlist, 1024*1024);
|
||||
|
||||
if (match->type == MatchCondition_condition_matchjid) {
|
||||
job_t* j = NULL;
|
||||
|
||||
|
|
@ -155,24 +158,25 @@ static int do_reply_joblist(cluster_t* c, endpoint_t* ep,
|
|||
|
||||
rc = key_find(c->jobmgr, (void*)match->condition.jobid, (void**)&j);
|
||||
if (rc > 0) {
|
||||
jobdata.jobs = (xce_job_t**)calloc(1, sizeof(xce_job_t*));
|
||||
if (jobdata.jobs != NULL) {
|
||||
jobdata.jobs[0] = &(j->job);
|
||||
jobdata.n_total = 1;
|
||||
}
|
||||
lock(j, RTTI_LOCK_WRITE);
|
||||
xlist_store(&jlist, &(j->job));
|
||||
}
|
||||
} else {
|
||||
collect_jobs(c, (collect_check_fn_t)check_job_, &(jobdata.n_total),
|
||||
&(jobdata.jobs));
|
||||
collect_jobs(c, NULL, &jlist);
|
||||
}
|
||||
|
||||
jobdata.n_total = jlist.count;
|
||||
jobdata.jobs = (xce_job_t**)jlist.data;
|
||||
|
||||
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);
|
||||
|
||||
deref_objs(jobdata.n_total, (void**)jobdata.jobs);
|
||||
|
||||
unlock_collect_jobs(&jlist);
|
||||
|
||||
FREEUP(jobdata.jobs);
|
||||
|
||||
return rc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue