forked from lei.chen/myxce
merge job rusage and pending reason support
This commit is contained in:
parent
30824ae5ea
commit
cb0c7fe9e7
82 changed files with 4280 additions and 2561 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <time.h>
|
||||
|
||||
#include "cluster.h"
|
||||
#include "preason.h"
|
||||
#include "xce/cluster_def.h"
|
||||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
|
@ -457,7 +458,10 @@ int handle_jobsubmit(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
|||
/* Run hooks to tell scheduler */
|
||||
j = jobmgr_lockjob(&(c->jobmgr), jobid, OBJREF_READ);
|
||||
if (j == NULL) {
|
||||
ERROR("%s fail to lock job %lu", __func__, jobid);
|
||||
char idstring[128];
|
||||
|
||||
fmt_jobid(idstring, sizeof(idstring) - 1, jobid);
|
||||
ERROR("%s fail to lock job %s (%lu)", __func__, idstring, jobid);
|
||||
} else {
|
||||
xlist_init(&jlist, 2);
|
||||
if (xlist_store(&jlist, j) >= 0) {
|
||||
|
|
@ -777,6 +781,9 @@ int update_job_rusages(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
|||
|
||||
TRACE("%s trying to update job(%ld) rusage", __func__, rusages->jobid);
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_RUSAGE_UPDATE, c, rusages);
|
||||
|
||||
j = jobmgr_lockjob(&(c->jobmgr), rusages->jobid, OBJREF_UPDATE);
|
||||
if (j == NULL) {
|
||||
PERROR("jobmgr_lockjob");
|
||||
|
|
@ -815,5 +822,106 @@ int update_job_rusages(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
|||
HOOK_DETAIL_JOB_UPDATE, c, j);
|
||||
|
||||
obj_deref(j);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_RUSAGE_UPDATE, c, rusages);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_preason(cluster_t* c, xce_pendreason_t* reasons)
|
||||
{
|
||||
job_t* j;
|
||||
xce_job_t* job;
|
||||
|
||||
TRACE("%s jobid %ld", __func__, reasons->jobid);
|
||||
|
||||
j = jobmgr_lockjob(&(c->jobmgr), reasons->jobid, OBJREF_UPDATE);
|
||||
if (j == NULL) {
|
||||
PERROR("jobmgr_lockjob");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_SETPREASON, c, j);
|
||||
job = &(j->job);
|
||||
if (job->pend_reasons != NULL) {
|
||||
erase_job_preason(job->pend_reasons);
|
||||
FREEUP(job->pend_reasons);
|
||||
}
|
||||
|
||||
MOVE_PTR(job->pend_reasons, reasons->reasons);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_SETPREASON, c, j);
|
||||
obj_deref(j);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_set_preason(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int i;
|
||||
xce_preason_set_t* reasons = request->body.preasonmsg;
|
||||
xce_reply_t reply;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
reply.status = 0;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
|
||||
xce_reply(ep, c->myhost, &reply);
|
||||
|
||||
for (i = 0; i < reasons->nreasons; i++) {
|
||||
int rc = 0;
|
||||
|
||||
if (reasons->reasons[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = set_preason(c, reasons->reasons[i]);
|
||||
if (rc < 0) {
|
||||
PERROR("set_preason");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_clr_preason(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int i;
|
||||
xce_reply_t reply;
|
||||
xce_clear_reason_t* clreason = request->body.clrpreasonmsg;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
reply.status = 0;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
|
||||
xce_reply(ep, c->myhost, &reply);
|
||||
|
||||
for (i = 0; i < clreason->njobs; i++) {
|
||||
uint64_t jobid = clreason->jobs[i];
|
||||
job_t* j;
|
||||
xce_job_t* job;
|
||||
|
||||
j = jobmgr_lockjob(&(c->jobmgr), jobid, OBJREF_UPDATE);
|
||||
if (j == NULL) {
|
||||
PERROR("jobmgr_lockjob");
|
||||
continue;
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_CLRPREASON, c, j);
|
||||
|
||||
job = &(j->job);
|
||||
if (job->pend_reasons != NULL) {
|
||||
erase_job_preason(job->pend_reasons);
|
||||
FREEUP(job->pend_reasons);
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_CLRPREASON, c, j);
|
||||
|
||||
obj_deref(j);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue