forked from lei.chen/myxce
save work status
This commit is contained in:
parent
ff6d4eeccd
commit
12a6010f29
7 changed files with 58 additions and 53 deletions
|
|
@ -28,8 +28,11 @@ typedef struct {
|
|||
} request_res_t;
|
||||
|
||||
typedef struct {
|
||||
char* user;
|
||||
char* queue;
|
||||
char* project;
|
||||
xce_resreq_t* resreq;
|
||||
} xce_sched_resreq_t;
|
||||
} xce_sched_obj_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
|
|
@ -59,7 +62,7 @@ typedef struct {
|
|||
xce_sched_queue_t* queue;
|
||||
xce_sched_user_t* user;
|
||||
xce_sched_project_t* project;
|
||||
xce_sched_resreq_t* resreq;
|
||||
xce_sched_obj_t* schedobj;
|
||||
uint32_t mintasks;
|
||||
uint32_t maxtasks;
|
||||
xce_job_alloc_t* allocs;
|
||||
|
|
@ -77,7 +80,8 @@ typedef struct {
|
|||
typedef struct {
|
||||
xce_sched_job_t* job;
|
||||
xce_sched_worker_t* worker;
|
||||
xce_sched_resreq_t* resreq;
|
||||
xce_sched_obj_t* schedobj;
|
||||
xce_resreq_t* resreq;
|
||||
xce_job_alloc_t* alloc;
|
||||
xce_pendreason_t* reason;
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ static int update_limit_res_value(zarray_t* array, xce_vres_t* vres)
|
|||
|
||||
static float get_vres_value(xce_sched_ctx_t* ctx, xce_vres_t* vres)
|
||||
{
|
||||
int i;
|
||||
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||
int i;
|
||||
xce_sched_obj_t* schedobj = ctx->schedobj;
|
||||
|
||||
#if 0
|
||||
if (resreq->op != RESREQ_OP_SIMPLE) {
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ static int skip_bad_worker_(xce_sched_worker_t* w)
|
|||
|
||||
static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
|
||||
{
|
||||
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||
xce_sched_job_t* job = ctx->job;
|
||||
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||
xce_sched_job_t* job = ctx->job;
|
||||
xce_sched_obj_t* schedobj = ctx->schedobj;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@ static int skip_bad_worker_(xce_sched_worker_t* w)
|
|||
|
||||
static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
|
||||
{
|
||||
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||
xce_sched_job_t* job = ctx->job;
|
||||
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||
int rc;
|
||||
xlist_t workers;
|
||||
xce_pendreason_t* reason = NULL;
|
||||
xvec_t* uncomit = NULL;
|
||||
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||
xce_sched_job_t* job = ctx->job;
|
||||
xce_sched_obj_t* schedobj = ctx->schedobj;
|
||||
int rc;
|
||||
xlist_t workers;
|
||||
xce_pendreason_t* reason = NULL;
|
||||
xvec_t* uncomit = NULL;
|
||||
|
||||
reason = make_pendreason(job->jobid);
|
||||
ctx->reason = reason;
|
||||
|
|
|
|||
|
|
@ -343,15 +343,15 @@ static int sched_update_res_accounts(xce_scheduler_t* sched, zarray_t* array,
|
|||
|
||||
static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap)
|
||||
{
|
||||
xce_scheduler_t* sched = va_arg(ap, xce_scheduler_t*);
|
||||
xce_sched_ctx_t* ctx = va_arg(ap, xce_sched_ctx_t*);
|
||||
xce_sched_job_t* job = ctx->job;
|
||||
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||
int rc;
|
||||
xce_host_alloc_t** hallocs = NULL;
|
||||
xce_host_alloc_t* halloc = NULL;
|
||||
xce_alloc_t** allocs = NULL;
|
||||
xvec_t* uncomit = NULL;
|
||||
xce_scheduler_t* sched = va_arg(ap, xce_scheduler_t*);
|
||||
xce_sched_ctx_t* ctx = va_arg(ap, xce_sched_ctx_t*);
|
||||
xce_sched_job_t* job = ctx->job;
|
||||
xce_sched_obj_t* schedobj = ctx->schedobj;
|
||||
int rc;
|
||||
xce_host_alloc_t** hallocs = NULL;
|
||||
xce_host_alloc_t* halloc = NULL;
|
||||
xce_alloc_t** allocs = NULL;
|
||||
xvec_t* uncomit = NULL;
|
||||
|
||||
/* FIXME: */
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -36,19 +36,19 @@ request_res_t* make_resource_request(char* res, float value)
|
|||
return req;
|
||||
}
|
||||
|
||||
static int make_sched_resreq(xce_sched_resreq_t* resreq, xce_scheduler_t* sched,
|
||||
xce_job_t* j)
|
||||
static int make_sched_obj(xce_sched_obj_t* obj, xce_scheduler_t* sched,
|
||||
xce_job_t* j)
|
||||
{
|
||||
int rc;
|
||||
char* errmsg;
|
||||
|
||||
memset(resreq, 0x0, sizeof(*resreq));
|
||||
resreq->resreq = (xce_resreq_t*)calloc(1, sizeof(*(resreq->resreq)));
|
||||
if (resreq->resreq == NULL) {
|
||||
memset(obj, 0x0, sizeof(*obj));
|
||||
obj->resreq = (xce_resreq_t*)calloc(1, sizeof(*(obj->resreq)));
|
||||
if (obj->resreq == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = parse_resreq(resreq->resreq, j->submit->resreq, &errmsg);
|
||||
rc = parse_resreq(obj->resreq, j->submit->resreq, &errmsg);
|
||||
if (rc < 0) {
|
||||
ERROR("%s parse_resreq with error code %d", __func__, rc);
|
||||
if (errmsg != NULL) {
|
||||
|
|
@ -84,15 +84,15 @@ xce_sched_job_t* make_sched_job(void* arg, xce_job_t* j)
|
|||
job->maxtasks = j->submit->maxtasks;
|
||||
job->priority = 0; /* FIXME: support job level priority */
|
||||
|
||||
job->resreq = (xce_sched_resreq_t*)calloc(1, sizeof(*(job->resreq)));
|
||||
if (job->resreq == NULL) {
|
||||
job->schedobj = (xce_sched_obj_t*)calloc(1, sizeof(*(job->schedobj)));
|
||||
if (job->schedobj == NULL) {
|
||||
/* FIXME: */
|
||||
free(job);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
make_sched_resreq(job->resreq, sched, j);
|
||||
make_sched_obj(job->schedobj, sched, j);
|
||||
job->allocs = NULL;
|
||||
job->accounts = NULL;
|
||||
if (j->allocs != NULL) {
|
||||
|
|
|
|||
|
|
@ -73,25 +73,26 @@ static int sched_make_parjob_allocation(xce_scheduler_t* sched,
|
|||
static int sched_make_primary_allocation(xce_scheduler_t* sched,
|
||||
xce_sched_ctx_t* ctx)
|
||||
{
|
||||
xce_primary_resreq_t *primary = ctx->resreq->resreq->u.primary;
|
||||
xce_primary_resreq_t* primary = ctx->schedobj->resreq->u.primary;
|
||||
|
||||
if (primary->maxTasks == 1) {
|
||||
return sched_make_seqjob_allocation(sched, ctx);
|
||||
}
|
||||
|
||||
|
||||
return sched_make_parjob_allocation(sched, ctx);
|
||||
}
|
||||
|
||||
static int sched_make_compound_allocation(xce_scheduler_t* sched,
|
||||
xce_sched_ctx_t* ctx)
|
||||
{
|
||||
xce_compound_resreq_t *resreq = ctx->resreq->resreq->u.compound;
|
||||
int i;
|
||||
xce_compound_resreq_t* resreq = ctx->schedobj->resreq->u.compound;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < resreq->primaries.count; i ++) {
|
||||
xce_primary_resreq_t *resreq1 = (xce_primary_resreq_t *)xlist_get(&(resreq->primaries), i);
|
||||
int rc;
|
||||
xce_sched_ctx_t ctx1 = {0};
|
||||
for (i = 0; i < resreq->primaries.count; i++) {
|
||||
xce_primary_resreq_t* resreq1
|
||||
= (xce_primary_resreq_t*)xlist_get(&(resreq->primaries), i);
|
||||
int rc;
|
||||
xce_sched_ctx_t ctx1 = { 0 };
|
||||
|
||||
/* FIXME: initialize ctx1 */
|
||||
|
||||
|
|
@ -99,7 +100,6 @@ static int sched_make_compound_allocation(xce_scheduler_t* sched,
|
|||
if (rc <= 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -107,20 +107,21 @@ static int sched_make_compound_allocation(xce_scheduler_t* sched,
|
|||
static int sched_make_alter_allocation(xce_scheduler_t* sched,
|
||||
xce_sched_ctx_t* ctx)
|
||||
{
|
||||
xce_alter_resreq_t *resreq = ctx->resreq->resreq->u.alter;
|
||||
int i;
|
||||
xce_alter_resreq_t* resreq = ctx->schedobj->resreq->u.alter;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < resreq->compounds.count; i++) {
|
||||
xce_compound_resreq_t* resreq1
|
||||
= (xce_compound_resreq_t*)xlist_get(&(resreq->compounds), i);
|
||||
int rc;
|
||||
xce_sched_ctx_t ctx1 = { 0 };
|
||||
|
||||
for(i = 0; i < resreq->compounds.count; i ++) {
|
||||
xce_compound_resreq_t *resreq1 = (xce_compound_resreq_t *)xlist_get(&(resreq->compounds), i);
|
||||
int rc;
|
||||
xce_sched_ctx_t ctx1 = {0};
|
||||
|
||||
if (resreq1 == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* FIXME: we need to initialize ctx1 */
|
||||
|
||||
|
||||
rc = sched_make_compound_allocation(sched, &ctx1);
|
||||
if (rc > 0) {
|
||||
return rc;
|
||||
|
|
@ -134,9 +135,9 @@ static int sched_make_allocation(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
|||
{
|
||||
int rc = 0;
|
||||
xce_sched_job_t* job = ctx->job;
|
||||
xce_resreq_t* resreq = job->resreq->resreq;
|
||||
xce_resreq_t* resreq = job->schedobj->resreq;
|
||||
|
||||
if (job->resreq == NULL) {
|
||||
if (job->schedobj == NULL) {
|
||||
xce_pendreason_t* reason = NULL;
|
||||
|
||||
ERROR("%s job %lu has invalid resource requirement", __func__,
|
||||
|
|
@ -150,7 +151,7 @@ static int sched_make_allocation(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ctx->resreq = job->resreq;
|
||||
ctx->schedobj = job->schedobj;
|
||||
switch (resreq->tag) {
|
||||
case XCE_RESREQ_PRIMARY:
|
||||
rc = sched_make_primary_allocation(sched, ctx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue