save works

This commit is contained in:
Rongsong Shen 2026-03-02 12:14:30 +08:00
parent b748e30d20
commit f4b1ba4cd7
21 changed files with 373 additions and 324 deletions

View file

@ -256,7 +256,7 @@ static int apiserver_job_update_fun(int type, int situation, void* data,
int rc; int rc;
xce_notify_data_t xdata xce_notify_data_t xdata
= { .event = NotifyData_data_updateJob, = { .event = NotifyData_data_updateJob,
.data = { .update_job = job->job } }; .data = { .update_job = &(job->job) } };
rc = notify(c, c->apiservers[i].ep, &xdata); rc = notify(c, c->apiservers[i].ep, &xdata);
if (rc < 0) { if (rc < 0) {
@ -351,11 +351,11 @@ static int apiserver_worker_change(int type, int situation, void* data,
{ {
int i; 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); situation);
collect_resval_with_idx(&(w->host->resvals), &(w->host->nresvals_to_sched), collect_resval_with_idx(&(w->host.resvals), &(w->host.nresvals_to_sched),
&(w->host->resvals_to_sched)); &(w->host.resvals_to_sched));
switch (situation) { switch (situation) {
case HOOK_AFTER_EVENT: case HOOK_AFTER_EVENT:
@ -383,8 +383,8 @@ static int apiserver_worker_change(int type, int situation, void* data,
break; break;
} }
free_resval_with_idx_list(&(w->host->resvals_to_sched), free_resval_with_idx_list(&(w->host.resvals_to_sched),
w->host->nresvals_to_sched); w->host.nresvals_to_sched);
return 0; return 0;
} }
@ -402,7 +402,7 @@ static int apiserver_worker_join(int type, int situation, void* data,
return 0; return 0;
} }
rc = key_find(c->workermgr, (void *)name, (void **)&w); rc = key_find(c->workermgr, (void*)name, (void**)&w);
if (rc < 0) { if (rc < 0) {
return rc; return rc;
} }
@ -514,7 +514,7 @@ static int apiserver_queue_hook_fun(int type, int situation, int detail,
int rc; int rc;
xce_notify_data_t xdata xce_notify_data_t xdata
= { .event = NotifyData_data_schedUpdateQueue, = { .event = NotifyData_data_schedUpdateQueue,
.data = { .sched_update_queue = q->queue } }; .data = { .sched_update_queue = &(q->queue) } };
rc = notify(c, c->apiservers[i].ep, &xdata); rc = notify(c, c->apiservers[i].ep, &xdata);
if (rc < 0) { if (rc < 0) {

View file

@ -515,26 +515,18 @@ int cluster_init(cluster_t* c)
kvmgr_params_t resmgr_params kvmgr_params_t resmgr_params
= { .key_type = KVMGR_KEY_STRING, = { .key_type = KVMGR_KEY_STRING,
.dynamic = 1, .dynamic = 1,
.nslots = c->myconf->cluster_config->resmgr->nhash_slots,
.delta = c->myconf->cluster_config->resmgr->delta,
.datakiller = (destroy_fn_t)res_obj_killer }; .datakiller = (destroy_fn_t)res_obj_killer };
kvmgr_params_t jobmgr_params kvmgr_params_t jobmgr_params
= { .key_type = KVMGR_KEY_INT, = { .key_type = KVMGR_KEY_INT,
.dynamic = 1, .dynamic = 1,
.nslots = c->myconf->cluster_config->jobmgr->nhash_slots,
.delta = c->myconf->cluster_config->jobmgr->delta,
.datakiller = (destroy_fn_t)job_obj_killer }; .datakiller = (destroy_fn_t)job_obj_killer };
kvmgr_params_t workermgr_params kvmgr_params_t workermgr_params
= { .key_type = KVMGR_KEY_STRING, = { .key_type = KVMGR_KEY_STRING,
.dynamic = 1, .dynamic = 1,
.nslots = c->myconf->cluster_config->workermgr->nhash_slots,
.delta = c->myconf->cluster_config->workermgr->delta,
.datakiller = (destroy_fn_t)worker_obj_killer }; .datakiller = (destroy_fn_t)worker_obj_killer };
kvmgr_params_t qmgr_params kvmgr_params_t qmgr_params
= { .key_type = KVMGR_KEY_STRING, = { .key_type = KVMGR_KEY_STRING,
.dynamic = 0, .dynamic = 0,
.nslots = c->myconf->cluster_config->qmgr->nhash_slots,
.delta = c->myconf->cluster_config->qmgr->delta,
.datakiller = (destroy_fn_t)queue_obj_killer }; .datakiller = (destroy_fn_t)queue_obj_killer };
if (c == NULL) { if (c == NULL) {
@ -565,6 +557,15 @@ int cluster_init(cluster_t* c)
return -errno; 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); c->configmgr = makeInstance(&xkvmgr_type, &config_mgr_params);
objmgr_init(&(c->objmgr)); 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) { if (now - ep->ts_last_in > timeout) {
TRACE("%s worker %s becomes UNAVAIL as heartbeat timeout", __func__, TRACE("%s worker %s becomes UNAVAIL as heartbeat timeout", __func__,
w->host->name); w->host.name);
mark_worker_unavail(c, w); mark_worker_unavail(c, w);
return 0; return 0;
} else { } else {
if (IS_WORKER_UNAVAIL(w->host->status)) { if (IS_WORKER_UNAVAIL(w->host.status)) {
mark_worker_back(c, w); 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))) { if (DATAQ_EMPTY(&(ep->outq))) {
int rc = 0; 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); rc = make_heartbeat(c, ep);
if (rc < 0) { if (rc < 0) {
ERROR("%s make_heartbeat to %s failed", __func__, ERROR("%s make_heartbeat to %s failed", __func__, w->host.name);
w->host->name);
return rc; return rc;
} }

View file

@ -23,13 +23,7 @@ static job_t* create_job(cluster_t* c, xce_job_t* j)
{ {
job_t* job = NULL; job_t* job = NULL;
job = calloc(1, sizeof(*job)); job = makeJob(c->jobmgr, j);
if (job == NULL) {
return NULL;
}
/* FIXME: */
job->job = makeJob(j);
return job; return job;
} }
@ -198,9 +192,9 @@ static int dispatch_a_job_(cluster_t* c, endpoint_t* ep, xce_job_alloc_t* alloc)
return -errno; 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", 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); free_launchinfo(&launchinfo);
obj_deref(w); 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_pre_exec;
char* q_post_exec; char* q_post_exec;
rc = get_queue_exec(c, j->job->submit->queue, &q_pre_exec, rc = get_queue_exec(c, j->job.submit->queue, &q_pre_exec, &q_post_exec);
&q_post_exec);
if (rc < 0) { if (rc < 0) {
obj_deref(j); obj_deref(j);
obj_deref(w); obj_deref(w);
return rc; return rc;
} }
if (j->job->submit->start_info->q_pre_exec != NULL) { if (j->job.submit->start_info->q_pre_exec != NULL) {
obj_deref(j->job->submit->start_info->q_pre_exec); obj_deref(j->job.submit->start_info->q_pre_exec);
} }
if (j->job->submit->start_info->q_post_exec != NULL) { if (j->job.submit->start_info->q_post_exec != NULL) {
obj_deref(j->job->submit->start_info->q_post_exec); 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_pre_exec = q_pre_exec;
j->job->submit->start_info->q_post_exec = q_post_exec; j->job.submit->start_info->q_post_exec = q_post_exec;
} }
einfo.jobid = alloc->jobid; einfo.jobid = alloc->jobid;
einfo.start_info = j->job->submit->start_info; einfo.start_info = j->job.submit->start_info;
einfo.launchinfo = &launchinfo; einfo.launchinfo = &launchinfo;
rc = xce_startjob_req(w->ep, &einfo); rc = xce_startjob_req(w->ep, &einfo);
free_launchinfo(&launchinfo); free_launchinfo(&launchinfo);
if (j->job->allocs != NULL) { if (j->job.allocs != NULL) {
free_JobAlloc_ptr(&(j->job->allocs)); free_JobAlloc_ptr(&(j->job.allocs));
} }
j->job->allocs = (xce_job_alloc_t*)calloc(1, sizeof(xce_job_alloc_t)); j->job.allocs = (xce_job_alloc_t*)calloc(1, sizeof(xce_job_alloc_t));
j->job->allocs->jobid = alloc->jobid; j->job.allocs->jobid = alloc->jobid;
j->job->allocs->nhosts = nc; j->job.allocs->nhosts = nc;
MOVE_PTR(j->job->allocs->allocs, allocs); MOVE_PTR(j->job.allocs->allocs, allocs);
alloc->allocs = NULL; alloc->allocs = NULL;
DEREF_OBJ(w); DEREF_OBJ(w);
@ -282,8 +275,8 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
return -ENOENT; return -ENOENT;
} }
if (j->job->allocs != NULL) { if (j->job.allocs != NULL) {
xce_host_alloc_t** allocs = j->job->allocs->allocs; xce_host_alloc_t** allocs = j->job.allocs->allocs;
worker_t* w = NULL; worker_t* w = NULL;
/* job control command will be sent to first node /* 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) { if (w != NULL) {
/* FIXME: better method to check host status */ /* 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); rc = xce_jobctrl_req(w->ep, ctrinfo);
if (rc < 0) { if (rc < 0) {
ERROR("job ctrl %ld on host %s returns %d", jobid, ERROR("job ctrl %ld on host %s returns %d", jobid,
w->host->name, rc); w->host.name, rc);
} }
} else { } else {
ERROR("worker %s is not in correct state, status %x ep %p", 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; rc = -errno;
} }
obj_deref(w); obj_deref(w);
@ -322,9 +315,9 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
case JobControl_u_siginfo: case JobControl_u_siginfo:
switch (ctrinfo->u.siginfo->signo) { switch (ctrinfo->u.siginfo->signo) {
case SIGCONT: case SIGCONT:
if (j->job->state if (j->job.state
& (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP)) { & (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP)) {
int state = j->job->state; int state = j->job.state;
/* resume suspend job? */ /* resume suspend job? */
state &= ~(JOB_STAT_PSUSP | JOB_STAT_USUSP); state &= ~(JOB_STAT_PSUSP | JOB_STAT_USUSP);
@ -333,9 +326,9 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
break; break;
case SIGSTOP: case SIGSTOP:
case SIGTSTP: case SIGTSTP:
if (!(j->job->state if (!(j->job.state
& (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP))) { & (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP))) {
int state = j->job->state; int state = j->job.state;
state |= JOB_STAT_PSUSP; state |= JOB_STAT_PSUSP;
mark_job_update(c, j, state); mark_job_update(c, j, state);
@ -344,7 +337,7 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
case SIGKILL: case SIGKILL:
case SIGTERM: case SIGTERM:
default: default:
if (j->job->state if (j->job.state
& (JOB_STAT_DONE | JOB_STAT_EXIT | JOB_STAT_ERR)) { & (JOB_STAT_DONE | JOB_STAT_EXIT | JOB_STAT_ERR)) {
break; break;
} }
@ -357,8 +350,7 @@ int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
} }
break; break;
case JobControl_u_ckptoption: case JobControl_u_ckptoption:
if (j->job->state if (j->job.state & (JOB_STAT_DONE | JOB_STAT_EXIT | JOB_STAT_ERR)) {
& (JOB_STAT_DONE | JOB_STAT_EXIT | JOB_STAT_ERR)) {
ERROR("job <%ld> has been finished, no checkpoint can be done.", ERROR("job <%ld> has been finished, no checkpoint can be done.",
jobid); jobid);
} else { } 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
HOOK_DETAIL_JOB_START, c, info, job); HOOK_DETAIL_JOB_START, c, info, job);
/* update job information */ /* update job information */
job->job->state = JOB_STAT_RUN; job->job.state = JOB_STAT_RUN;
job->job->start_time = time(NULL); job->job.start_time = time(NULL);
if (job->job->pidinfo == NULL) { if (job->job.pidinfo == NULL) {
job->job->pidinfo = (job_pidinfo_t*)calloc(1, sizeof(job_pidinfo_t)); job->job.pidinfo = (job_pidinfo_t*)calloc(1, sizeof(job_pidinfo_t));
} }
job->job->pidinfo->npids = copy_int_list((int**)&(job->job->pidinfo->pids), job->job.pidinfo->npids = copy_int_list((int**)&(job->job.pidinfo->pids),
(int*)info->pids, info->npids); (int*)info->pids, info->npids);
job->job->pidinfo->npgids = copy_int_list( job->job.pidinfo->npgids = copy_int_list((int**)&(job->job.pidinfo->pgids),
(int**)&(job->job->pidinfo->pgids), (int*)info->pgids, info->npgids); (int*)info->pgids, info->npgids);
if (info->exdata != NULL) { if (info->exdata != NULL) {
job->job->pidinfo->exdata = makeString(info->exdata); job->job.pidinfo->exdata = makeString(info->exdata);
} else { } else {
job->job->pidinfo->exdata = NULL; job->job.pidinfo->exdata = NULL;
} }
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT, 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); HOOK_DETAIL_JOB_EXIT, c, finish, job);
/* update job information */ /* update job information */
if (finish->exit_code == 0) { if (finish->exit_code == 0) {
job->job->state = JOB_STAT_DONE; job->job.state = JOB_STAT_DONE;
} else { } 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 */ /* fill job run time/rusage information */
if (job->job->exit_info == NULL) { if (job->job.exit_info == NULL) {
job->job->exit_info job->job.exit_info = (job_exitinfo_t*)calloc(1, sizeof(job_exitinfo_t));
= (job_exitinfo_t*)calloc(1, sizeof(job_exitinfo_t));
} }
if (job->job->exit_info != NULL) { if (job->job.exit_info != NULL) {
job->job->exit_info->exitcode = finish->exit_code; 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
HOOK_DETAIL_JOB_EXIT, c, finish, job); 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) { switch (failinfo->stage) {
case JOB_EXEC_STAGE_Q_POST_EXEC: case JOB_EXEC_STAGE_Q_POST_EXEC:
case JOB_EXEC_STAGE_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 " WARN("job %ld got post exec fail notification but job's exit "
"status has not been set", "status has not been set",
job->job->jobid); job->job.jobid);
job->job->state |= JOB_STAT_EXIT; job->job.state |= JOB_STAT_EXIT;
} }
job->job->state |= JOB_STAT_PERR; job->job.state |= JOB_STAT_PERR;
break; break;
default: default:
job->job->state = JOB_STAT_EXIT; job->job.state = JOB_STAT_EXIT;
break; 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
HOOK_DETAIL_JOB_FAIL, c, failinfo, job); 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
HOOK_DETAIL_JOB_UPDATE, c, job); HOOK_DETAIL_JOB_UPDATE, c, job);
/* update job state */ /* update job state */
job->job->state = state; job->job.state = state;
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
HOOK_DETAIL_JOB_UPDATE, c, job); HOOK_DETAIL_JOB_UPDATE, c, job);
@ -674,7 +665,7 @@ int on_job_stop(cluster_t* c, uint64_t jobid)
return -errno; return -errno;
} }
state = job->job->state; state = job->job.state;
state |= JOB_STAT_USUSP; state |= JOB_STAT_USUSP;
mark_job_update(c, job, state); mark_job_update(c, job, state);
@ -695,7 +686,7 @@ int on_job_resume(cluster_t* c, uint64_t jobid)
return -errno; return -errno;
} }
state = job->job->state; state = job->job.state;
state &= ~JOB_STAT_USUSP; state &= ~JOB_STAT_USUSP;
mark_job_update(c, job, state); 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; return -errno;
} }
state = job->job->state; state = job->job.state;
if ((state & (JOB_STAT_EXIT | JOB_STAT_DONE)) == 0) { if ((state & (JOB_STAT_EXIT | JOB_STAT_DONE)) == 0) {
WARN("job %ld got post exec fail notification but job's exit status " WARN("job %ld got post exec fail notification but job's exit status "
"has not been set", "has not been set",
job->job->jobid); job->job.jobid);
state |= JOB_STAT_EXIT; state |= JOB_STAT_EXIT;
/* ensure that job finish time has been set */ /* ensure that job finish time has been set */
job->job->finish_time = time(NULL); job->job.finish_time = time(NULL);
} }
state |= JOB_STAT_PDONE; 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
HOOK_DETAIL_JOB_CKPT, c, j); HOOK_DETAIL_JOB_CKPT, c, j);
if (j->job->ckptinfo != NULL) { if (j->job.ckptinfo != NULL) {
obj_deref(j->job->ckptinfo); 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
HOOK_DETAIL_JOB_CKPT, c, j); 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; return errno;
} }
host = makeString(w->host->name); host = makeString(w->host.name);
obj_deref(w); obj_deref(w);
if (host == NULL) { 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
HOOK_DETAIL_JOB_UPDATE, c, j); 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); 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 /* FIXME
* update other fields of job rusage later * 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
HOOK_DETAIL_SETPREASON, c, j); HOOK_DETAIL_SETPREASON, c, j);
job = j->job; job = &(j->job);
if (job->pend_reasons != NULL) { if (job->pend_reasons != NULL) {
erase_job_preason(job->pend_reasons); erase_job_preason(job->pend_reasons);
FREEUP(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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
HOOK_DETAIL_CLRPREASON, c, j); HOOK_DETAIL_CLRPREASON, c, j);
job = j->job; job = &(j->job);
if (job->pend_reasons != NULL) { if (job->pend_reasons != NULL) {
erase_job_preason(job->pend_reasons); erase_job_preason(job->pend_reasons);
FREEUP(job->pend_reasons); FREEUP(job->pend_reasons);

View file

@ -157,7 +157,7 @@ static int do_reply_joblist(cluster_t* c, endpoint_t* ep,
if (rc > 0) { if (rc > 0) {
jobdata.jobs = (xce_job_t**)calloc(1, sizeof(xce_job_t*)); jobdata.jobs = (xce_job_t**)calloc(1, sizeof(xce_job_t*));
if (jobdata.jobs != NULL) { if (jobdata.jobs != NULL) {
jobdata.jobs[0] = j->job; jobdata.jobs[0] = &(j->job);
jobdata.n_total = 1; jobdata.n_total = 1;
} }
} }

View file

@ -19,12 +19,7 @@ queue_t* create_queue(cluster_t* c, xce_queue_t* p)
{ {
queue_t* q; queue_t* q;
q = calloc(1, sizeof(*q)); q = makeQueue(c->qmgr, p);
if (q == NULL) {
return NULL;
}
q->queue = makeQueue(p);
return q; return q;
} }
@ -72,28 +67,28 @@ int queue_ctrl(cluster_t* c, xce_queuectrl_t* ctrl)
switch (ctrl->action) { switch (ctrl->action) {
case QUEUE_OPEN: case QUEUE_OPEN:
if (!(q->queue->status & QUEUE_STAT_CLOSED)) { if (!(q->queue.status & QUEUE_STAT_CLOSED)) {
goto clean; goto clean;
} }
q->queue->status &= ~QUEUE_STAT_CLOSED; q->queue.status &= ~QUEUE_STAT_CLOSED;
break; break;
case QUEUE_CLOSE: case QUEUE_CLOSE:
if (q->queue->status & QUEUE_STAT_CLOSED) { if (q->queue.status & QUEUE_STAT_CLOSED) {
goto clean; goto clean;
} }
q->queue->status |= QUEUE_STAT_CLOSED; q->queue.status |= QUEUE_STAT_CLOSED;
break; break;
case QUEUE_INACTIVE: case QUEUE_INACTIVE:
if (q->queue->status & QUEUE_STAT_INACT_ADMIN) { if (q->queue.status & QUEUE_STAT_INACT_ADMIN) {
goto clean; goto clean;
} }
q->queue->status |= QUEUE_STAT_INACT_ADMIN; q->queue.status |= QUEUE_STAT_INACT_ADMIN;
break; break;
case QUEUE_ACTIVE: case QUEUE_ACTIVE:
if (!(q->queue->status & QUEUE_STAT_INACT_ADMIN)) { if (!(q->queue.status & QUEUE_STAT_INACT_ADMIN)) {
goto clean; goto clean;
} }
q->queue->status &= ~QUEUE_STAT_INACT_ADMIN; q->queue.status &= ~QUEUE_STAT_INACT_ADMIN;
break; break;
default: default:
rc = -1; rc = -1;
@ -147,14 +142,14 @@ int get_queue_exec(cluster_t* c, char* queue, char** pre_exec, char** post_exec)
return -ENOENT; return -ENOENT;
} }
if (q->queue->pre_exec != NULL) { if (q->queue.pre_exec != NULL) {
*pre_exec = makeString(q->queue->pre_exec); *pre_exec = makeString(q->queue.pre_exec);
} else { } else {
*pre_exec = NULL; *pre_exec = NULL;
} }
if (q->queue->post_exec != NULL) { if (q->queue.post_exec != NULL) {
*post_exec = makeString(q->queue->post_exec); *post_exec = makeString(q->queue.post_exec);
} else { } else {
*post_exec = NULL; *post_exec = NULL;
} }

View file

@ -341,7 +341,7 @@ static int sched_job_update_fun(int type, int situation, void* data, va_list ap)
xce_notify_data_t xdata = { xce_notify_data_t xdata = {
.event = NotifyData_data_schedUpdateJob, .event = NotifyData_data_schedUpdateJob,
.data = { .data = {
.sched_update_job = job->job .sched_update_job = &(job->job)
} }
}; };
/* clang-format on */ /* clang-format on */
@ -419,11 +419,11 @@ static int sched_worker_change(int type, int situation, void* data,
int rc = 0; int rc = 0;
xlist_t wlist; 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); situation);
collect_resval_with_idx(&(w->host->resvals), &(w->host->nresvals_to_sched), collect_resval_with_idx(&(w->host.resvals), &(w->host.nresvals_to_sched),
&(w->host->resvals_to_sched)); &(w->host.resvals_to_sched));
mylock_lock(&(c->sched.lock)); mylock_lock(&(c->sched.lock));
if (c->sched.ep != NULL) { 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)); mylock_unlock(&(c->sched.lock));
free_resval_with_idx_list(&(w->host->resvals_to_sched), free_resval_with_idx_list(&(w->host.resvals_to_sched),
w->host->nresvals_to_sched); w->host.nresvals_to_sched);
return rc; return rc;
} }
@ -458,7 +458,7 @@ static int sched_worker_join(int type, int situation, void* data, va_list ap)
return 0; return 0;
} }
rc = key_find(c->workermgr, (void *)name, (void **)&w); rc = key_find(c->workermgr, (void*)name, (void**)&w);
if (rc < 0) { if (rc < 0) {
return rc; return rc;
} }
@ -558,7 +558,7 @@ static int sched_queue_update(int type,
xce_notify_data_t xdata = { xce_notify_data_t xdata = {
.event = NotifyData_data_schedUpdateQueue, .event = NotifyData_data_schedUpdateQueue,
.data = { .data = {
.sched_update_queue = q->queue .sched_update_queue = &(q->queue)
} }
}; };
/* clang-format on */ /* clang-format on */

View file

@ -26,7 +26,7 @@ static int run_tasks_on_host(cluster_t* c, endpoint_t* ep, uint64_t jobid,
return -ENOENT; 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); obj_deref(w);
return -EINVAL; return -EINVAL;
} }
@ -59,7 +59,7 @@ static int check_task_hosts(cluster_t* c, xce_taskrun_t* runmsg)
return -ENOENT; return -ENOENT;
} }
if ((w->ep == NULL) || IS_WORKER_UNAVAIL(w->host->status)) { if ((w->ep == NULL) || IS_WORKER_UNAVAIL(w->host.status)) {
return -ENOENT; return -ENOENT;
} }
} }

View file

@ -70,7 +70,7 @@ static int update_val_res(cluster_t* c, worker_t* w, xce_resource_t* r,
array = &(c->sharedinst); array = &(c->sharedinst);
} else { } else {
/* update host based resource */ /* update host based resource */
array = &(w->host->resvals); array = &(w->host.resvals);
} }
if (idx < array->caps) { if (idx < array->caps) {
@ -213,17 +213,16 @@ static int add_hostattrs_resvals(cluster_t* c, worker_t* w)
{ {
#define N_HOST_ATTRS (8) #define N_HOST_ATTRS (8)
xce_val_t values[N_HOST_ATTRS] = { xce_val_t values[N_HOST_ATTRS] = {
{ .which = Value_u_svalue, .u = { .svalue = w->host.attrs->hosttype } },
{ .which = Value_u_svalue, { .which = Value_u_svalue,
.u = { .svalue = w->host->attrs->hosttype } }, .u = { .svalue = w->host.attrs->hostmodel } },
{ .which = Value_u_svalue,
.u = { .svalue = w->host->attrs->hostmodel } },
{ .which = Value_u_fvalue, { .which = Value_u_fvalue,
.u = { .fvalue = w->host->attrs->cpufactor } }, .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->maxcpus } },
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->maxmem } }, { .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->maxswap } },
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->maxtmp } }, { .which = Value_u_fvalue, .u = { .fvalue = w->host.attrs->maxtmp } },
{ .which = Value_u_fvalue, .u = { .fvalue = w->host->attrs->ndisks } } { .which = Value_u_fvalue, .u = { .fvalue = w->host.attrs->ndisks } }
}; };
xce_resval_t resvals[N_HOST_ATTRS] = { xce_resval_t resvals[N_HOST_ATTRS] = {
{ .name = "type", .val = &values[0] }, { .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; cluster_t* c = (cluster_t*)cls;
/* clang-format off */ /* clang-format off */
worker_t worker = { worker_t worker = {
.host = &(xce_worker_t){ .host = (xce_worker_t){
.name = (char*)host, .name = (char*)host,
} }
}; };
@ -290,28 +289,28 @@ int add_worker(void* cls, endpoint_t* ep, const char* host, hostattrs_t* attrs)
return -errno; return -errno;
} }
worker.host->attrs = attrs; worker.host.attrs = attrs;
w->host = makeWorker(worker.host); w = makeWorker(c->workermgr, &(worker.host));
if (w->host == NULL) { if (w == NULL) {
return -errno; return -errno;
} }
/* we should hold the update lock */ /* we should hold the update lock */
/* If admin makes the host in locked or closed, we need keep this */ /* 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; w->ep = ep;
/* override host type? */ /* override host type? */
if (strcmp(hconfig->hosttype, "!") != 0) { if (strcmp(hconfig->hosttype, "!") != 0) {
dereference(w->host->attrs->hosttype); dereference(w->host.attrs->hosttype);
w->host->attrs->hosttype = makeString(hconfig->hosttype); w->host.attrs->hosttype = makeString(hconfig->hosttype);
} }
/* override host model */ /* override host model */
if (strcmp(hconfig->hostmodel, "!") != 0) { if (strcmp(hconfig->hostmodel, "!") != 0) {
dereference(w->host->attrs->hostmodel); dereference(w->host.attrs->hostmodel);
w->host->attrs->hostmodel = makeString(hconfig->hostmodel); w->host.attrs->hostmodel = makeString(hconfig->hostmodel);
} }
add_hostattrs_resvals(c, w); add_hostattrs_resvals(c, w);
idx = w->idx; 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? */ /* using auto detected or pre configured MXJ? */
nslots = hconfig->mxj; nslots = hconfig->mxj;
if (nslots < 0) { if (nslots < 0) {
nslots = w->host->attrs->maxcpus; nslots = w->host.attrs->maxcpus;
} }
set_host_slots(c, w, nslots); set_host_slots(c, w, nslots);
if (w->host->dispatch_window_config != NULL) { if (w->host.dispatch_window_config != NULL) {
free_timewindow_config(w->host->dispatch_window_config); free_timewindow_config(w->host.dispatch_window_config);
w->host->dispatch_window_config = NULL; w->host.dispatch_window_config = NULL;
} }
if (hconfig->dispatchwindow != NULL) { if (hconfig->dispatchwindow != NULL) {
w->host->dispatch_window_config w->host.dispatch_window_config
= dup_timewindow_config(hconfig->dispatchwindow); = dup_timewindow_config(hconfig->dispatchwindow);
} }
if (w->host->thresholds != NULL) { if (w->host.thresholds != NULL) {
free_resource_thresholds(w->host->thresholds, w->host->nthresholds); free_resource_thresholds(w->host.thresholds, w->host.nthresholds);
w->host->nthresholds = 0; w->host.nthresholds = 0;
w->host->thresholds = NULL; w->host.thresholds = NULL;
} }
if (hconfig->thresholds != NULL) { if (hconfig->thresholds != NULL) {
w->host->thresholds = dup_resource_thresholds(hconfig->thresholds, w->host.thresholds = dup_resource_thresholds(hconfig->thresholds,
hconfig->nthresholds); hconfig->nthresholds);
w->host->nthresholds = hconfig->nthresholds; w->host.nthresholds = hconfig->nthresholds;
} }
/* add bool resources to host */ /* add bool resources to host */
@ -361,27 +360,18 @@ int restore_worker(void* cls, xce_worker_t host)
cluster_t* c = (cluster_t*)cls; cluster_t* c = (cluster_t*)cls;
int idx = 0; int idx = 0;
worker_t* w = NULL; 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)); w = calloc(1, sizeof(*w));
if (w == NULL) { if (w == NULL) {
return -ENOMEM; return -ENOMEM;
} }
w->host = makeWorker(worker.host); w = makeWorker(c->workermgr, &host);
if (w->host == NULL) { if (w == NULL) {
return -errno; return -errno;
} }
add_hostattrs_resvals(c, w); add_hostattrs_resvals(c, w);
idx = w->idx; idx = w->idx;
w->host->status |= XCE_WORKER_UNAVAIL; w->host.status |= XCE_WORKER_UNAVAIL;
DEREF_OBJ(w); DEREF_OBJ(w);
@ -476,7 +466,7 @@ int get_resval(cluster_t* c, char* resname, char* host, xce_val_t* val)
return -ENOENT; return -ENOENT;
} }
array = &(w->host->resvals); array = &(w->host.resvals);
} else { } else {
array = &(c->sharedinst); 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_BEFORE_EVENT,
HOOK_DETAIL_WORKER_DEAD, c, w); 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
HOOK_DETAIL_WORKER_DEAD, c, w); 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_BEFORE_EVENT,
HOOK_DETAIL_WORKER_UPDATE, c, w); 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, xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
HOOK_DETAIL_WORKER_UPDATE, c, w); HOOK_DETAIL_WORKER_UPDATE, c, w);
@ -574,16 +564,16 @@ int worker_ctrl(cluster_t* c, xce_hostctrl_t* ctrl)
switch (ctrl->action) { switch (ctrl->action) {
case HOST_OPEN: case HOST_OPEN:
if (!(w->host->status & XCE_WORKER_CLOSED)) { if (!(w->host.status & XCE_WORKER_CLOSED)) {
goto clean; goto clean;
} }
w->host->status &= ~XCE_WORKER_CLOSED; w->host.status &= ~XCE_WORKER_CLOSED;
break; break;
case HOST_CLOSE: case HOST_CLOSE:
if (w->host->status & XCE_WORKER_CLOSED) { if (w->host.status & XCE_WORKER_CLOSED) {
goto clean; goto clean;
} }
w->host->status |= XCE_WORKER_CLOSED; w->host.status |= XCE_WORKER_CLOSED;
break; break;
default: default:
rc = -1; rc = -1;

View file

@ -2,11 +2,13 @@
#define _JOBJ_H_ 1 #define _JOBJ_H_ 1
#include <rtti.h>
#include "xce/types.h" #include "xce/types.h"
extern job_submit_data_t* makeJobsub(job_submit_data_t*); extern job_submit_data_t* makeJobsub(job_submit_data_t*);
extern job_startinfo_t* makeJobstartinfo(job_startinfo_t*); extern job_startinfo_t* makeJobstartinfo(job_startinfo_t*);
extern xce_job_t* makeJob(xce_job_t*); extern job_t* makeJob(var, xce_job_t*);
extern int job_obj_init(int, int); extern int job_obj_init(int, int);
extern void job_obj_fini(); extern void job_obj_fini();

View file

@ -2,8 +2,10 @@
#define _QOBJ_H_ 1 #define _QOBJ_H_ 1
#include <rtti.h>
#include "xce/types.h" #include "xce/types.h"
extern xce_queue_t *makeQueue(xce_queue_t*); extern queue_t* makeQueue(var, xce_queue_t*);
#endif #endif

View file

@ -2,8 +2,10 @@
#define _WOBJ_H_ 1 #define _WOBJ_H_ 1
#include <rtti.h>
#include "xce/types.h" #include "xce/types.h"
extern xce_worker_t* makeWorker(xce_worker_t*); extern worker_t* makeWorker(var, xce_worker_t*);
#endif #endif

View file

@ -274,11 +274,11 @@ typedef struct {
} xce_res_account_t; } xce_res_account_t;
typedef struct { typedef struct {
xce_worker_t* host; xce_worker_t host;
char hostkey[XCE_MAXKEY_LEN]; char hostkey[XCE_MAXKEY_LEN];
endpoint_t* ep; endpoint_t* ep;
int idx; int idx;
zarray_t usages; zarray_t usages;
} worker_t; } worker_t;
typedef struct { typedef struct {
@ -470,7 +470,7 @@ typedef struct {
} xce_job_t; } xce_job_t;
typedef struct { typedef struct {
xce_job_t* job; xce_job_t job;
} job_t; } job_t;
typedef struct { typedef struct {
@ -517,7 +517,7 @@ typedef struct {
} xce_queue_t; } xce_queue_t;
typedef struct { typedef struct {
xce_queue_t* queue; xce_queue_t queue;
} queue_t; } queue_t;
typedef struct { typedef struct {

View file

@ -537,14 +537,14 @@ typedef struct {
static size_t job_datasize(va_list ap) static size_t job_datasize(va_list ap)
{ {
size_t sz = sizeof(xce_job_t); size_t sz = sizeof(job_t);
return sz; return sz;
} }
static int job_init(meta_obj_t* obj, va_list ap) static int job_init(meta_obj_t* obj, va_list ap)
{ {
xce_job_t* dst = RTTI_OBJ_TO_DATA(xce_job_t, obj); job_t* dst = RTTI_OBJ_TO_DATA(job_t, obj);
job_private_t* priv = (job_private_t*)RTTI_OBJ_TO_PRIV(obj); job_private_t* priv = (job_private_t*)RTTI_OBJ_TO_PRIV(obj);
xce_job_t* src = va_arg(ap, xce_job_t*); xce_job_t* src = va_arg(ap, xce_job_t*);
@ -552,22 +552,22 @@ static int job_init(meta_obj_t* obj, va_list ap)
return -EINVAL; return -EINVAL;
} }
dst->jobid = src->jobid; dst->job.jobid = src->jobid;
dst->submit = makeJobsub(src->submit); dst->job.submit = makeJobsub(src->submit);
dst->sub_time = src->sub_time; dst->job.sub_time = src->sub_time;
dst->queue_time = src->queue_time; dst->job.queue_time = src->queue_time;
dst->start_time = src->start_time; dst->job.start_time = src->start_time;
dst->finish_time = src->finish_time; dst->job.finish_time = src->finish_time;
MOVE_PTR(dst->pidinfo, src->pidinfo); MOVE_PTR(dst->job.pidinfo, src->pidinfo);
dst->state = src->state; dst->job.state = src->state;
MOVE_PTR(dst->allocs, src->allocs); MOVE_PTR(dst->job.allocs, src->allocs);
MOVE_PTR(dst->accounts, src->accounts); MOVE_PTR(dst->job.accounts, src->accounts);
dst->run_time = src->run_time; dst->job.run_time = src->run_time;
MOVE_PTR(dst->run_usage, src->run_usage); MOVE_PTR(dst->job.run_usage, src->run_usage);
MOVE_PTR(dst->exit_info, src->exit_info); MOVE_PTR(dst->job.exit_info, src->exit_info);
dst->ckptinfo = makeString(src->ckptinfo); dst->job.ckptinfo = makeString(src->ckptinfo);
dst->pending_ctrl = src->pending_ctrl; dst->job.pending_ctrl = src->pending_ctrl;
MOVE_PTR(dst->pend_reasons, src->pend_reasons); MOVE_PTR(dst->job.pend_reasons, src->pend_reasons);
my_rwlock_init(&(priv->lock)); my_rwlock_init(&(priv->lock));
priv->refcount = 1; priv->refcount = 1;
@ -577,24 +577,24 @@ static int job_init(meta_obj_t* obj, va_list ap)
static void job_destroy(meta_obj_t* obj) static void job_destroy(meta_obj_t* obj)
{ {
xce_job_t* j = RTTI_OBJ_TO_DATA(xce_job_t, obj); job_t* j = RTTI_OBJ_TO_DATA(job_t, obj);
job_private_t* priv = (job_private_t*)RTTI_OBJ_TO_PRIV(obj); job_private_t* priv = (job_private_t*)RTTI_OBJ_TO_PRIV(obj);
dereference(j->submit); dereference(j->job.submit);
dereference(j->ckptinfo); dereference(j->job.ckptinfo);
/* FIXME: */ /* FIXME: */
if (j->pidinfo != NULL) { } if (j->job.pidinfo != NULL) { }
if (j->allocs != NULL) { } if (j->job.allocs != NULL) { }
if (j->accounts != NULL) { } if (j->job.accounts != NULL) { }
if (j->run_usage != NULL) { } if (j->job.run_usage != NULL) { }
if (j->exit_info != NULL) { } if (j->job.exit_info != NULL) { }
if (j->pend_reasons != NULL) { } if (j->job.pend_reasons != NULL) { }
my_rwlock_fini(&(priv->lock)); my_rwlock_fini(&(priv->lock));
memset(priv, 0x0, sizeof(*priv)); memset(priv, 0x0, sizeof(*priv));
@ -616,7 +616,7 @@ static int job_reference(meta_obj_t* obj)
static void job_dereference(meta_obj_t* obj) static void job_dereference(meta_obj_t* obj)
{ {
job_private_t* priv = (job_private_t*)RTTI_OBJ_TO_PRIV(obj); job_private_t* priv = (job_private_t*)RTTI_OBJ_TO_PRIV(obj);
xce_job_t* j = RTTI_OBJ_TO_DATA(xce_job_t, obj); job_t* j = RTTI_OBJ_TO_DATA(job_t, obj);
uint64_t count; uint64_t count;
my_rwlock_wlock(&(priv->lock)); my_rwlock_wlock(&(priv->lock));
@ -674,9 +674,10 @@ static typeinfo_t job_type = {
.unlock = (unlock_fn_t)job_unlock } } .unlock = (unlock_fn_t)job_unlock } }
}; };
xce_job_t* makeJob(xce_job_t* j) job_t* makeJob(var jobmgr, xce_job_t* j)
{ {
xce_job_t* job = makeInstance(&job_type, j); job_t* job = makeInstance(&job_type, j);
/* FIXME */
return job; return job;
} }

View file

@ -16,14 +16,14 @@ typedef struct {
static size_t queue_datasize(va_list ap) static size_t queue_datasize(va_list ap)
{ {
size_t sz = sizeof(xce_queue_t); size_t sz = sizeof(queue_t);
return sz; return sz;
} }
static int queue_init(meta_obj_t* obj, va_list ap) static int queue_init(meta_obj_t* obj, va_list ap)
{ {
xce_queue_t* dst = RTTI_OBJ_TO_DATA(xce_queue_t, obj); queue_t* dst = RTTI_OBJ_TO_DATA(queue_t, obj);
queue_private_t* priv = (queue_private_t*)RTTI_OBJ_TO_PRIV(obj); queue_private_t* priv = (queue_private_t*)RTTI_OBJ_TO_PRIV(obj);
xce_queue_t* src = va_arg(ap, xce_queue_t*); xce_queue_t* src = va_arg(ap, xce_queue_t*);
@ -31,26 +31,26 @@ static int queue_init(meta_obj_t* obj, va_list ap)
return -EINVAL; return -EINVAL;
} }
dst->queue = makeString(src->queue); dst->queue.queue = makeString(src->queue);
dst->attrs = src->attrs; dst->queue.attrs = src->attrs;
dst->status = src->status; dst->queue.status = src->status;
dst->priority = src->priority; dst->queue.priority = src->priority;
dst->accept_interval = src->accept_interval; dst->queue.accept_interval = src->accept_interval;
dst->sched_delay = src->sched_delay; dst->queue.sched_delay = src->sched_delay;
dst->resreq = makeString(src->resreq); dst->queue.resreq = makeString(src->resreq);
MOVE_PTR(dst->users, src->users); MOVE_PTR(dst->queue.users, src->users);
MOVE_PTR(dst->hosts, src->hosts); MOVE_PTR(dst->queue.hosts, src->hosts);
dst->nthresholds = src->nthresholds; dst->queue.nthresholds = src->nthresholds;
MOVE_PTR(dst->thresholds, src->thresholds); MOVE_PTR(dst->queue.thresholds, src->thresholds);
MOVE_PTR(dst->runwindow, src->runwindow); MOVE_PTR(dst->queue.runwindow, src->runwindow);
MOVE_PTR(dst->dispatchwindow, src->dispatchwindow); MOVE_PTR(dst->queue.dispatchwindow, src->dispatchwindow);
MOVE_PTR(dst->runwindow_config, src->runwindow_config); MOVE_PTR(dst->queue.runwindow_config, src->runwindow_config);
MOVE_PTR(dst->dispatchwindow_config, src->dispatchwindow_config); MOVE_PTR(dst->queue.dispatchwindow_config, src->dispatchwindow_config);
dst->pending_ctrl = src->pending_ctrl; dst->queue.pending_ctrl = src->pending_ctrl;
dst->pre_exec = makeString(src->pre_exec); dst->queue.pre_exec = makeString(src->pre_exec);
dst->post_exec = makeString(src->post_exec); dst->queue.post_exec = makeString(src->post_exec);
dst->autopscaler = makeString(src->autopscaler); dst->queue.autopscaler = makeString(src->autopscaler);
my_rwlock_init(&(priv->lock)); my_rwlock_init(&(priv->lock));
priv->refcount = 1; priv->refcount = 1;
@ -60,30 +60,30 @@ static int queue_init(meta_obj_t* obj, va_list ap)
static void queue_destroy(meta_obj_t* obj) static void queue_destroy(meta_obj_t* obj)
{ {
xce_queue_t* q = RTTI_OBJ_TO_DATA(xce_queue_t, obj); queue_t* q = RTTI_OBJ_TO_DATA(queue_t, obj);
queue_private_t* priv = (queue_private_t*)RTTI_OBJ_TO_PRIV(obj); queue_private_t* priv = (queue_private_t*)RTTI_OBJ_TO_PRIV(obj);
dereference(q->queue); dereference(q->queue.queue);
dereference(q->resreq); dereference(q->queue.resreq);
/* FIXME: */ /* FIXME: */
if (q->users != NULL) { } if (q->queue.users != NULL) { }
if (q->hosts != NULL) { } if (q->queue.hosts != NULL) { }
if (q->thresholds != NULL) { } if (q->queue.thresholds != NULL) { }
if (q->runwindow != NULL) { } if (q->queue.runwindow != NULL) { }
if (q->dispatchwindow != NULL) { } if (q->queue.dispatchwindow != NULL) { }
if (q->runwindow_config != NULL) { } if (q->queue.runwindow_config != NULL) { }
if (q->dispatchwindow_config != NULL) { } if (q->queue.dispatchwindow_config != NULL) { }
dereference(q->pre_exec); dereference(q->queue.pre_exec);
dereference(q->post_exec); dereference(q->queue.post_exec);
dereference(q->autopscaler); dereference(q->queue.autopscaler);
my_rwlock_fini(&(priv->lock)); my_rwlock_fini(&(priv->lock));
memset(priv, 0x0, sizeof(*priv)); memset(priv, 0x0, sizeof(*priv));
@ -163,8 +163,9 @@ static typeinfo_t queue_type = {
.unlock = (unlock_fn_t)queue_unlock } } .unlock = (unlock_fn_t)queue_unlock } }
}; };
xce_queue_t* makeQueue(xce_queue_t* w) queue_t* makeQueue(var qmgr, xce_queue_t* w)
{ {
xce_queue_t* queue = makeInstance(&queue_type, w); /* FIMXE: */
queue_t* queue = makeInstance(&queue_type, w);
return queue; return queue;
} }

View file

@ -6,6 +6,7 @@
#include <unity/unity.h> #include <unity/unity.h>
#include "jobj.h" #include "jobj.h"
#include "kvmgr.h"
#include "utils.h" #include "utils.h"
#include "xstring.h" #include "xstring.h"
@ -206,6 +207,12 @@ static void test_jobsub_share(void)
static void test_job_create(void) static void test_job_create(void)
{ {
int rc; int rc;
kvmgr_params_t jobmgr_params = { .key_type = KVMGR_KEY_INT,
.dynamic = 1,
.nslots = 32,
.delta = 32,
.datakiller = destroy };
var jobmgr;
job_startinfo_t s1 = { .exechome = "/homes/rshen", job_startinfo_t s1 = { .exechome = "/homes/rshen",
.execcwd = "/tmp", .execcwd = "/tmp",
.execuser = "rshen", .execuser = "rshen",
@ -226,7 +233,7 @@ static void test_job_create(void)
.job_description = "no description", .job_description = "no description",
.resreq = "type == any" }; .resreq = "type == any" };
xce_job_t job1 = { .submit = &jobsub1 }; xce_job_t job1 = { .submit = &jobsub1 };
xce_job_t* j2 = NULL; job_t* j2 = NULL;
time_t now = time(NULL); time_t now = time(NULL);
rc = xstring_table_init(32); rc = xstring_table_init(32);
@ -249,31 +256,36 @@ static void test_job_create(void)
job1.pending_ctrl = 0; job1.pending_ctrl = 0;
job1.jobid = 100; job1.jobid = 100;
j2 = makeJob(&job1); jobmgr = makeInstance(&xkvmgr_type, &jobmgr_params);
TEST_ASSERT_TRUE(jobmgr != NULL);
j2 = makeJob(jobmgr, &job1);
TEST_ASSERT_TRUE(j2 != NULL); TEST_ASSERT_TRUE(j2 != NULL);
TEST_ASSERT_TRUE( TEST_ASSERT_TRUE(
EQUAL_STRING(s1.exechome, j2->submit->start_info->exechome) EQUAL_STRING(s1.exechome, j2->job.submit->start_info->exechome)
&& EQUAL_STRING(s1.execcwd, j2->submit->start_info->execcwd) && EQUAL_STRING(s1.execcwd, j2->job.submit->start_info->execcwd)
&& EQUAL_STRING(s1.execuser, j2->submit->start_info->execuser) && EQUAL_STRING(s1.execuser, j2->job.submit->start_info->execuser)
&& EQUAL_STRING(s1.cmdline, j2->submit->start_info->cmdline) && EQUAL_STRING(s1.cmdline, j2->job.submit->start_info->cmdline)
&& EQUAL_STRING(s1.exdata, j2->submit->start_info->exdata) && EQUAL_STRING(s1.exdata, j2->job.submit->start_info->exdata)
&& EQUAL_STRING(s1.q_pre_exec, j2->submit->start_info->q_pre_exec) && EQUAL_STRING(s1.q_pre_exec, j2->job.submit->start_info->q_pre_exec)
&& EQUAL_STRING(s1.q_post_exec, j2->submit->start_info->q_post_exec) && EQUAL_STRING(s1.q_post_exec, j2->job.submit->start_info->q_post_exec)
&& EQUAL_STRING(s1.job_pre_exec, j2->submit->start_info->job_pre_exec) && EQUAL_STRING(s1.job_pre_exec, j2->job.submit->start_info->job_pre_exec)
&& EQUAL_STRING(s1.job_post_exec, j2->submit->start_info->job_post_exec) && EQUAL_STRING(s1.job_post_exec, j2->job.submit->start_info->job_post_exec)
&& EQUAL_STRING(j2->submit->queue, "xce") && EQUAL_STRING(j2->job.submit->queue, "xce")
&& EQUAL_STRING(j2->submit->user, "rshen") && EQUAL_STRING(j2->job.submit->user, "rshen")
&& EQUAL_STRING(j2->submit->job_name, "J1") && EQUAL_STRING(j2->job.submit->job_name, "J1")
&& EQUAL_STRING(j2->submit->project_name, "default") && EQUAL_STRING(j2->job.submit->project_name, "default")
&& EQUAL_STRING(j2->submit->job_description, "no description") && EQUAL_STRING(j2->job.submit->job_description, "no description")
&& EQUAL_STRING(j2->submit->resreq, "type == any") && EQUAL_STRING(j2->job.submit->resreq, "type == any")
&& (j2->submit->mintasks == 1) && (j2->submit->maxtasks == 5) && (j2->job.submit->mintasks == 1) && (j2->job.submit->maxtasks == 5)
&& (j2->submit->user_group == NULL)); && (j2->job.submit->user_group == NULL));
dereference(j2); dereference(j2);
destroy(jobmgr);
job_obj_fini(); job_obj_fini();
xstring_table_fini(); xstring_table_fini();
} }

View file

@ -2,28 +2,40 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <rtti.h>
#include <unity/unity.h> #include <unity/unity.h>
#include "qobj.h" #include "qobj.h"
#include "utils.h" #include "utils.h"
#include "xstring.h" #include "xstring.h"
#include "kvmgr.h"
static void test_queue_create(void) static void test_queue_create(void)
{ {
int rc; int rc;
xce_queue_t q1 = { 0 }; kvmgr_params_t params = { .key_type = KVMGR_KEY_STRING,
xce_queue_t* q = NULL; .nslots = 32,
.delta = 32,
.datakiller = destroy };
var qmgr;
xce_queue_t q1 = { 0 };
queue_t* q = NULL;
rc = xstring_table_init(32); rc = xstring_table_init(32);
TEST_ASSERT_TRUE(rc >= 0); TEST_ASSERT_TRUE(rc >= 0);
q = makeQueue(&q1); qmgr = makeInstance(&xkvmgr_type, &params);
TEST_ASSERT_TRUE(qmgr != NULL);
q = makeQueue(qmgr, &q1);
TEST_ASSERT_TRUE(q != NULL); TEST_ASSERT_TRUE(q != NULL);
destroy(q); destroy(q);
destroy(qmgr);
xstring_table_fini(); xstring_table_fini();
} }

View file

@ -5,41 +5,52 @@
#include <unity/unity.h> #include <unity/unity.h>
#include "kvmgr.h"
#include "utils.h" #include "utils.h"
#include "wobj.h" #include "wobj.h"
#include "xstring.h" #include "xstring.h"
static void test_worker_create(void) static void test_worker_create(void)
{ {
int rc; int rc;
hostattrs_t attrs1 = { .hosttype = "LINUX64", kvmgr_params_t params = { .key_type = KVMGR_KEY_STRING,
.hostmodel = "linux-gnu-x86_64", .nslots = 32,
.cpufactor = 100.0, .delta = 32,
.maxcpus = 5, .datakiller = destroy };
.maxmem = 65536.0, var workermgr;
.maxswap = 65536.0, hostattrs_t attrs1 = { .hosttype = "LINUX64",
.maxtmp = 0.0, .hostmodel = "linux-gnu-x86_64",
.ndisks = 2 }; .cpufactor = 100.0,
xce_worker_t w1 = { .maxcpus = 5,
.name = "worker1", .maxmem = 65536.0,
.attrs = &attrs1, .maxswap = 65536.0,
.maxtmp = 0.0,
.ndisks = 2 };
xce_worker_t w1 = {
.name = "worker1",
.attrs = &attrs1,
}; };
xce_worker_t* w = NULL; worker_t* w = NULL;
rc = xstring_table_init(32); rc = xstring_table_init(32);
TEST_ASSERT_TRUE(rc >= 0); TEST_ASSERT_TRUE(rc >= 0);
w = makeWorker(&w1); workermgr = makeInstance(&xkvmgr_type, &params);
TEST_ASSERT_TRUE(workermgr != NULL);
w = makeWorker(workermgr, &w1);
TEST_ASSERT_TRUE(w != NULL); TEST_ASSERT_TRUE(w != NULL);
TEST_ASSERT_TRUE(EQUAL_STRING(w->name, w1.name) TEST_ASSERT_TRUE(EQUAL_STRING(w->host.name, w1.name)
&& EQUAL_STRING(w->attrs->hosttype, attrs1.hosttype) && EQUAL_STRING(w->host.attrs->hosttype, attrs1.hosttype)
&& EQUAL_STRING(w->attrs->hostmodel, attrs1.hostmodel) && EQUAL_STRING(w->host.attrs->hostmodel, attrs1.hostmodel)
&& (w->attrs->cpufactor == attrs1.cpufactor) && (w->host.attrs->cpufactor == attrs1.cpufactor)
&& (w->attrs->maxcpus == attrs1.maxcpus)); && (w->host.attrs->maxcpus == attrs1.maxcpus));
dereference(w); dereference(w);
destroy(workermgr);
xstring_table_fini(); xstring_table_fini();
} }

View file

@ -16,14 +16,14 @@ typedef struct {
static size_t worker_datasize(va_list ap) static size_t worker_datasize(va_list ap)
{ {
size_t sz = sizeof(xce_worker_t); size_t sz = sizeof(worker_t);
return sz; return sz;
} }
static int worker_init(meta_obj_t* obj, va_list ap) static int worker_init(meta_obj_t* obj, va_list ap)
{ {
xce_worker_t* dst = RTTI_OBJ_TO_DATA(xce_worker_t, obj); worker_t* dst = RTTI_OBJ_TO_DATA(worker_t, obj);
worker_private_t* priv = (worker_private_t*)RTTI_OBJ_TO_PRIV(obj); worker_private_t* priv = (worker_private_t*)RTTI_OBJ_TO_PRIV(obj);
xce_worker_t* src = va_arg(ap, xce_worker_t*); xce_worker_t* src = va_arg(ap, xce_worker_t*);
@ -31,28 +31,28 @@ static int worker_init(meta_obj_t* obj, va_list ap)
return -EINVAL; return -EINVAL;
} }
dst->name = makeString(src->name); dst->host.name = makeString(src->name);
dst->attrs = (hostattrs_t*)calloc(1, sizeof(hostattrs_t)); dst->host.attrs = (hostattrs_t*)calloc(1, sizeof(hostattrs_t));
if (dst->attrs == NULL) { if (dst->host.attrs == NULL) {
return -ENOMEM; return -ENOMEM;
} }
memcpy(dst->attrs, src->attrs, sizeof(*(dst->attrs))); memcpy(dst->host.attrs, src->attrs, sizeof(*(dst->host.attrs)));
dst->attrs->hosttype = makeString(src->attrs->hosttype); dst->host.attrs->hosttype = makeString(src->attrs->hosttype);
dst->attrs->hostmodel = makeString(src->attrs->hostmodel); dst->host.attrs->hostmodel = makeString(src->attrs->hostmodel);
dst->status = src->status; dst->host.status = src->status;
/* FIXME: */ /* FIXME: */
zarray_init(&(dst->resvals), 64, NULL); zarray_init(&(dst->host.resvals), 64, NULL);
dst->dead_since = src->dead_since; dst->host.dead_since = src->dead_since;
dst->pending_ctrl = src->pending_ctrl; dst->host.pending_ctrl = src->pending_ctrl;
MOVE_PTR(dst->dispatch_window_config, src->dispatch_window_config); MOVE_PTR(dst->host.dispatch_window_config, src->dispatch_window_config);
dst->nthresholds = src->nthresholds; dst->host.nthresholds = src->nthresholds;
MOVE_PTR(dst->thresholds, src->thresholds); MOVE_PTR(dst->host.thresholds, src->thresholds);
dst->nresvals_to_sched = 0; dst->host.nresvals_to_sched = 0;
dst->resvals_to_sched = NULL; dst->host.resvals_to_sched = NULL;
my_rwlock_init(&(priv->lock)); my_rwlock_init(&(priv->lock));
priv->refcount = 1; priv->refcount = 1;
@ -62,24 +62,24 @@ static int worker_init(meta_obj_t* obj, va_list ap)
static void worker_destroy(meta_obj_t* obj) static void worker_destroy(meta_obj_t* obj)
{ {
xce_worker_t* w = RTTI_OBJ_TO_DATA(xce_worker_t, obj); worker_t* w = RTTI_OBJ_TO_DATA(worker_t, obj);
worker_private_t* priv = (worker_private_t*)RTTI_OBJ_TO_PRIV(obj); worker_private_t* priv = (worker_private_t*)RTTI_OBJ_TO_PRIV(obj);
dereference(w->name); dereference(w->host.name);
if (w->attrs != NULL) { if (w->host.attrs != NULL) {
dereference(w->attrs->hosttype); dereference(w->host.attrs->hosttype);
dereference(w->attrs->hostmodel); dereference(w->host.attrs->hostmodel);
FREEUP(w->attrs); FREEUP(w->host.attrs);
} }
if (w->dispatch_window_config != NULL) { } if (w->host.dispatch_window_config != NULL) { }
if (w->thresholds != NULL) { } if (w->host.thresholds != NULL) { }
if (w->resvals_to_sched != NULL) { } if (w->host.resvals_to_sched != NULL) { }
zarray_fini(&(w->resvals)); zarray_fini(&(w->host.resvals));
my_rwlock_fini(&(priv->lock)); my_rwlock_fini(&(priv->lock));
memset(priv, 0x0, sizeof(*priv)); memset(priv, 0x0, sizeof(*priv));
@ -101,7 +101,7 @@ static int worker_reference(meta_obj_t* obj)
static void worker_dereference(meta_obj_t* obj) static void worker_dereference(meta_obj_t* obj)
{ {
worker_private_t* priv = (worker_private_t*)RTTI_OBJ_TO_PRIV(obj); worker_private_t* priv = (worker_private_t*)RTTI_OBJ_TO_PRIV(obj);
xce_worker_t* w = RTTI_OBJ_TO_DATA(xce_worker_t, obj); worker_t* w = RTTI_OBJ_TO_DATA(worker_t, obj);
uint64_t count = 0; uint64_t count = 0;
my_rwlock_wlock(&(priv->lock)); my_rwlock_wlock(&(priv->lock));
@ -159,8 +159,9 @@ static typeinfo_t worker_type = {
.unlock = (unlock_fn_t)worker_unlock } } .unlock = (unlock_fn_t)worker_unlock } }
}; };
xce_worker_t* makeWorker(xce_worker_t* w) worker_t* makeWorker(var workermgr, xce_worker_t* w)
{ {
xce_worker_t* worker = makeInstance(&worker_type, w); worker_t* worker = makeInstance(&worker_type, w);
/* fIXME */
return worker; return worker;
} }

View file

@ -60,3 +60,12 @@ subdir('worker')
subdir('autoscaler') subdir('autoscaler')
subdir('scheduler') subdir('scheduler')
subdir('apiserver') subdir('apiserver')
configure_file(
input: 'tools/appimage/entry.sh',
output: 'xcerun',
copy: true,
install: true,
install_dir: 'bin',
install_mode: 'rwxr-xr-x'
)

View file

@ -60,6 +60,8 @@ stdenv.mkDerivation {
separateDebugInfo = true; separateDebugInfo = true;
})) }))
packcc packcc
cowsay
fortune
]; ];
build-system = [ pkgs.meson ]; build-system = [ pkgs.meson ];
@ -75,4 +77,8 @@ stdenv.mkDerivation {
("-Dcommit_id=" + myCommitId) ("-Dcommit_id=" + myCommitId)
# (lib.optional (!with_debug) "-Dbuildtype=release") # (lib.optional (!with_debug) "-Dbuildtype=release")
]; ];
meta = {
mainProgram = "xcerun";
};
} }

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
case "$1" in
hello)
shift
cowsay "Hello, $*"
;;
fortune)
fortune
;;
*)
echo "Usage: $0 {hello <message>|fortune}"
exit 1
;;
esac