forked from lei.chen/myxce
save works
This commit is contained in:
parent
b748e30d20
commit
f4b1ba4cd7
21 changed files with 373 additions and 324 deletions
|
|
@ -256,7 +256,7 @@ static int apiserver_job_update_fun(int type, int situation, void* data,
|
|||
int rc;
|
||||
xce_notify_data_t xdata
|
||||
= { .event = NotifyData_data_updateJob,
|
||||
.data = { .update_job = job->job } };
|
||||
.data = { .update_job = &(job->job) } };
|
||||
|
||||
rc = notify(c, c->apiservers[i].ep, &xdata);
|
||||
if (rc < 0) {
|
||||
|
|
@ -351,11 +351,11 @@ static int apiserver_worker_change(int type, int situation, void* data,
|
|||
{
|
||||
int i;
|
||||
|
||||
TRACE("%s worker %s idx %d situation %d", __func__, w->host->name, w->idx,
|
||||
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),
|
||||
&(w->host->resvals_to_sched));
|
||||
collect_resval_with_idx(&(w->host.resvals), &(w->host.nresvals_to_sched),
|
||||
&(w->host.resvals_to_sched));
|
||||
|
||||
switch (situation) {
|
||||
case HOOK_AFTER_EVENT:
|
||||
|
|
@ -383,8 +383,8 @@ static int apiserver_worker_change(int type, int situation, void* data,
|
|||
break;
|
||||
}
|
||||
|
||||
free_resval_with_idx_list(&(w->host->resvals_to_sched),
|
||||
w->host->nresvals_to_sched);
|
||||
free_resval_with_idx_list(&(w->host.resvals_to_sched),
|
||||
w->host.nresvals_to_sched);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -402,7 +402,7 @@ static int apiserver_worker_join(int type, int situation, void* data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
rc = key_find(c->workermgr, (void *)name, (void **)&w);
|
||||
rc = key_find(c->workermgr, (void*)name, (void**)&w);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -514,7 +514,7 @@ static int apiserver_queue_hook_fun(int type, int situation, int detail,
|
|||
int rc;
|
||||
xce_notify_data_t xdata
|
||||
= { .event = NotifyData_data_schedUpdateQueue,
|
||||
.data = { .sched_update_queue = q->queue } };
|
||||
.data = { .sched_update_queue = &(q->queue) } };
|
||||
|
||||
rc = notify(c, c->apiservers[i].ep, &xdata);
|
||||
if (rc < 0) {
|
||||
|
|
|
|||
|
|
@ -515,26 +515,18 @@ int cluster_init(cluster_t* c)
|
|||
kvmgr_params_t resmgr_params
|
||||
= { .key_type = KVMGR_KEY_STRING,
|
||||
.dynamic = 1,
|
||||
.nslots = c->myconf->cluster_config->resmgr->nhash_slots,
|
||||
.delta = c->myconf->cluster_config->resmgr->delta,
|
||||
.datakiller = (destroy_fn_t)res_obj_killer };
|
||||
kvmgr_params_t jobmgr_params
|
||||
= { .key_type = KVMGR_KEY_INT,
|
||||
.dynamic = 1,
|
||||
.nslots = c->myconf->cluster_config->jobmgr->nhash_slots,
|
||||
.delta = c->myconf->cluster_config->jobmgr->delta,
|
||||
.datakiller = (destroy_fn_t)job_obj_killer };
|
||||
kvmgr_params_t workermgr_params
|
||||
= { .key_type = KVMGR_KEY_STRING,
|
||||
.dynamic = 1,
|
||||
.nslots = c->myconf->cluster_config->workermgr->nhash_slots,
|
||||
.delta = c->myconf->cluster_config->workermgr->delta,
|
||||
.datakiller = (destroy_fn_t)worker_obj_killer };
|
||||
kvmgr_params_t qmgr_params
|
||||
= { .key_type = KVMGR_KEY_STRING,
|
||||
.dynamic = 0,
|
||||
.nslots = c->myconf->cluster_config->qmgr->nhash_slots,
|
||||
.delta = c->myconf->cluster_config->qmgr->delta,
|
||||
.datakiller = (destroy_fn_t)queue_obj_killer };
|
||||
|
||||
if (c == NULL) {
|
||||
|
|
@ -565,6 +557,15 @@ int cluster_init(cluster_t* c)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
resmgr_params.nslots = c->myconf->cluster_config->resmgr->nhash_slots;
|
||||
resmgr_params.delta = c->myconf->cluster_config->resmgr->delta;
|
||||
jobmgr_params.nslots = c->myconf->cluster_config->jobmgr->nhash_slots;
|
||||
jobmgr_params.delta = c->myconf->cluster_config->jobmgr->delta;
|
||||
workermgr_params.nslots = c->myconf->cluster_config->workermgr->nhash_slots;
|
||||
workermgr_params.delta = c->myconf->cluster_config->workermgr->delta;
|
||||
qmgr_params.nslots = c->myconf->cluster_config->qmgr->nhash_slots;
|
||||
qmgr_params.delta = c->myconf->cluster_config->qmgr->delta;
|
||||
|
||||
c->configmgr = makeInstance(&xkvmgr_type, &config_mgr_params);
|
||||
|
||||
objmgr_init(&(c->objmgr));
|
||||
|
|
@ -644,13 +645,13 @@ static int check_worker_timeout_(cluster_t* c, worker_t* w)
|
|||
|
||||
if (now - ep->ts_last_in > timeout) {
|
||||
TRACE("%s worker %s becomes UNAVAIL as heartbeat timeout", __func__,
|
||||
w->host->name);
|
||||
w->host.name);
|
||||
|
||||
mark_worker_unavail(c, w);
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
if (IS_WORKER_UNAVAIL(w->host->status)) {
|
||||
if (IS_WORKER_UNAVAIL(w->host.status)) {
|
||||
mark_worker_back(c, w);
|
||||
}
|
||||
}
|
||||
|
|
@ -659,13 +660,12 @@ static int check_worker_timeout_(cluster_t* c, worker_t* w)
|
|||
if (DATAQ_EMPTY(&(ep->outq))) {
|
||||
int rc = 0;
|
||||
|
||||
TRACE("%s send heartbeat to %s", __func__, w->host->name);
|
||||
TRACE("%s send heartbeat to %s", __func__, w->host.name);
|
||||
|
||||
rc = make_heartbeat(c, ep);
|
||||
|
||||
if (rc < 0) {
|
||||
ERROR("%s make_heartbeat to %s failed", __func__,
|
||||
w->host->name);
|
||||
ERROR("%s make_heartbeat to %s failed", __func__, w->host.name);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,7 @@ static job_t* create_job(cluster_t* c, xce_job_t* j)
|
|||
{
|
||||
job_t* job = NULL;
|
||||
|
||||
job = calloc(1, sizeof(*job));
|
||||
if (job == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* FIXME: */
|
||||
job->job = makeJob(j);
|
||||
job = makeJob(c->jobmgr, j);
|
||||
|
||||
return job;
|
||||
}
|
||||
|
|
@ -198,9 +192,9 @@ static int dispatch_a_job_(cluster_t* c, endpoint_t* ep, xce_job_alloc_t* alloc)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
if ((w->ep == NULL) || (w->host->status != 0)) {
|
||||
if ((w->ep == NULL) || (w->host.status != 0)) {
|
||||
ERROR("worker %s is not in correct state, status %x ep %p",
|
||||
w->host->name, w->host->status, w->ep);
|
||||
w->host.name, w->host.status, w->ep);
|
||||
free_launchinfo(&launchinfo);
|
||||
|
||||
obj_deref(w);
|
||||
|
|
@ -215,41 +209,40 @@ static int dispatch_a_job_(cluster_t* c, endpoint_t* ep, xce_job_alloc_t* alloc)
|
|||
char* q_pre_exec;
|
||||
char* q_post_exec;
|
||||
|
||||
rc = get_queue_exec(c, j->job->submit->queue, &q_pre_exec,
|
||||
&q_post_exec);
|
||||
rc = get_queue_exec(c, j->job.submit->queue, &q_pre_exec, &q_post_exec);
|
||||
if (rc < 0) {
|
||||
obj_deref(j);
|
||||
obj_deref(w);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (j->job->submit->start_info->q_pre_exec != NULL) {
|
||||
obj_deref(j->job->submit->start_info->q_pre_exec);
|
||||
if (j->job.submit->start_info->q_pre_exec != NULL) {
|
||||
obj_deref(j->job.submit->start_info->q_pre_exec);
|
||||
}
|
||||
|
||||
if (j->job->submit->start_info->q_post_exec != NULL) {
|
||||
obj_deref(j->job->submit->start_info->q_post_exec);
|
||||
if (j->job.submit->start_info->q_post_exec != NULL) {
|
||||
obj_deref(j->job.submit->start_info->q_post_exec);
|
||||
}
|
||||
|
||||
j->job->submit->start_info->q_pre_exec = q_pre_exec;
|
||||
j->job->submit->start_info->q_post_exec = q_post_exec;
|
||||
j->job.submit->start_info->q_pre_exec = q_pre_exec;
|
||||
j->job.submit->start_info->q_post_exec = q_post_exec;
|
||||
}
|
||||
|
||||
einfo.jobid = alloc->jobid;
|
||||
einfo.start_info = j->job->submit->start_info;
|
||||
einfo.start_info = j->job.submit->start_info;
|
||||
einfo.launchinfo = &launchinfo;
|
||||
|
||||
rc = xce_startjob_req(w->ep, &einfo);
|
||||
|
||||
free_launchinfo(&launchinfo);
|
||||
|
||||
if (j->job->allocs != NULL) {
|
||||
free_JobAlloc_ptr(&(j->job->allocs));
|
||||
if (j->job.allocs != NULL) {
|
||||
free_JobAlloc_ptr(&(j->job.allocs));
|
||||
}
|
||||
j->job->allocs = (xce_job_alloc_t*)calloc(1, sizeof(xce_job_alloc_t));
|
||||
j->job->allocs->jobid = alloc->jobid;
|
||||
j->job->allocs->nhosts = nc;
|
||||
MOVE_PTR(j->job->allocs->allocs, allocs);
|
||||
j->job.allocs = (xce_job_alloc_t*)calloc(1, sizeof(xce_job_alloc_t));
|
||||
j->job.allocs->jobid = alloc->jobid;
|
||||
j->job.allocs->nhosts = nc;
|
||||
MOVE_PTR(j->job.allocs->allocs, allocs);
|
||||
alloc->allocs = NULL;
|
||||
|
||||
DEREF_OBJ(w);
|
||||
|
|
@ -282,8 +275,8 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (j->job->allocs != NULL) {
|
||||
xce_host_alloc_t** allocs = j->job->allocs->allocs;
|
||||
if (j->job.allocs != NULL) {
|
||||
xce_host_alloc_t** allocs = j->job.allocs->allocs;
|
||||
worker_t* w = NULL;
|
||||
|
||||
/* job control command will be sent to first node
|
||||
|
|
@ -295,15 +288,15 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
|
|||
}
|
||||
if (w != NULL) {
|
||||
/* FIXME: better method to check host status */
|
||||
if ((w->ep != NULL) && (w->host->status == 0)) {
|
||||
if ((w->ep != NULL) && (w->host.status == 0)) {
|
||||
rc = xce_jobctrl_req(w->ep, ctrinfo);
|
||||
if (rc < 0) {
|
||||
ERROR("job ctrl %ld on host %s returns %d", jobid,
|
||||
w->host->name, rc);
|
||||
w->host.name, rc);
|
||||
}
|
||||
} else {
|
||||
ERROR("worker %s is not in correct state, status %x ep %p",
|
||||
w->host->name, w->host->status, w->ep);
|
||||
w->host.name, w->host.status, w->ep);
|
||||
rc = -errno;
|
||||
}
|
||||
obj_deref(w);
|
||||
|
|
@ -322,9 +315,9 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
|
|||
case JobControl_u_siginfo:
|
||||
switch (ctrinfo->u.siginfo->signo) {
|
||||
case SIGCONT:
|
||||
if (j->job->state
|
||||
if (j->job.state
|
||||
& (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP)) {
|
||||
int state = j->job->state;
|
||||
int state = j->job.state;
|
||||
|
||||
/* resume suspend job? */
|
||||
state &= ~(JOB_STAT_PSUSP | JOB_STAT_USUSP);
|
||||
|
|
@ -333,9 +326,9 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
|
|||
break;
|
||||
case SIGSTOP:
|
||||
case SIGTSTP:
|
||||
if (!(j->job->state
|
||||
if (!(j->job.state
|
||||
& (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP))) {
|
||||
int state = j->job->state;
|
||||
int state = j->job.state;
|
||||
|
||||
state |= JOB_STAT_PSUSP;
|
||||
mark_job_update(c, j, state);
|
||||
|
|
@ -344,7 +337,7 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
|
|||
case SIGKILL:
|
||||
case SIGTERM:
|
||||
default:
|
||||
if (j->job->state
|
||||
if (j->job.state
|
||||
& (JOB_STAT_DONE | JOB_STAT_EXIT | JOB_STAT_ERR)) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -357,8 +350,7 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
|
|||
}
|
||||
break;
|
||||
case JobControl_u_ckptoption:
|
||||
if (j->job->state
|
||||
& (JOB_STAT_DONE | JOB_STAT_EXIT | JOB_STAT_ERR)) {
|
||||
if (j->job.state & (JOB_STAT_DONE | JOB_STAT_EXIT | JOB_STAT_ERR)) {
|
||||
ERROR("job <%ld> has been finished, no checkpoint can be done.",
|
||||
jobid);
|
||||
} else {
|
||||
|
|
@ -509,20 +501,20 @@ static int mark_job_start(cluster_t* c, job_t* job, job_pidinfo_t* info)
|
|||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_START, c, info, job);
|
||||
/* update job information */
|
||||
job->job->state = JOB_STAT_RUN;
|
||||
job->job->start_time = time(NULL);
|
||||
if (job->job->pidinfo == NULL) {
|
||||
job->job->pidinfo = (job_pidinfo_t*)calloc(1, sizeof(job_pidinfo_t));
|
||||
job->job.state = JOB_STAT_RUN;
|
||||
job->job.start_time = time(NULL);
|
||||
if (job->job.pidinfo == NULL) {
|
||||
job->job.pidinfo = (job_pidinfo_t*)calloc(1, sizeof(job_pidinfo_t));
|
||||
}
|
||||
|
||||
job->job->pidinfo->npids = copy_int_list((int**)&(job->job->pidinfo->pids),
|
||||
(int*)info->pids, info->npids);
|
||||
job->job->pidinfo->npgids = copy_int_list(
|
||||
(int**)&(job->job->pidinfo->pgids), (int*)info->pgids, info->npgids);
|
||||
job->job.pidinfo->npids = copy_int_list((int**)&(job->job.pidinfo->pids),
|
||||
(int*)info->pids, info->npids);
|
||||
job->job.pidinfo->npgids = copy_int_list((int**)&(job->job.pidinfo->pgids),
|
||||
(int*)info->pgids, info->npgids);
|
||||
if (info->exdata != NULL) {
|
||||
job->job->pidinfo->exdata = makeString(info->exdata);
|
||||
job->job.pidinfo->exdata = makeString(info->exdata);
|
||||
} else {
|
||||
job->job->pidinfo->exdata = NULL;
|
||||
job->job.pidinfo->exdata = NULL;
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
|
|
@ -556,24 +548,23 @@ static int mark_job_finish(cluster_t* c, job_t* job, xce_jobfinish_t* finish)
|
|||
HOOK_DETAIL_JOB_EXIT, c, finish, job);
|
||||
/* update job information */
|
||||
if (finish->exit_code == 0) {
|
||||
job->job->state = JOB_STAT_DONE;
|
||||
job->job.state = JOB_STAT_DONE;
|
||||
} else {
|
||||
job->job->state = JOB_STAT_EXIT;
|
||||
job->job.state = JOB_STAT_EXIT;
|
||||
}
|
||||
job->job->finish_time = time(NULL);
|
||||
job->job.finish_time = time(NULL);
|
||||
|
||||
/* fill job run time/rusage information */
|
||||
|
||||
if (job->job->exit_info == NULL) {
|
||||
job->job->exit_info
|
||||
= (job_exitinfo_t*)calloc(1, sizeof(job_exitinfo_t));
|
||||
if (job->job.exit_info == NULL) {
|
||||
job->job.exit_info = (job_exitinfo_t*)calloc(1, sizeof(job_exitinfo_t));
|
||||
}
|
||||
|
||||
if (job->job->exit_info != NULL) {
|
||||
job->job->exit_info->exitcode = finish->exit_code;
|
||||
if (job->job.exit_info != NULL) {
|
||||
job->job.exit_info->exitcode = finish->exit_code;
|
||||
}
|
||||
|
||||
job->job->run_time = job->job->finish_time - job->job->start_time;
|
||||
job->job.run_time = job->job.finish_time - job->job.start_time;
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_EXIT, c, finish, job);
|
||||
|
|
@ -609,20 +600,20 @@ static int mark_job_fail(cluster_t* c, job_t* job, job_failinfo_t* failinfo)
|
|||
switch (failinfo->stage) {
|
||||
case JOB_EXEC_STAGE_Q_POST_EXEC:
|
||||
case JOB_EXEC_STAGE_POST_EXEC:
|
||||
if ((job->job->state & (JOB_STAT_EXIT | JOB_STAT_DONE)) == 0) {
|
||||
if ((job->job.state & (JOB_STAT_EXIT | JOB_STAT_DONE)) == 0) {
|
||||
WARN("job %ld got post exec fail notification but job's exit "
|
||||
"status has not been set",
|
||||
job->job->jobid);
|
||||
job->job->state |= JOB_STAT_EXIT;
|
||||
job->job.jobid);
|
||||
job->job.state |= JOB_STAT_EXIT;
|
||||
}
|
||||
job->job->state |= JOB_STAT_PERR;
|
||||
job->job.state |= JOB_STAT_PERR;
|
||||
break;
|
||||
default:
|
||||
job->job->state = JOB_STAT_EXIT;
|
||||
job->job.state = JOB_STAT_EXIT;
|
||||
break;
|
||||
}
|
||||
|
||||
job->job->finish_time = time(NULL);
|
||||
job->job.finish_time = time(NULL);
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_FAIL, c, failinfo, job);
|
||||
|
|
@ -635,7 +626,7 @@ static int mark_job_update(cluster_t* c, job_t* job, int state)
|
|||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_UPDATE, c, job);
|
||||
/* update job state */
|
||||
job->job->state = state;
|
||||
job->job.state = state;
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_UPDATE, c, job);
|
||||
|
|
@ -674,7 +665,7 @@ int on_job_stop(cluster_t* c, uint64_t jobid)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
state = job->job->state;
|
||||
state = job->job.state;
|
||||
|
||||
state |= JOB_STAT_USUSP;
|
||||
mark_job_update(c, job, state);
|
||||
|
|
@ -695,7 +686,7 @@ int on_job_resume(cluster_t* c, uint64_t jobid)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
state = job->job->state;
|
||||
state = job->job.state;
|
||||
state &= ~JOB_STAT_USUSP;
|
||||
mark_job_update(c, job, state);
|
||||
|
||||
|
|
@ -715,14 +706,14 @@ int on_job_postdone(cluster_t* c, endpoint_t* ep, uint64_t jobid)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
state = job->job->state;
|
||||
state = job->job.state;
|
||||
if ((state & (JOB_STAT_EXIT | JOB_STAT_DONE)) == 0) {
|
||||
WARN("job %ld got post exec fail notification but job's exit status "
|
||||
"has not been set",
|
||||
job->job->jobid);
|
||||
job->job.jobid);
|
||||
state |= JOB_STAT_EXIT;
|
||||
/* ensure that job finish time has been set */
|
||||
job->job->finish_time = time(NULL);
|
||||
job->job.finish_time = time(NULL);
|
||||
}
|
||||
|
||||
state |= JOB_STAT_PDONE;
|
||||
|
|
@ -756,11 +747,11 @@ int on_job_ckpt(cluster_t* c, endpoint_t* ep, xce_ckptinfo_t* ckptinfo)
|
|||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_CKPT, c, j);
|
||||
if (j->job->ckptinfo != NULL) {
|
||||
obj_deref(j->job->ckptinfo);
|
||||
if (j->job.ckptinfo != NULL) {
|
||||
obj_deref(j->job.ckptinfo);
|
||||
}
|
||||
|
||||
j->job->ckptinfo = makeString(info);
|
||||
j->job.ckptinfo = makeString(info);
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_CKPT, c, j);
|
||||
|
|
@ -809,7 +800,7 @@ int update_job_rusages(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
|||
return errno;
|
||||
}
|
||||
|
||||
host = makeString(w->host->name);
|
||||
host = makeString(w->host.name);
|
||||
obj_deref(w);
|
||||
|
||||
if (host == NULL) {
|
||||
|
|
@ -821,12 +812,12 @@ int update_job_rusages(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
|||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_UPDATE, c, j);
|
||||
update_host_runusage(&(j->job->run_usage), host, rusages->count,
|
||||
update_host_runusage(&(j->job.run_usage), host, rusages->count,
|
||||
rusages->usages);
|
||||
|
||||
update_pids(&(j->job->pidinfo), rusages->npids, rusages->pids);
|
||||
update_pids(&(j->job.pidinfo), rusages->npids, rusages->pids);
|
||||
|
||||
update_pgids(&(j->job->pidinfo), rusages->npgids, rusages->pgids);
|
||||
update_pgids(&(j->job.pidinfo), rusages->npgids, rusages->pgids);
|
||||
|
||||
/* FIXME
|
||||
* update other fields of job rusage later
|
||||
|
|
@ -856,7 +847,7 @@ static int set_preason(cluster_t* c, xce_pendreason_t* reasons)
|
|||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_SETPREASON, c, j);
|
||||
job = j->job;
|
||||
job = &(j->job);
|
||||
if (job->pend_reasons != NULL) {
|
||||
erase_job_preason(job->pend_reasons);
|
||||
FREEUP(job->pend_reasons);
|
||||
|
|
@ -923,7 +914,7 @@ int do_clr_preason(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
|||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_CLRPREASON, c, j);
|
||||
|
||||
job = j->job;
|
||||
job = &(j->job);
|
||||
if (job->pend_reasons != NULL) {
|
||||
erase_job_preason(job->pend_reasons);
|
||||
FREEUP(job->pend_reasons);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ static int do_reply_joblist(cluster_t* c, endpoint_t* ep,
|
|||
if (rc > 0) {
|
||||
jobdata.jobs = (xce_job_t**)calloc(1, sizeof(xce_job_t*));
|
||||
if (jobdata.jobs != NULL) {
|
||||
jobdata.jobs[0] = j->job;
|
||||
jobdata.jobs[0] = &(j->job);
|
||||
jobdata.n_total = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,7 @@ queue_t* create_queue(cluster_t* c, xce_queue_t* p)
|
|||
{
|
||||
queue_t* q;
|
||||
|
||||
q = calloc(1, sizeof(*q));
|
||||
if (q == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
q->queue = makeQueue(p);
|
||||
q = makeQueue(c->qmgr, p);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
|
@ -72,28 +67,28 @@ int queue_ctrl(cluster_t* c, xce_queuectrl_t* ctrl)
|
|||
|
||||
switch (ctrl->action) {
|
||||
case QUEUE_OPEN:
|
||||
if (!(q->queue->status & QUEUE_STAT_CLOSED)) {
|
||||
if (!(q->queue.status & QUEUE_STAT_CLOSED)) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue->status &= ~QUEUE_STAT_CLOSED;
|
||||
q->queue.status &= ~QUEUE_STAT_CLOSED;
|
||||
break;
|
||||
case QUEUE_CLOSE:
|
||||
if (q->queue->status & QUEUE_STAT_CLOSED) {
|
||||
if (q->queue.status & QUEUE_STAT_CLOSED) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue->status |= QUEUE_STAT_CLOSED;
|
||||
q->queue.status |= QUEUE_STAT_CLOSED;
|
||||
break;
|
||||
case QUEUE_INACTIVE:
|
||||
if (q->queue->status & QUEUE_STAT_INACT_ADMIN) {
|
||||
if (q->queue.status & QUEUE_STAT_INACT_ADMIN) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue->status |= QUEUE_STAT_INACT_ADMIN;
|
||||
q->queue.status |= QUEUE_STAT_INACT_ADMIN;
|
||||
break;
|
||||
case QUEUE_ACTIVE:
|
||||
if (!(q->queue->status & QUEUE_STAT_INACT_ADMIN)) {
|
||||
if (!(q->queue.status & QUEUE_STAT_INACT_ADMIN)) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue->status &= ~QUEUE_STAT_INACT_ADMIN;
|
||||
q->queue.status &= ~QUEUE_STAT_INACT_ADMIN;
|
||||
break;
|
||||
default:
|
||||
rc = -1;
|
||||
|
|
@ -147,14 +142,14 @@ int get_queue_exec(cluster_t* c, char* queue, char** pre_exec, char** post_exec)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (q->queue->pre_exec != NULL) {
|
||||
*pre_exec = makeString(q->queue->pre_exec);
|
||||
if (q->queue.pre_exec != NULL) {
|
||||
*pre_exec = makeString(q->queue.pre_exec);
|
||||
} else {
|
||||
*pre_exec = NULL;
|
||||
}
|
||||
|
||||
if (q->queue->post_exec != NULL) {
|
||||
*post_exec = makeString(q->queue->post_exec);
|
||||
if (q->queue.post_exec != NULL) {
|
||||
*post_exec = makeString(q->queue.post_exec);
|
||||
} else {
|
||||
*post_exec = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ static int sched_job_update_fun(int type, int situation, void* data, va_list ap)
|
|||
xce_notify_data_t xdata = {
|
||||
.event = NotifyData_data_schedUpdateJob,
|
||||
.data = {
|
||||
.sched_update_job = job->job
|
||||
.sched_update_job = &(job->job)
|
||||
}
|
||||
};
|
||||
/* clang-format on */
|
||||
|
|
@ -419,11 +419,11 @@ static int sched_worker_change(int type, int situation, void* data,
|
|||
int rc = 0;
|
||||
xlist_t wlist;
|
||||
|
||||
TRACE("%s worker %s idx %d situation %d", __func__, w->host->name, w->idx,
|
||||
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),
|
||||
&(w->host->resvals_to_sched));
|
||||
collect_resval_with_idx(&(w->host.resvals), &(w->host.nresvals_to_sched),
|
||||
&(w->host.resvals_to_sched));
|
||||
|
||||
mylock_lock(&(c->sched.lock));
|
||||
if (c->sched.ep != NULL) {
|
||||
|
|
@ -440,8 +440,8 @@ static int sched_worker_change(int type, int situation, void* data,
|
|||
}
|
||||
mylock_unlock(&(c->sched.lock));
|
||||
|
||||
free_resval_with_idx_list(&(w->host->resvals_to_sched),
|
||||
w->host->nresvals_to_sched);
|
||||
free_resval_with_idx_list(&(w->host.resvals_to_sched),
|
||||
w->host.nresvals_to_sched);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -458,7 +458,7 @@ static int sched_worker_join(int type, int situation, void* data, va_list ap)
|
|||
return 0;
|
||||
}
|
||||
|
||||
rc = key_find(c->workermgr, (void *)name, (void **)&w);
|
||||
rc = key_find(c->workermgr, (void*)name, (void**)&w);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -558,7 +558,7 @@ static int sched_queue_update(int type,
|
|||
xce_notify_data_t xdata = {
|
||||
.event = NotifyData_data_schedUpdateQueue,
|
||||
.data = {
|
||||
.sched_update_queue = q->queue
|
||||
.sched_update_queue = &(q->queue)
|
||||
}
|
||||
};
|
||||
/* clang-format on */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ static int run_tasks_on_host(cluster_t* c, endpoint_t* ep, uint64_t jobid,
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
if ((w->ep == NULL) || (IS_WORKER_UNAVAIL(w->host->status))) {
|
||||
if ((w->ep == NULL) || (IS_WORKER_UNAVAIL(w->host.status))) {
|
||||
obj_deref(w);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ static int check_task_hosts(cluster_t* c, xce_taskrun_t* runmsg)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
if ((w->ep == NULL) || IS_WORKER_UNAVAIL(w->host->status)) {
|
||||
if ((w->ep == NULL) || IS_WORKER_UNAVAIL(w->host.status)) {
|
||||
return -ENOENT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ static int update_val_res(cluster_t* c, worker_t* w, xce_resource_t* r,
|
|||
array = &(c->sharedinst);
|
||||
} else {
|
||||
/* update host based resource */
|
||||
array = &(w->host->resvals);
|
||||
array = &(w->host.resvals);
|
||||
}
|
||||
|
||||
if (idx < array->caps) {
|
||||
|
|
@ -213,17 +213,16 @@ static int add_hostattrs_resvals(cluster_t* c, worker_t* w)
|
|||
{
|
||||
#define N_HOST_ATTRS (8)
|
||||
xce_val_t values[N_HOST_ATTRS] = {
|
||||
{ .which = Value_u_svalue, .u = { .svalue = w->host.attrs->hosttype } },
|
||||
{ .which = Value_u_svalue,
|
||||
.u = { .svalue = w->host->attrs->hosttype } },
|
||||
{ .which = Value_u_svalue,
|
||||
.u = { .svalue = w->host->attrs->hostmodel } },
|
||||
.u = { .svalue = w->host.attrs->hostmodel } },
|
||||
{ .which = Value_u_fvalue,
|
||||
.u = { .fvalue = w->host->attrs->cpufactor } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->maxcpus } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->maxmem } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->maxswap } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->maxtmp } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->ndisks } }
|
||||
.u = { .fvalue = w->host.attrs->cpufactor } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host.attrs->maxcpus } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host.attrs->maxmem } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host.attrs->maxswap } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host.attrs->maxtmp } },
|
||||
{ .which = Value_u_fvalue, .u = { .fvalue = w->host.attrs->ndisks } }
|
||||
};
|
||||
xce_resval_t resvals[N_HOST_ATTRS] = {
|
||||
{ .name = "type", .val = &values[0] },
|
||||
|
|
@ -266,7 +265,7 @@ int add_worker(void* cls, endpoint_t* ep, const char* host, hostattrs_t* attrs)
|
|||
cluster_t* c = (cluster_t*)cls;
|
||||
/* clang-format off */
|
||||
worker_t worker = {
|
||||
.host = &(xce_worker_t){
|
||||
.host = (xce_worker_t){
|
||||
.name = (char*)host,
|
||||
}
|
||||
};
|
||||
|
|
@ -290,28 +289,28 @@ int add_worker(void* cls, endpoint_t* ep, const char* host, hostattrs_t* attrs)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
worker.host->attrs = attrs;
|
||||
worker.host.attrs = attrs;
|
||||
|
||||
w->host = makeWorker(worker.host);
|
||||
if (w->host == NULL) {
|
||||
w = makeWorker(c->workermgr, &(worker.host));
|
||||
if (w == NULL) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
/* we should hold the update lock */
|
||||
/* If admin makes the host in locked or closed, we need keep this */
|
||||
w->host->status &= ~XCE_WORKER_UNAVAIL; /* status OK */
|
||||
w->host.status &= ~XCE_WORKER_UNAVAIL; /* status OK */
|
||||
w->ep = ep;
|
||||
|
||||
/* override host type? */
|
||||
if (strcmp(hconfig->hosttype, "!") != 0) {
|
||||
dereference(w->host->attrs->hosttype);
|
||||
w->host->attrs->hosttype = makeString(hconfig->hosttype);
|
||||
dereference(w->host.attrs->hosttype);
|
||||
w->host.attrs->hosttype = makeString(hconfig->hosttype);
|
||||
}
|
||||
|
||||
/* override host model */
|
||||
if (strcmp(hconfig->hostmodel, "!") != 0) {
|
||||
dereference(w->host->attrs->hostmodel);
|
||||
w->host->attrs->hostmodel = makeString(hconfig->hostmodel);
|
||||
dereference(w->host.attrs->hostmodel);
|
||||
w->host.attrs->hostmodel = makeString(hconfig->hostmodel);
|
||||
}
|
||||
add_hostattrs_resvals(c, w);
|
||||
idx = w->idx;
|
||||
|
|
@ -319,31 +318,31 @@ int add_worker(void* cls, endpoint_t* ep, const char* host, hostattrs_t* attrs)
|
|||
/* using auto detected or pre configured MXJ? */
|
||||
nslots = hconfig->mxj;
|
||||
if (nslots < 0) {
|
||||
nslots = w->host->attrs->maxcpus;
|
||||
nslots = w->host.attrs->maxcpus;
|
||||
}
|
||||
|
||||
set_host_slots(c, w, nslots);
|
||||
|
||||
if (w->host->dispatch_window_config != NULL) {
|
||||
free_timewindow_config(w->host->dispatch_window_config);
|
||||
w->host->dispatch_window_config = NULL;
|
||||
if (w->host.dispatch_window_config != NULL) {
|
||||
free_timewindow_config(w->host.dispatch_window_config);
|
||||
w->host.dispatch_window_config = NULL;
|
||||
}
|
||||
|
||||
if (hconfig->dispatchwindow != NULL) {
|
||||
w->host->dispatch_window_config
|
||||
w->host.dispatch_window_config
|
||||
= dup_timewindow_config(hconfig->dispatchwindow);
|
||||
}
|
||||
|
||||
if (w->host->thresholds != NULL) {
|
||||
free_resource_thresholds(w->host->thresholds, w->host->nthresholds);
|
||||
w->host->nthresholds = 0;
|
||||
w->host->thresholds = NULL;
|
||||
if (w->host.thresholds != NULL) {
|
||||
free_resource_thresholds(w->host.thresholds, w->host.nthresholds);
|
||||
w->host.nthresholds = 0;
|
||||
w->host.thresholds = NULL;
|
||||
}
|
||||
|
||||
if (hconfig->thresholds != NULL) {
|
||||
w->host->thresholds = dup_resource_thresholds(hconfig->thresholds,
|
||||
hconfig->nthresholds);
|
||||
w->host->nthresholds = hconfig->nthresholds;
|
||||
w->host.thresholds = dup_resource_thresholds(hconfig->thresholds,
|
||||
hconfig->nthresholds);
|
||||
w->host.nthresholds = hconfig->nthresholds;
|
||||
}
|
||||
|
||||
/* add bool resources to host */
|
||||
|
|
@ -361,27 +360,18 @@ int restore_worker(void* cls, xce_worker_t host)
|
|||
cluster_t* c = (cluster_t*)cls;
|
||||
int idx = 0;
|
||||
worker_t* w = NULL;
|
||||
/* do work in add_worker() doing for normal worker join */
|
||||
/* clang-format off */
|
||||
worker_t worker = {
|
||||
.host = &(xce_worker_t){
|
||||
.name = (char*)host.name,
|
||||
.status = host.status,
|
||||
},
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
w = calloc(1, sizeof(*w));
|
||||
if (w == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
w->host = makeWorker(worker.host);
|
||||
if (w->host == NULL) {
|
||||
w = makeWorker(c->workermgr, &host);
|
||||
if (w == NULL) {
|
||||
return -errno;
|
||||
}
|
||||
add_hostattrs_resvals(c, w);
|
||||
idx = w->idx;
|
||||
w->host->status |= XCE_WORKER_UNAVAIL;
|
||||
w->host.status |= XCE_WORKER_UNAVAIL;
|
||||
|
||||
DEREF_OBJ(w);
|
||||
|
||||
|
|
@ -476,7 +466,7 @@ int get_resval(cluster_t* c, char* resname, char* host, xce_val_t* val)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
array = &(w->host->resvals);
|
||||
array = &(w->host.resvals);
|
||||
} else {
|
||||
array = &(c->sharedinst);
|
||||
}
|
||||
|
|
@ -497,7 +487,7 @@ int mark_worker_unavail(cluster_t* c, worker_t* w)
|
|||
{
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_WORKER_DEAD, c, w);
|
||||
w->host->status |= XCE_WORKER_UNAVAIL;
|
||||
w->host.status |= XCE_WORKER_UNAVAIL;
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_DEAD, c, w);
|
||||
|
|
@ -508,7 +498,7 @@ int mark_worker_back(cluster_t* c, worker_t* w)
|
|||
{
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_WORKER_UPDATE, c, w);
|
||||
w->host->status &= ~XCE_WORKER_UNAVAIL;
|
||||
w->host.status &= ~XCE_WORKER_UNAVAIL;
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_UPDATE, c, w);
|
||||
|
|
@ -574,16 +564,16 @@ int worker_ctrl(cluster_t* c, xce_hostctrl_t* ctrl)
|
|||
|
||||
switch (ctrl->action) {
|
||||
case HOST_OPEN:
|
||||
if (!(w->host->status & XCE_WORKER_CLOSED)) {
|
||||
if (!(w->host.status & XCE_WORKER_CLOSED)) {
|
||||
goto clean;
|
||||
}
|
||||
w->host->status &= ~XCE_WORKER_CLOSED;
|
||||
w->host.status &= ~XCE_WORKER_CLOSED;
|
||||
break;
|
||||
case HOST_CLOSE:
|
||||
if (w->host->status & XCE_WORKER_CLOSED) {
|
||||
if (w->host.status & XCE_WORKER_CLOSED) {
|
||||
goto clean;
|
||||
}
|
||||
w->host->status |= XCE_WORKER_CLOSED;
|
||||
w->host.status |= XCE_WORKER_CLOSED;
|
||||
break;
|
||||
default:
|
||||
rc = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue