reformat code and job array
This commit is contained in:
parent
a665ccd4fe
commit
9ff857db9f
64 changed files with 1497 additions and 2476 deletions
|
|
@ -23,13 +23,10 @@ static time_t last_print_time = 0;
|
|||
static unsigned long npkts_old = 0;
|
||||
static unsigned long npkts = 0;
|
||||
|
||||
static xce_peerinfo_t from_controller = {
|
||||
.name = "controller",
|
||||
.key = "keepSecret"
|
||||
};
|
||||
static xce_peerinfo_t from_controller
|
||||
= { .name = "controller", .key = "keepSecret" };
|
||||
|
||||
static ep_private_t*
|
||||
ep_get_private()
|
||||
static ep_private_t* ep_get_private()
|
||||
{
|
||||
ep_private_t* priv;
|
||||
|
||||
|
|
@ -37,10 +34,7 @@ ep_get_private()
|
|||
return priv;
|
||||
}
|
||||
|
||||
static int handle_client_leave(cluster_t* c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int handle_client_leave(cluster_t* c) { return 0; }
|
||||
|
||||
static void handle_endpoint_error(endpoint_t* ep)
|
||||
{
|
||||
|
|
@ -58,8 +52,7 @@ static void handle_endpoint_error(endpoint_t* ep)
|
|||
|
||||
priv = (ep_private_t*)ep->data;
|
||||
|
||||
TRACE("endpoint %p priv data %p",
|
||||
ep, priv);
|
||||
TRACE("endpoint %p priv data %p", ep, priv);
|
||||
|
||||
if (priv != NULL) {
|
||||
role = priv->role;
|
||||
|
|
@ -68,8 +61,7 @@ static void handle_endpoint_error(endpoint_t* ep)
|
|||
if (priv->u.idx >= 0) {
|
||||
handle_worker_leave(c, priv->u.idx);
|
||||
} else {
|
||||
ERROR("incorrect worker idx %d",
|
||||
priv->u.idx);
|
||||
ERROR("incorrect worker idx %d", priv->u.idx);
|
||||
}
|
||||
break;
|
||||
case HostRole_scheduler:
|
||||
|
|
@ -81,8 +73,7 @@ static void handle_endpoint_error(endpoint_t* ep)
|
|||
handle_client_leave(c);
|
||||
break;
|
||||
default:
|
||||
ERROR("unknown role %d for endpoint %p",
|
||||
priv->role, ep);
|
||||
ERROR("unknown role %d for endpoint %p", priv->role, ep);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -97,9 +88,7 @@ static void handle_endpoint_error(endpoint_t* ep)
|
|||
return;
|
||||
}
|
||||
|
||||
static int do_notify(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* req)
|
||||
static int do_notify(cluster_t* c, endpoint_t* ep, xce_request_t* req)
|
||||
{
|
||||
xce_notify_data_t* data = req->body.notifymsg;
|
||||
|
||||
|
|
@ -149,9 +138,7 @@ static int myreq_handler(vtask_t* task)
|
|||
|
||||
rc = ioctx_decode(&(task->ctx), &request);
|
||||
|
||||
TRACE("%s cpu#%d opcode %d",
|
||||
__func__, task->vcpu,
|
||||
request.opcode);
|
||||
TRACE("%s cpu#%d opcode %d", __func__, task->vcpu, request.opcode);
|
||||
|
||||
init_reply_by_req(&reply, &request);
|
||||
|
||||
|
|
@ -201,8 +188,7 @@ static int myreq_handler(vtask_t* task)
|
|||
break;
|
||||
default:
|
||||
rc = -E_XCE_BAD_OPCODE;
|
||||
ERROR("Unknown opcode: %d",
|
||||
request.opcode);
|
||||
ERROR("Unknown opcode: %d", request.opcode);
|
||||
reply.status = rc;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
xce_reply(task->ctx.ep, c->myhost, &reply);
|
||||
|
|
@ -396,14 +382,14 @@ int cluster_build_config(cluster_t* c)
|
|||
char valbuf[128];
|
||||
int i;
|
||||
|
||||
snprintf(valbuf, sizeof(valbuf) - 1,
|
||||
"%d", c->myconf->cluster_config->heartbeat_interval);
|
||||
snprintf(valbuf, sizeof(valbuf) - 1, "%d",
|
||||
c->myconf->cluster_config->heartbeat_interval);
|
||||
add_config(c, "heartbeat_interval", valbuf);
|
||||
snprintf(valbuf, sizeof(valbuf) - 1,
|
||||
"%d", c->myconf->cluster_config->inactive_heartbeat_count);
|
||||
snprintf(valbuf, sizeof(valbuf) - 1, "%d",
|
||||
c->myconf->cluster_config->inactive_heartbeat_count);
|
||||
add_config(c, "inactive_heartbeat_count", valbuf);
|
||||
snprintf(valbuf, sizeof(valbuf) - 1,
|
||||
"%d", c->myconf->cluster_config->ncandidates);
|
||||
snprintf(valbuf, sizeof(valbuf) - 1, "%d",
|
||||
c->myconf->cluster_config->ncandidates);
|
||||
add_config(c, "ncandidates", valbuf);
|
||||
|
||||
for (i = 0; i < c->myconf->cluster_config->ncandidates; i++) {
|
||||
|
|
@ -461,15 +447,9 @@ int cluster_build_queues(cluster_t* c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cluster_build_groups(cluster_t* c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int cluster_build_groups(cluster_t* c) { return 0; }
|
||||
|
||||
static int xce_config_init(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int xce_config_init(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
int rc = 0;
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
|
|
@ -512,10 +492,7 @@ static int xce_config_init(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int cluster_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
static int cluster_hook_fun(int type, int situation, int detail, void* data,
|
||||
va_list ap)
|
||||
{
|
||||
if (detail == HOOK_DETAIL_CLUSTER_INIT) {
|
||||
|
|
@ -527,10 +504,8 @@ static int cluster_hook_fun(int type,
|
|||
|
||||
static int xce_install_hooks(cluster_t* c)
|
||||
{
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
(hook_fn_t)cluster_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
(hook_fn_t)cluster_hook_fun, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -551,10 +526,8 @@ int cluster_init(cluster_t* c)
|
|||
|
||||
xce_install_hooks(c);
|
||||
|
||||
rc = xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_CLUSTER_INIT, c);
|
||||
rc = xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
HOOK_BEFORE_EVENT, HOOK_DETAIL_CLUSTER_INIT, c);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -562,24 +535,19 @@ int cluster_init(cluster_t* c)
|
|||
mylock_init(&(c->sched.lock));
|
||||
c->sched.ep = NULL;
|
||||
|
||||
kvmgr_init(&(c->configmgr),
|
||||
string_hash_key,
|
||||
128, 128,
|
||||
kvmgr_init(&(c->configmgr), string_hash_key, 128, 128,
|
||||
(zarray_item_killer_t)config_obj_killer);
|
||||
|
||||
objmgr_init(&(c->objmgr));
|
||||
jobmgr_init(&(c->jobmgr),
|
||||
c->myconf->cluster_config->jobmgr->nhash_slots,
|
||||
jobmgr_init(&(c->jobmgr), c->myconf->cluster_config->jobmgr->nhash_slots,
|
||||
c->myconf->cluster_config->jobmgr->delta);
|
||||
resmgr_init(&(c->resmgr),
|
||||
c->myconf->cluster_config->resmgr->nhash_slots,
|
||||
resmgr_init(&(c->resmgr), c->myconf->cluster_config->resmgr->nhash_slots,
|
||||
c->myconf->cluster_config->resmgr->delta,
|
||||
c->myconf->cluster_config->resmgr->inst_delta);
|
||||
workermgr_init(&(c->workermgr),
|
||||
c->myconf->cluster_config->workermgr->nhash_slots,
|
||||
c->myconf->cluster_config->workermgr->delta);
|
||||
qmgr_init(&(c->qmgr),
|
||||
c->myconf->cluster_config->qmgr->nhash_slots,
|
||||
qmgr_init(&(c->qmgr), c->myconf->cluster_config->qmgr->nhash_slots,
|
||||
c->myconf->cluster_config->qmgr->delta);
|
||||
iomgr_init(&(c->iomgr));
|
||||
register_xstring(&(c->objmgr),
|
||||
|
|
@ -589,11 +557,8 @@ int cluster_init(cluster_t* c)
|
|||
|
||||
zarray_init(&(c->endpoints), 16, endpoint_killer);
|
||||
|
||||
rc = endpoint_init(&(c->ep),
|
||||
AF_INET,
|
||||
SOCK_STREAM,
|
||||
c->myconf->cluster_config->port,
|
||||
5);
|
||||
rc = endpoint_init(&(c->ep), AF_INET, SOCK_STREAM,
|
||||
c->myconf->cluster_config->port, 5);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -608,9 +573,7 @@ int cluster_init(cluster_t* c)
|
|||
|
||||
vtaskmgr_init(&(c->vtaskmgr), c->myconf->cluster_config->vcpus);
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
HOOK_AFTER_EVENT,
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_CLUSTER_INIT, c);
|
||||
|
||||
return 0;
|
||||
|
|
@ -645,9 +608,7 @@ int cluster_run(cluster_t* c)
|
|||
}
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
HOOK_BEFORE_EVENT,
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_CLUSTER_SHUTDOWN, c);
|
||||
c->running = 0;
|
||||
iomgr_unmonitor(&(c->iomgr), &(c->ep));
|
||||
|
|
@ -661,9 +622,7 @@ void cluster_fini(cluster_t* c)
|
|||
vtaskmgr_fini(&(c->vtaskmgr));
|
||||
endpoint_deref(&(c->ep));
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
HOOK_AFTER_EVENT,
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_CLUSTER_SHUTDOWN, c);
|
||||
cbuf_fini(&(c->wbuf));
|
||||
iomgr_fini(&(c->iomgr));
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ int not_null_check(void* arg)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int collect_resval_with_idx_(zarray_t* array,
|
||||
int* nres,
|
||||
static int collect_resval_with_idx_(zarray_t* array, int* nres,
|
||||
xce_val_with_idx_t*** resvals)
|
||||
{
|
||||
int nc;
|
||||
|
|
@ -97,8 +96,7 @@ static int collect_resval_with_idx_(zarray_t* array,
|
|||
val->val->u.svalue = strdup("-");
|
||||
}
|
||||
} else {
|
||||
memcpy(val->val, array->data[i],
|
||||
sizeof(xce_val_t));
|
||||
memcpy(val->val, array->data[i], sizeof(xce_val_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,8 +105,7 @@ static int collect_resval_with_idx_(zarray_t* array,
|
|||
return j;
|
||||
}
|
||||
|
||||
int collect_resval_with_idx(zarray_t* array,
|
||||
int* nres,
|
||||
int collect_resval_with_idx(zarray_t* array, int* nres,
|
||||
xce_val_with_idx_t*** resvals)
|
||||
{
|
||||
int rc = 0;
|
||||
|
|
@ -121,8 +118,7 @@ int collect_resval_with_idx(zarray_t* array,
|
|||
|
||||
return rc;
|
||||
}
|
||||
static int count_(void* arg1,
|
||||
void* arg2)
|
||||
static int count_(void* arg1, void* arg2)
|
||||
{
|
||||
struct intern_array_* arg = (struct intern_array_*)arg1;
|
||||
|
||||
|
|
@ -139,8 +135,7 @@ static int count_(void* arg1,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int add_confvar_(void* arg1,
|
||||
void* arg2)
|
||||
static int add_confvar_(void* arg1, void* arg2)
|
||||
{
|
||||
struct intern_array_* arg = (struct intern_array_*)arg1;
|
||||
xce_config_t** p = NULL;
|
||||
|
|
@ -159,8 +154,7 @@ static int add_confvar_(void* arg1,
|
|||
|
||||
p = (xce_config_t**)arg->data;
|
||||
if (p == NULL) {
|
||||
p = (xce_config_t**)calloc(arg->count,
|
||||
sizeof(xce_config_t*));
|
||||
p = (xce_config_t**)calloc(arg->count, sizeof(xce_config_t*));
|
||||
if (p == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -174,18 +168,15 @@ static int add_confvar_(void* arg1,
|
|||
return 1;
|
||||
}
|
||||
|
||||
void collect_confvars(cluster_t* c,
|
||||
collect_check_fn_t fn,
|
||||
int* nconfig,
|
||||
xce_config_t*** configs)
|
||||
void collect_confvars(cluster_t* c, collect_check_fn_t fn, int* nconfig,
|
||||
xce_config_t*** configs)
|
||||
{
|
||||
xlist_t lst;
|
||||
struct intern_array_ args = {
|
||||
.count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (fn == NULL) ? not_null_check : fn
|
||||
};
|
||||
struct intern_array_ args
|
||||
= { .count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (fn == NULL) ? not_null_check : fn };
|
||||
int rc;
|
||||
|
||||
*nconfig = 0;
|
||||
|
|
@ -205,8 +196,7 @@ void collect_confvars(cluster_t* c,
|
|||
}
|
||||
}
|
||||
|
||||
static int add_queue_(void* arg1,
|
||||
void* arg2)
|
||||
static int add_queue_(void* arg1, void* arg2)
|
||||
{
|
||||
struct intern_array_* arg = (struct intern_array_*)arg1;
|
||||
xce_queue_t** p = NULL;
|
||||
|
|
@ -229,8 +219,7 @@ static int add_queue_(void* arg1,
|
|||
|
||||
p = (xce_queue_t**)arg->data;
|
||||
if (p == NULL) {
|
||||
p = (xce_queue_t**)calloc(arg->count,
|
||||
sizeof(xce_queue_t*));
|
||||
p = (xce_queue_t**)calloc(arg->count, sizeof(xce_queue_t*));
|
||||
if (p == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -244,18 +233,15 @@ static int add_queue_(void* arg1,
|
|||
return 1;
|
||||
}
|
||||
|
||||
void collect_queues(cluster_t* c,
|
||||
collect_check_fn_t fn,
|
||||
int* nqueues,
|
||||
xce_queue_t*** queues)
|
||||
void collect_queues(cluster_t* c, collect_check_fn_t fn, int* nqueues,
|
||||
xce_queue_t*** queues)
|
||||
{
|
||||
xlist_t lst;
|
||||
struct intern_array_ args = {
|
||||
.count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (fn == NULL) ? not_null_check : fn
|
||||
};
|
||||
struct intern_array_ args
|
||||
= { .count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (fn == NULL) ? not_null_check : fn };
|
||||
int rc;
|
||||
|
||||
*nqueues = 0;
|
||||
|
|
@ -275,8 +261,7 @@ void collect_queues(cluster_t* c,
|
|||
}
|
||||
}
|
||||
|
||||
static int add_resource_(void* arg1,
|
||||
void* arg2)
|
||||
static int add_resource_(void* arg1, void* arg2)
|
||||
{
|
||||
struct intern_array_* arg = (struct intern_array_*)arg1;
|
||||
xce_resource_t** p = NULL;
|
||||
|
|
@ -299,8 +284,7 @@ static int add_resource_(void* arg1,
|
|||
|
||||
p = (xce_resource_t**)arg->data;
|
||||
if (p == NULL) {
|
||||
p = (xce_resource_t**)calloc(arg->count,
|
||||
sizeof(xce_resource_t*));
|
||||
p = (xce_resource_t**)calloc(arg->count, sizeof(xce_resource_t*));
|
||||
if (p == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -315,18 +299,15 @@ static int add_resource_(void* arg1,
|
|||
return 1;
|
||||
}
|
||||
|
||||
void collect_resources(cluster_t* c,
|
||||
collect_check_fn_t fn,
|
||||
int* nresources,
|
||||
xce_resource_t*** resources)
|
||||
void collect_resources(cluster_t* c, collect_check_fn_t fn, int* nresources,
|
||||
xce_resource_t*** resources)
|
||||
{
|
||||
xlist_t lst;
|
||||
struct intern_array_ args = {
|
||||
.count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (fn == NULL) ? not_null_check : fn
|
||||
};
|
||||
struct intern_array_ args
|
||||
= { .count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (fn == NULL) ? not_null_check : fn };
|
||||
int rc;
|
||||
|
||||
*nresources = 0;
|
||||
|
|
@ -346,8 +327,7 @@ void collect_resources(cluster_t* c,
|
|||
}
|
||||
}
|
||||
|
||||
static int add_job_(void* arg1,
|
||||
void* arg2)
|
||||
static int add_job_(void* arg1, void* arg2)
|
||||
{
|
||||
struct intern_array_* arg = (struct intern_array_*)arg1;
|
||||
xce_job_t** p = NULL;
|
||||
|
|
@ -384,18 +364,12 @@ static int add_job_(void* arg1,
|
|||
return 1;
|
||||
}
|
||||
|
||||
void collect_jobs(cluster_t* c,
|
||||
collect_check_fn_t fn,
|
||||
int* njobs,
|
||||
xce_job_t*** jobs)
|
||||
void collect_jobs(cluster_t* c, collect_check_fn_t fn, int* njobs,
|
||||
xce_job_t*** jobs)
|
||||
{
|
||||
xlist_t lst;
|
||||
struct intern_array_ args = {
|
||||
.count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (check_fn_t)fn
|
||||
};
|
||||
struct intern_array_ args
|
||||
= { .count = 0, .idx = 0, .data = NULL, .checkfn = (check_fn_t)fn };
|
||||
int rc = 0;
|
||||
|
||||
*njobs = 0;
|
||||
|
|
@ -416,8 +390,7 @@ void collect_jobs(cluster_t* c,
|
|||
return;
|
||||
}
|
||||
|
||||
static int add_worker_(void* arg1,
|
||||
void* arg2)
|
||||
static int add_worker_(void* arg1, void* arg2)
|
||||
{
|
||||
struct intern_array_* arg = (struct intern_array_*)arg1;
|
||||
xce_worker_t** p = NULL;
|
||||
|
|
@ -451,8 +424,7 @@ static int add_worker_(void* arg1,
|
|||
|
||||
w = (xce_worker_t*)obj_ref(arg2, OBJREF_READ);
|
||||
|
||||
collect_resval_with_idx(&(w->resvals),
|
||||
&(w->nresvals_to_sched),
|
||||
collect_resval_with_idx(&(w->resvals), &(w->nresvals_to_sched),
|
||||
&(w->resvals_to_sched));
|
||||
|
||||
p[arg->idx] = w;
|
||||
|
|
@ -461,18 +433,12 @@ static int add_worker_(void* arg1,
|
|||
return 1;
|
||||
}
|
||||
|
||||
void collect_workers(cluster_t* c,
|
||||
collect_check_fn_t fn,
|
||||
int* nworkers,
|
||||
xce_worker_t*** workers)
|
||||
void collect_workers(cluster_t* c, collect_check_fn_t fn, int* nworkers,
|
||||
xce_worker_t*** workers)
|
||||
{
|
||||
xlist_t lst;
|
||||
struct intern_array_ args = {
|
||||
.count = 0,
|
||||
.idx = 0,
|
||||
.data = NULL,
|
||||
.checkfn = (check_fn_t)fn
|
||||
};
|
||||
struct intern_array_ args
|
||||
= { .count = 0, .idx = 0, .data = NULL, .checkfn = (check_fn_t)fn };
|
||||
int rc = 0;
|
||||
|
||||
*nworkers = 0;
|
||||
|
|
@ -494,20 +460,16 @@ void collect_workers(cluster_t* c,
|
|||
return;
|
||||
}
|
||||
|
||||
void collect_shared_resvals(cluster_t* c,
|
||||
collect_check_fn_t fn,
|
||||
int* nres,
|
||||
void collect_shared_resvals(cluster_t* c, collect_check_fn_t fn, int* nres,
|
||||
xce_val_with_idx_t*** resvals)
|
||||
{
|
||||
|
||||
collect_resval_with_idx(&(c->resmgr.sharedinst),
|
||||
nres, resvals);
|
||||
collect_resval_with_idx(&(c->resmgr.sharedinst), nres, resvals);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void deref_objs(int count,
|
||||
void** objs)
|
||||
void deref_objs(int count, void** objs)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -522,9 +484,7 @@ void deref_objs(int count,
|
|||
}
|
||||
}
|
||||
|
||||
int notify(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_notify_data_t* data)
|
||||
int notify(cluster_t* c, endpoint_t* ep, xce_notify_data_t* data)
|
||||
{
|
||||
ioctx_t* ctx = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,9 @@ extern int jobmgr_init(jobmgr_t*, int, int);
|
|||
extern void jobmgr_fini(jobmgr_t*);
|
||||
extern int workermgr_init(workermgr_t*, int, int);
|
||||
extern void workermgr_fini(workermgr_t*);
|
||||
extern int workermgr_add(workermgr_t*,
|
||||
worker_t*);
|
||||
extern worker_t* workermgr_lock(workermgr_t*,
|
||||
char*, int);
|
||||
extern worker_t* workermgr_lock_byid(workermgr_t*,
|
||||
int, int);
|
||||
extern int workermgr_add(workermgr_t*, worker_t*);
|
||||
extern worker_t* workermgr_lock(workermgr_t*, char*, int);
|
||||
extern worker_t* workermgr_lock_byid(workermgr_t*, int, int);
|
||||
extern void workermgr_del(workermgr_t*, worker_t*);
|
||||
extern int worker_ctrl(cluster_t*, xce_hostctrl_t*);
|
||||
extern void qmgr_fini(qmgr_t*);
|
||||
|
|
@ -47,32 +44,25 @@ extern queue_t* qmgr_lockq(qmgr_t*, char*, int);
|
|||
extern void qmgr_delq(qmgr_t*, queue_t*);
|
||||
extern int qmgr_iter(qmgr_t*, xlist_t*, void*);
|
||||
|
||||
extern xce_resource_t* get_resource(cluster_t*,
|
||||
char*);
|
||||
extern xce_resource_t* get_resource(cluster_t*, char*);
|
||||
extern int add_to_xlist(xlist_t*, void*);
|
||||
extern int add_worker_to_xlist(xlist_t*, void*);
|
||||
extern int add_queue_to_xlist(xlist_t*, void*);
|
||||
extern int add_job_to_xlist(xlist_t*, void*);
|
||||
|
||||
extern void resource_killer(void*);
|
||||
extern int add_resource(void*, char*, char*,
|
||||
int, xce_order_t,
|
||||
int, int);
|
||||
extern int resmgr_init(resmgr_t*, int, int, int);
|
||||
extern void resmgr_fini(resmgr_t*);
|
||||
extern int32_t resmgr_add_res(resmgr_t*,
|
||||
xce_resource_t*);
|
||||
extern xce_resource_t* resmgr_lockres(resmgr_t* mgr,
|
||||
char*, int);
|
||||
extern void resource_killer(void*);
|
||||
extern int add_resource(void*, char*, char*, int, xce_order_t, int, int);
|
||||
extern int resmgr_init(resmgr_t*, int, int, int);
|
||||
extern void resmgr_fini(resmgr_t*);
|
||||
extern int32_t resmgr_add_res(resmgr_t*, xce_resource_t*);
|
||||
extern xce_resource_t* resmgr_lockres(resmgr_t* mgr, char*, int);
|
||||
extern void res_obj_killer(xce_resource_t*);
|
||||
extern void resmgr_del_res(resmgr_t*,
|
||||
xce_resource_t*);
|
||||
extern void resmgr_del_res(resmgr_t*, xce_resource_t*);
|
||||
extern int resmgr_iter(resmgr_t*, xlist_t*, void*);
|
||||
|
||||
extern void config_obj_killer(xce_config_t*);
|
||||
|
||||
extern int update_resvals(cluster_t*, worker_t*,
|
||||
int, xce_resval_t*);
|
||||
extern int update_resvals(cluster_t*, worker_t*, int, xce_resval_t*);
|
||||
|
||||
extern int load_jobs(void*);
|
||||
extern int update_job(void*, uint64_t, xce_kv_list_t*);
|
||||
|
|
@ -84,49 +74,42 @@ extern void queue_fini(queue_t*);
|
|||
extern int queue_ctrl(cluster_t*, xce_queuectrl_t*);
|
||||
extern queue_t* qmgr_lockq(qmgr_t*, char*, int);
|
||||
|
||||
extern int xce_update_data(endpoint_t*, cluster_t*,
|
||||
int, int, int*, int, xce_kv_t*);
|
||||
extern int xce_update_data(endpoint_t*, cluster_t*, int, int, int*, int,
|
||||
xce_kv_t*);
|
||||
extern int on_scheduler_join(cluster_t*);
|
||||
|
||||
extern int xce_push_reslist(endpoint_t*, cluster_t*,
|
||||
int, xce_resource_t**);
|
||||
extern int xce_push_confvars(endpoint_t*, cluster_t*,
|
||||
int, xce_config_t**);
|
||||
extern int xce_push_workerlist(endpoint_t*, cluster_t*,
|
||||
int, xce_worker_t**);
|
||||
extern int xce_push_joblist(endpoint_t*, cluster_t*,
|
||||
int, xce_job_t**);
|
||||
extern int xce_push_queuelist(endpoint_t*, cluster_t*,
|
||||
int, xce_queue_t**);
|
||||
extern int xcesched_push_job(cluster_t*, uint64_t);
|
||||
extern int on_worker_join(void*, endpoint_t*);
|
||||
extern int get_resval(cluster_t*, char*,
|
||||
char*, xce_val_t*);
|
||||
extern job_t* jobmgr_lockjob(jobmgr_t*, uint64_t, int);
|
||||
extern int xce_push_reslist(endpoint_t*, cluster_t*, int, xce_resource_t**);
|
||||
extern int xce_push_confvars(endpoint_t*, cluster_t*, int, xce_config_t**);
|
||||
extern int xce_push_workerlist(endpoint_t*, cluster_t*, int, xce_worker_t**);
|
||||
extern int xce_push_joblist(endpoint_t*, cluster_t*, int, xce_job_t**);
|
||||
extern int xce_push_queuelist(endpoint_t*, cluster_t*, int, xce_queue_t**);
|
||||
extern int xcesched_push_job(cluster_t*, uint64_t);
|
||||
extern int on_worker_join(void*, endpoint_t*);
|
||||
extern int get_resval(cluster_t*, char*, char*, xce_val_t*);
|
||||
extern job_t* jobmgr_lockjob(jobmgr_t*, uint64_t, int);
|
||||
extern int32_t jobmgr_add_job(jobmgr_t*, job_t*);
|
||||
extern void jobmgr_del_job(jobmgr_t*, job_t*);
|
||||
extern void job_obj_killer(job_t*);
|
||||
extern int handle_push(struct capn*, cluster_t*,
|
||||
endpoint_t*, struct Request*);
|
||||
extern int do_get_op(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int do_update_op(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int handle_join(cluster_t*,
|
||||
endpoint_t*,
|
||||
xce_request_t*);
|
||||
extern int handle_reply(endpoint_t*, struct Request*,
|
||||
cluster_t*);
|
||||
extern int handle_jobdispatch(cluster_t*, endpoint_t*,
|
||||
xce_request_t*);
|
||||
extern int handle_jobsubmit(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int handle_worker_leave(cluster_t*, int);
|
||||
extern int handle_scheduler_leave(cluster_t*);
|
||||
extern int handle_clusterconf(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int handle_push(struct capn*, cluster_t*, endpoint_t*, struct Request*);
|
||||
extern int do_get_op(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int do_update_op(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int handle_join(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int handle_reply(endpoint_t*, struct Request*, cluster_t*);
|
||||
extern int handle_jobdispatch(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int handle_jobsubmit(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int handle_worker_leave(cluster_t*, int);
|
||||
extern int handle_scheduler_leave(cluster_t*);
|
||||
extern int handle_clusterconf(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
|
||||
extern void collect_confvars(cluster_t*, collect_check_fn_t, int*, xce_config_t***);
|
||||
extern void collect_queues(cluster_t*, collect_check_fn_t, int*, xce_queue_t***);
|
||||
extern void collect_resources(cluster_t*, collect_check_fn_t, int*, xce_resource_t***);
|
||||
extern void collect_confvars(cluster_t*, collect_check_fn_t, int*,
|
||||
xce_config_t***);
|
||||
extern void collect_queues(cluster_t*, collect_check_fn_t, int*,
|
||||
xce_queue_t***);
|
||||
extern void collect_resources(cluster_t*, collect_check_fn_t, int*,
|
||||
xce_resource_t***);
|
||||
extern void collect_jobs(cluster_t*, collect_check_fn_t, int*, xce_job_t***);
|
||||
extern void collect_workers(cluster_t*, collect_check_fn_t, int*, xce_worker_t***);
|
||||
extern void collect_workers(cluster_t*, collect_check_fn_t, int*,
|
||||
xce_worker_t***);
|
||||
extern void deref_objs(int, void**);
|
||||
extern int get_queue_exec(cluster_t*, char*, char**, char**);
|
||||
extern int jobmgr_iter(jobmgr_t*, xlist_t*, void*);
|
||||
|
|
@ -146,8 +129,8 @@ extern int update_resval_list(cluster_t*, worker_t*, xce_resval_list_t*);
|
|||
extern int do_jobcontrol_op(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int job_ctrl(cluster_t*, xce_jobctrl_t*);
|
||||
extern int update_job_rusages(cluster_t*, endpoint_t*, xce_request_t*);
|
||||
extern int update_host_runusage(xce_job_runusage_t**, char*,
|
||||
int, xce_rusage_t**);
|
||||
extern int update_host_runusage(xce_job_runusage_t**, char*, int,
|
||||
xce_rusage_t**);
|
||||
extern int update_pids(job_pidinfo_t**, int, int*);
|
||||
extern int update_pgids(job_pidinfo_t**, int, int*);
|
||||
extern int get_ep_role(endpoint_t*);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ typedef struct {
|
|||
zarray_t usages;
|
||||
} worker_t;
|
||||
|
||||
extern int add_worker(void*, endpoint_t*, const char*,
|
||||
hostattrs_t*);
|
||||
extern int add_worker(void*, endpoint_t*, const char*, hostattrs_t*);
|
||||
extern int restore_worker(void*, xce_worker_t);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,36 +16,22 @@ static int mark_job_update(cluster_t*, job_t*, int);
|
|||
|
||||
uint64_t jobid = 100;
|
||||
|
||||
static job_t* create_job(cluster_t* c,
|
||||
uint64_t jobid,
|
||||
char* queue,
|
||||
char* user,
|
||||
char* exechome,
|
||||
char* execcwd,
|
||||
char* execuser,
|
||||
char* cmdline,
|
||||
char* exdata,
|
||||
uint32_t mintasks,
|
||||
uint32_t maxtasks)
|
||||
static job_t* create_job(cluster_t* c, uint64_t jobid, char* queue, char* user,
|
||||
char* exechome, char* execcwd, char* execuser,
|
||||
char* cmdline, char* exdata, uint32_t mintasks,
|
||||
uint32_t maxtasks)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
return job;
|
||||
}
|
||||
|
||||
uint64_t job_submit(void* c,
|
||||
char* user,
|
||||
char* queue,
|
||||
char* resreq,
|
||||
char* cmdline,
|
||||
char* exdata,
|
||||
uint32_t mintasks,
|
||||
uint64_t job_submit(void* c, char* user, char* queue, char* resreq,
|
||||
char* cmdline, char* exdata, uint32_t mintasks,
|
||||
uint32_t maxtasks)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
|
||||
job = create_job(c, jobid++, queue,
|
||||
user, "/tmp",
|
||||
"/tmp", user, cmdline,
|
||||
job = create_job(c, jobid++, queue, user, "/tmp", "/tmp", user, cmdline,
|
||||
exdata, mintasks, maxtasks);
|
||||
if (job == NULL) {
|
||||
return -errno;
|
||||
|
|
@ -62,20 +48,16 @@ int load_jobs(void* c)
|
|||
|
||||
for (i = 1; i < NJOBS; i++) {
|
||||
sprintf(cmdline, "echo normal; sleep %d", i);
|
||||
job = create_job(c, jobid++, "normal",
|
||||
"rshen", "/home/rshen",
|
||||
"/tmp", "rshen", (char*)cmdline,
|
||||
NULL, 1, 1);
|
||||
job = create_job(c, jobid++, "normal", "rshen", "/home/rshen", "/tmp",
|
||||
"rshen", (char*)cmdline, NULL, 1, 1);
|
||||
if (job == NULL) {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i < NJOBS; i++) {
|
||||
job = create_job(c, jobid++, "xce",
|
||||
"rshen", "/home/rshen",
|
||||
"/tmp", "rshen", "echo xce; sleep 30",
|
||||
NULL, 1, 1);
|
||||
job = create_job(c, jobid++, "xce", "rshen", "/home/rshen", "/tmp",
|
||||
"rshen", "echo xce; sleep 30", NULL, 1, 1);
|
||||
if (job == NULL) {
|
||||
return -errno;
|
||||
}
|
||||
|
|
@ -108,8 +90,7 @@ static void free_launchinfo(xce_launch_t* launch)
|
|||
FREEUP(launch->hosts);
|
||||
}
|
||||
|
||||
static int mk_launchinfo(xce_launch_t* launch,
|
||||
xce_job_alloc_t* alloc)
|
||||
static int mk_launchinfo(xce_launch_t* launch, xce_job_alloc_t* alloc)
|
||||
{
|
||||
int i;
|
||||
int rc = 0;
|
||||
|
|
@ -124,7 +105,8 @@ static int mk_launchinfo(xce_launch_t* launch,
|
|||
|
||||
launch->nhosts = alloc->nhosts;
|
||||
for (i = 0; i < alloc->nhosts; i++) {
|
||||
launch->hosts[i] = (xce_host_launch_t*)calloc(1, sizeof(xce_host_launch_t));
|
||||
launch->hosts[i]
|
||||
= (xce_host_launch_t*)calloc(1, sizeof(xce_host_launch_t));
|
||||
if (launch->hosts[i] == NULL) {
|
||||
rc = -ENOMEM;
|
||||
break;
|
||||
|
|
@ -141,9 +123,7 @@ static int mk_launchinfo(xce_launch_t* launch,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int dispatch_a_job_(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_job_alloc_t* alloc)
|
||||
static int dispatch_a_job_(cluster_t* c, endpoint_t* ep, xce_job_alloc_t* alloc)
|
||||
{
|
||||
int rc = 0;
|
||||
job_t* j;
|
||||
|
|
@ -177,9 +157,7 @@ static int dispatch_a_job_(cluster_t* c,
|
|||
|
||||
allocs = (xce_host_alloc_t**)alloc->allocs;
|
||||
/* using head node of job */
|
||||
w = workermgr_lock(&(c->workermgr),
|
||||
allocs[0]->host,
|
||||
OBJREF_READ);
|
||||
w = workermgr_lock(&(c->workermgr), allocs[0]->host, OBJREF_READ);
|
||||
if (w == NULL) {
|
||||
PERROR("workermgr_lock");
|
||||
free_launchinfo(&launchinfo);
|
||||
|
|
@ -189,9 +167,7 @@ static int dispatch_a_job_(cluster_t* c,
|
|||
|
||||
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);
|
||||
|
|
@ -206,8 +182,7 @@ static int dispatch_a_job_(cluster_t* c,
|
|||
char* q_pre_exec;
|
||||
char* q_post_exec;
|
||||
|
||||
rc = get_queue_exec(c, j->job.queue,
|
||||
&q_pre_exec, &q_post_exec);
|
||||
rc = get_queue_exec(c, j->job.queue, &q_pre_exec, &q_post_exec);
|
||||
if (rc < 0) {
|
||||
obj_deref(j);
|
||||
obj_deref(w);
|
||||
|
|
@ -247,8 +222,8 @@ static int dispatch_a_job_(cluster_t* c,
|
|||
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 = (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;
|
||||
|
|
@ -265,8 +240,7 @@ static int dispatch_a_job_(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int job_ctrl(cluster_t* c,
|
||||
xce_jobctrl_t* ctrinfo)
|
||||
int job_ctrl(cluster_t* c, xce_jobctrl_t* ctrinfo)
|
||||
{
|
||||
uint64_t jobid = ctrinfo->jobid;
|
||||
job_t* j;
|
||||
|
|
@ -287,9 +261,7 @@ int job_ctrl(cluster_t* c,
|
|||
/* job control command will be sent to first node
|
||||
* for parallel jobs
|
||||
*/
|
||||
w = workermgr_lock(&(c->workermgr),
|
||||
allocs[0]->host,
|
||||
OBJREF_READ);
|
||||
w = workermgr_lock(&(c->workermgr), allocs[0]->host, OBJREF_READ);
|
||||
if (w != NULL) {
|
||||
/* FIXME: better method to check host status */
|
||||
if ((w->ep != NULL) && (w->host.status == 0)) {
|
||||
|
|
@ -297,8 +269,8 @@ int job_ctrl(cluster_t* c,
|
|||
if (ioctx != NULL) {
|
||||
rc = xce_jobctrl_req(ioctx, ctrinfo);
|
||||
if (rc < 0) {
|
||||
ERROR("job ctrl %ld on host %s returns %d",
|
||||
jobid, w->host.name, rc);
|
||||
ERROR("job ctrl %ld on host %s returns %d", jobid,
|
||||
w->host.name, rc);
|
||||
}
|
||||
} else {
|
||||
ERROR("memory allocate failed");
|
||||
|
|
@ -306,9 +278,7 @@ int job_ctrl(cluster_t* c,
|
|||
}
|
||||
} 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);
|
||||
|
|
@ -328,7 +298,8 @@ int job_ctrl(cluster_t* c,
|
|||
case JobControl_u_siginfo:
|
||||
switch (ctrinfo->u.siginfo->signo) {
|
||||
case SIGCONT:
|
||||
if (j->job.state & (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP)) {
|
||||
if (j->job.state
|
||||
& (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP)) {
|
||||
int state = j->job.state;
|
||||
|
||||
/* resume suspend job? */
|
||||
|
|
@ -338,7 +309,8 @@ int job_ctrl(cluster_t* c,
|
|||
break;
|
||||
case SIGSTOP:
|
||||
case SIGTSTP:
|
||||
if (!(j->job.state & (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP))) {
|
||||
if (!(j->job.state
|
||||
& (JOB_STAT_PSUSP | JOB_STAT_USUSP | JOB_STAT_SSUSP))) {
|
||||
int state = j->job.state;
|
||||
|
||||
state |= JOB_STAT_PSUSP;
|
||||
|
|
@ -348,7 +320,8 @@ int job_ctrl(cluster_t* c,
|
|||
case SIGKILL:
|
||||
case SIGTERM:
|
||||
default:
|
||||
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)) {
|
||||
break;
|
||||
}
|
||||
/* FIXME: */
|
||||
|
|
@ -379,10 +352,8 @@ int job_ctrl(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static void notify_dispatch(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
uint64_t jobid,
|
||||
int code)
|
||||
static void notify_dispatch(cluster_t* c, endpoint_t* ep, uint64_t jobid,
|
||||
int code)
|
||||
{
|
||||
/* clang-format off */
|
||||
job_failinfo_t info = {
|
||||
|
|
@ -400,9 +371,7 @@ static void notify_dispatch(cluster_t* c,
|
|||
notify(c, ep, &data);
|
||||
}
|
||||
|
||||
int handle_jobdispatch(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int handle_jobdispatch(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
int i;
|
||||
|
|
@ -435,9 +404,7 @@ int handle_jobdispatch(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int handle_jobsubmit(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int handle_jobsubmit(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
uint64_t jobid;
|
||||
xce_job_submit_t* submit;
|
||||
|
|
@ -449,22 +416,17 @@ int handle_jobsubmit(cluster_t* c,
|
|||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
if (NULLSTR(submit->user) || NULLSTR(submit->queue) || NULLSTR(submit->cmdline)) {
|
||||
if (NULLSTR(submit->user) || NULLSTR(submit->queue)
|
||||
|| NULLSTR(submit->cmdline)) {
|
||||
jobid = 0;
|
||||
errno = EINVAL;
|
||||
} else {
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_NEW,
|
||||
c, submit);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_NEW, c, submit);
|
||||
|
||||
jobid = job_submit(c, (char*)submit->user,
|
||||
(char*)submit->queue,
|
||||
(char*)submit->resreq,
|
||||
(char*)submit->cmdline,
|
||||
(char*)submit->exdata,
|
||||
submit->mintasks,
|
||||
jobid = job_submit(c, (char*)submit->user, (char*)submit->queue,
|
||||
(char*)submit->resreq, (char*)submit->cmdline,
|
||||
(char*)submit->exdata, submit->mintasks,
|
||||
submit->maxtasks);
|
||||
}
|
||||
if (jobid == 0) {
|
||||
|
|
@ -482,19 +444,14 @@ int handle_jobsubmit(cluster_t* c,
|
|||
xce_reply(ep, c->myhost, &reply);
|
||||
|
||||
/* Run hooks to tell scheduler */
|
||||
j = jobmgr_lockjob(&(c->jobmgr),
|
||||
jobid, OBJREF_READ);
|
||||
j = jobmgr_lockjob(&(c->jobmgr), jobid, OBJREF_READ);
|
||||
if (j == NULL) {
|
||||
ERROR("%s fail to lock job %lu",
|
||||
__func__, jobid);
|
||||
ERROR("%s fail to lock job %lu", __func__, jobid);
|
||||
} else {
|
||||
xlist_init(&jlist, 2);
|
||||
if (xlist_store(&jlist, j) >= 0) {
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_NEW,
|
||||
c, &jlist);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_AFTER_EVENT, HOOK_DETAIL_JOB_NEW, c, &jlist);
|
||||
} else {
|
||||
PERROR("xlist_store");
|
||||
}
|
||||
|
|
@ -506,15 +463,10 @@ int handle_jobsubmit(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mark_job_start(cluster_t* c,
|
||||
job_t* job,
|
||||
job_pidinfo_t* info)
|
||||
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);
|
||||
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);
|
||||
|
|
@ -527,23 +479,19 @@ static int mark_job_start(cluster_t* c,
|
|||
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 = create_obj_by_typename(&(c->objmgr), "xstring",
|
||||
info->exdata);
|
||||
job->job.pidinfo->exdata
|
||||
= create_obj_by_typename(&(c->objmgr), "xstring", info->exdata);
|
||||
} else {
|
||||
job->job.pidinfo->exdata = NULL;
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_START,
|
||||
c, info, job);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_START, c, info, job);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_job_start(cluster_t* c,
|
||||
job_pidinfo_t* info)
|
||||
int on_job_start(cluster_t* c, job_pidinfo_t* info)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
|
||||
|
|
@ -563,15 +511,10 @@ int on_job_start(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mark_job_finish(cluster_t* c,
|
||||
job_t* job,
|
||||
xce_jobfinish_t* finish)
|
||||
static int mark_job_finish(cluster_t* c, job_t* job, xce_jobfinish_t* finish)
|
||||
{
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_EXIT,
|
||||
c, finish, job);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_EXIT, c, finish, job);
|
||||
/* update job information */
|
||||
if (finish->exit_code == 0) {
|
||||
job->job.state = JOB_STAT_DONE;
|
||||
|
|
@ -592,22 +535,18 @@ static int mark_job_finish(cluster_t* c,
|
|||
|
||||
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);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_EXIT, c, finish, job);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_job_finish(cluster_t* c,
|
||||
xce_jobfinish_t* finish)
|
||||
int on_job_finish(cluster_t* c, xce_jobfinish_t* finish)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
|
||||
TRACE("%s job finish jobid %ld exit code %d",
|
||||
__func__, finish->jobid, finish->exit_code);
|
||||
TRACE("%s job finish jobid %ld exit code %d", __func__, finish->jobid,
|
||||
finish->exit_code);
|
||||
|
||||
job = jobmgr_lockjob(&(c->jobmgr), finish->jobid, OBJREF_UPDATE);
|
||||
if (job == NULL) {
|
||||
|
|
@ -623,22 +562,18 @@ int on_job_finish(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mark_job_fail(cluster_t* c,
|
||||
job_t* job,
|
||||
job_failinfo_t* failinfo)
|
||||
static int mark_job_fail(cluster_t* c, job_t* job, job_failinfo_t* failinfo)
|
||||
{
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_FAIL,
|
||||
c, failinfo, job);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_FAIL, c, failinfo, job);
|
||||
/* update job information */
|
||||
|
||||
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) {
|
||||
WARN("job %ld got post exec fail notification but job's exit status has not been set",
|
||||
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;
|
||||
}
|
||||
|
|
@ -651,43 +586,31 @@ static int mark_job_fail(cluster_t* c,
|
|||
|
||||
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);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_FAIL, c, failinfo, job);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mark_job_update(cluster_t* c,
|
||||
job_t* job,
|
||||
int state)
|
||||
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);
|
||||
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;
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_UPDATE,
|
||||
c, job);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_UPDATE, c, job);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_job_fail(cluster_t* c,
|
||||
job_failinfo_t* failinfo)
|
||||
int on_job_fail(cluster_t* c, job_failinfo_t* failinfo)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
|
||||
TRACE("%s job fail jobid %ld code %d",
|
||||
__func__, failinfo->jobid, failinfo->code);
|
||||
TRACE("%s job fail jobid %ld code %d", __func__, failinfo->jobid,
|
||||
failinfo->code);
|
||||
|
||||
job = jobmgr_lockjob(&(c->jobmgr), failinfo->jobid, OBJREF_UPDATE);
|
||||
if (job == NULL) {
|
||||
|
|
@ -703,14 +626,12 @@ int on_job_fail(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_job_stop(cluster_t* c,
|
||||
uint64_t jobid)
|
||||
int on_job_stop(cluster_t* c, uint64_t jobid)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
int state;
|
||||
|
||||
TRACE("%s job stop jobid %ld",
|
||||
__func__, jobid);
|
||||
TRACE("%s job stop jobid %ld", __func__, jobid);
|
||||
|
||||
job = jobmgr_lockjob(&(c->jobmgr), jobid, OBJREF_UPDATE);
|
||||
if (job == NULL) {
|
||||
|
|
@ -729,14 +650,12 @@ int on_job_stop(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_job_resume(cluster_t* c,
|
||||
uint64_t jobid)
|
||||
int on_job_resume(cluster_t* c, uint64_t jobid)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
int state;
|
||||
|
||||
TRACE("%s job resume jobid %ld",
|
||||
__func__, jobid);
|
||||
TRACE("%s job resume jobid %ld", __func__, jobid);
|
||||
|
||||
job = jobmgr_lockjob(&(c->jobmgr), jobid, OBJREF_UPDATE);
|
||||
if (job == NULL) {
|
||||
|
|
@ -754,15 +673,12 @@ int on_job_resume(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_job_postdone(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
uint64_t jobid)
|
||||
int on_job_postdone(cluster_t* c, endpoint_t* ep, uint64_t jobid)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
int state;
|
||||
|
||||
TRACE("%s job post done jobid %ld",
|
||||
__func__, jobid);
|
||||
TRACE("%s job post done jobid %ld", __func__, jobid);
|
||||
|
||||
job = jobmgr_lockjob(&(c->jobmgr), jobid, OBJREF_UPDATE);
|
||||
if (job == NULL) {
|
||||
|
|
@ -772,7 +688,8 @@ int on_job_postdone(cluster_t* c,
|
|||
|
||||
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",
|
||||
WARN("job %ld got post exec fail notification but job's exit status "
|
||||
"has not been set",
|
||||
job->job.jobid);
|
||||
state |= JOB_STAT_EXIT;
|
||||
/* ensure that job finish time has been set */
|
||||
|
|
@ -788,59 +705,44 @@ int on_job_postdone(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_job_ckpt(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_ckptinfo_t* ckptinfo)
|
||||
int on_job_ckpt(cluster_t* c, endpoint_t* ep, xce_ckptinfo_t* ckptinfo)
|
||||
{
|
||||
uint64_t jobid;
|
||||
char* info = NULL;
|
||||
job_t* j;
|
||||
|
||||
if (ckptinfo == NULL) {
|
||||
ERROR("%s ckptinfo should not be NULL",
|
||||
__func__);
|
||||
ERROR("%s ckptinfo should not be NULL", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
jobid = ckptinfo->jobid;
|
||||
info = ckptinfo->ckptinfo;
|
||||
|
||||
TRACE("%s job %ld ckptinfo %s",
|
||||
__func__, jobid, info);
|
||||
TRACE("%s job %ld ckptinfo %s", __func__, jobid, info);
|
||||
|
||||
j = jobmgr_lockjob(&(c->jobmgr), jobid,
|
||||
OBJREF_UPDATE);
|
||||
j = jobmgr_lockjob(&(c->jobmgr), jobid, OBJREF_UPDATE);
|
||||
if (j == NULL) {
|
||||
ERROR("%s can not find job %ld",
|
||||
__func__, jobid);
|
||||
ERROR("%s can not find job %ld", __func__, jobid);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_JOB_CKPT,
|
||||
c, j);
|
||||
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);
|
||||
}
|
||||
|
||||
j->job.ckptinfo = create_obj_by_typename(&(c->objmgr), "xstring",
|
||||
info);
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_CKPT,
|
||||
c, j);
|
||||
j->job.ckptinfo = create_obj_by_typename(&(c->objmgr), "xstring", info);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_CKPT, c, j);
|
||||
|
||||
obj_deref(j);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_jobcontrol_op(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int do_jobcontrol_op(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
|
@ -855,17 +757,14 @@ int do_jobcontrol_op(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int update_job_rusages(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int update_job_rusages(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
xce_job_rusages_t* rusages = request->body.updatemsg->data.jobrusages;
|
||||
job_t* j;
|
||||
worker_t* w;
|
||||
char* host = NULL;
|
||||
|
||||
TRACE("%s trying to update job(%ld) rusage",
|
||||
__func__, rusages->jobid);
|
||||
TRACE("%s trying to update job(%ld) rusage", __func__, rusages->jobid);
|
||||
|
||||
j = jobmgr_lockjob(&(c->jobmgr), rusages->jobid, OBJREF_UPDATE);
|
||||
if (j == NULL) {
|
||||
|
|
@ -879,43 +778,30 @@ int update_job_rusages(cluster_t* c,
|
|||
return errno;
|
||||
}
|
||||
|
||||
host = create_obj_by_typename(&(c->objmgr), "xstring",
|
||||
w->host.name);
|
||||
host = create_obj_by_typename(&(c->objmgr), "xstring", w->host.name);
|
||||
obj_deref(w);
|
||||
|
||||
if (host == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
TRACE("%s update job (%ld) rusage for host %s",
|
||||
__func__, rusages->jobid, host);
|
||||
TRACE("%s update job (%ld) rusage for host %s", __func__, rusages->jobid,
|
||||
host);
|
||||
|
||||
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,
|
||||
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,
|
||||
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
|
||||
*/
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_UPDATE,
|
||||
c, j);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_JOB_UPDATE, c, j);
|
||||
|
||||
obj_deref(j);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -9,14 +9,10 @@
|
|||
#include "xce/errnox.h"
|
||||
#include "xstring.h"
|
||||
|
||||
int jobmgr_init(jobmgr_t* mgr,
|
||||
int nhslots,
|
||||
int delta)
|
||||
int jobmgr_init(jobmgr_t* mgr, int nhslots, int delta)
|
||||
{
|
||||
ht_init(&(mgr->htab), nhslots,
|
||||
int_hash_key);
|
||||
zarray_init(&(mgr->jobs), delta,
|
||||
(zarray_item_killer_t)job_obj_killer);
|
||||
ht_init(&(mgr->htab), nhslots, int_hash_key);
|
||||
zarray_init(&(mgr->jobs), delta, (zarray_item_killer_t)job_obj_killer);
|
||||
mylock_init(&(mgr->lock));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -28,9 +24,7 @@ void jobmgr_fini(jobmgr_t* mgr)
|
|||
mylock_fini(&(mgr->lock));
|
||||
}
|
||||
|
||||
job_t* jobmgr_lockjob_(jobmgr_t* mgr,
|
||||
uint64_t jobid,
|
||||
int op)
|
||||
job_t* jobmgr_lockjob_(jobmgr_t* mgr, uint64_t jobid, int op)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -54,9 +48,7 @@ job_t* jobmgr_lockjob_(jobmgr_t* mgr,
|
|||
return obj_ref(job, op);
|
||||
}
|
||||
|
||||
job_t* jobmgr_lockjob(jobmgr_t* mgr,
|
||||
uint64_t jobid,
|
||||
int op)
|
||||
job_t* jobmgr_lockjob(jobmgr_t* mgr, uint64_t jobid, int op)
|
||||
{
|
||||
job_t* job = NULL;
|
||||
|
||||
|
|
@ -81,14 +73,12 @@ job_t* jobmgr_lockjob(jobmgr_t* mgr,
|
|||
return job;
|
||||
}
|
||||
|
||||
static int32_t jobmgr_add_job_(jobmgr_t* mgr,
|
||||
job_t* job)
|
||||
static int32_t jobmgr_add_job_(jobmgr_t* mgr, job_t* job)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
||||
e = ht_get(&(mgr->htab),
|
||||
(void*)job->job.jobid);
|
||||
e = ht_get(&(mgr->htab), (void*)job->job.jobid);
|
||||
if (e != NULL) {
|
||||
return -EEXIST;
|
||||
}
|
||||
|
|
@ -98,8 +88,7 @@ static int32_t jobmgr_add_job_(jobmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
e = ht_add(&(mgr->htab),
|
||||
(void*)job->job.jobid);
|
||||
e = ht_add(&(mgr->htab), (void*)job->job.jobid);
|
||||
if (e == NULL) {
|
||||
zarray_del(&(mgr->jobs), idx);
|
||||
return -errno;
|
||||
|
|
@ -109,8 +98,7 @@ static int32_t jobmgr_add_job_(jobmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
int32_t jobmgr_add_job(jobmgr_t* mgr,
|
||||
job_t* job)
|
||||
int32_t jobmgr_add_job(jobmgr_t* mgr, job_t* job)
|
||||
{
|
||||
int32_t idx;
|
||||
|
||||
|
|
@ -125,14 +113,12 @@ int32_t jobmgr_add_job(jobmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
static void jobmgr_del_job_(jobmgr_t* mgr,
|
||||
job_t* job)
|
||||
static void jobmgr_del_job_(jobmgr_t* mgr, job_t* job)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
||||
e = ht_get(&(mgr->htab),
|
||||
(void*)job->job.jobid);
|
||||
e = ht_get(&(mgr->htab), (void*)job->job.jobid);
|
||||
if (e == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -147,8 +133,7 @@ static void jobmgr_del_job_(jobmgr_t* mgr,
|
|||
return;
|
||||
}
|
||||
|
||||
void jobmgr_del_job(jobmgr_t* mgr,
|
||||
job_t* job)
|
||||
void jobmgr_del_job(jobmgr_t* mgr, job_t* job)
|
||||
{
|
||||
if ((mgr == NULL) || (job == NULL)) {
|
||||
return;
|
||||
|
|
@ -158,9 +143,7 @@ void jobmgr_del_job(jobmgr_t* mgr,
|
|||
mylock_unlock(&(mgr->lock));
|
||||
}
|
||||
|
||||
int jobmgr_iter(jobmgr_t* mgr,
|
||||
xlist_t* l,
|
||||
void* arg)
|
||||
int jobmgr_iter(jobmgr_t* mgr, xlist_t* l, void* arg)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,15 +8,12 @@
|
|||
#include "xce/cluster_def.h"
|
||||
#include "xce/errnox.h"
|
||||
|
||||
static int validate_host(cluster_t* c,
|
||||
const char* host,
|
||||
const char* key)
|
||||
static int validate_host(cluster_t* c, const char* host, const char* key)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int handle_client_join(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
static int handle_client_join(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
xce_reply_t reply;
|
||||
|
|
@ -31,8 +28,7 @@ static int handle_client_join(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_worker_join(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
static int handle_worker_join(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
int idx;
|
||||
|
|
@ -42,14 +38,12 @@ static int handle_worker_join(cluster_t* c,
|
|||
int rc = 0;
|
||||
xce_joindata_t* joinmsg = NULL;
|
||||
|
||||
TRACE("%s worker %s joining...",
|
||||
__func__, from->name);
|
||||
TRACE("%s worker %s joining...", __func__, from->name);
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
if (!validate_host(c, from->name, from->key)) {
|
||||
ERROR("%s reject join of host %s",
|
||||
__func__, from->name);
|
||||
ERROR("%s reject join of host %s", __func__, from->name);
|
||||
rc = -EPERM;
|
||||
|
||||
reply.status = rc;
|
||||
|
|
@ -61,25 +55,18 @@ static int handle_worker_join(cluster_t* c,
|
|||
|
||||
joinmsg = request->body.joinmsg;
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_WORKER_JOIN,
|
||||
c, from->name, 0);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_WORKER_JOIN, c, from->name, 0);
|
||||
idx = add_worker(c, ep, from->name, joinmsg->data.attrs);
|
||||
|
||||
reply.status = idx;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
xce_reply(ep, c->myhost, &reply);
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_JOIN,
|
||||
c, from->name, idx);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_JOIN, c, from->name, idx);
|
||||
if (idx < 0) {
|
||||
ERROR("worker %s join failed, rc %d",
|
||||
from->name, idx);
|
||||
ERROR("worker %s join failed, rc %d", from->name, idx);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
|
@ -90,15 +77,13 @@ static int handle_worker_join(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_scheduler_join(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
static int handle_scheduler_join(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
xce_reply_t reply;
|
||||
ep_private_t* priv = (ep_private_t*)ep->data;
|
||||
|
||||
TRACE("%s scheduler join, ep %p",
|
||||
__func__, ep);
|
||||
TRACE("%s scheduler join, ep %p", __func__, ep);
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
|
|
@ -114,8 +99,7 @@ static int handle_scheduler_join(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_controller_join(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
static int handle_controller_join(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
xce_reply_t reply;
|
||||
|
|
@ -132,9 +116,7 @@ static int handle_controller_join(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int handle_join_(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
static int handle_join_(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
ep_private_t* priv;
|
||||
int rc = -EINVAL;
|
||||
|
|
@ -160,8 +142,7 @@ static int handle_join_(cluster_t* c,
|
|||
role = request->body.joinmsg->role;
|
||||
priv->role = role;
|
||||
|
||||
TRACE("%s role %d join from %s",
|
||||
__func__, role, from->name);
|
||||
TRACE("%s role %d join from %s", __func__, role, from->name);
|
||||
|
||||
switch (role) {
|
||||
case HostRole_client:
|
||||
|
|
@ -178,8 +159,7 @@ static int handle_join_(cluster_t* c,
|
|||
break;
|
||||
default:
|
||||
rc = -E_XCE_BAD_ROLE;
|
||||
ERROR("unknown role %d from host %s",
|
||||
role, from->name);
|
||||
ERROR("unknown role %d from host %s", role, from->name);
|
||||
|
||||
reply.status = rc;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
|
|
@ -190,9 +170,7 @@ static int handle_join_(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int handle_join(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int handle_join(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,27 +9,28 @@
|
|||
|
||||
extern int myapp_run(myconf_t*);
|
||||
|
||||
static char doc[] = "xce_controller";
|
||||
static char args_doc[] = "";
|
||||
const char* argp_program_version = MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID));
|
||||
const char* argp_program_bug_address = BUG_EMAIL;
|
||||
static char doc[] = "xce_controller";
|
||||
static char args_doc[] = "";
|
||||
const char* argp_program_version
|
||||
= MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID));
|
||||
const char* argp_program_bug_address = BUG_EMAIL;
|
||||
|
||||
struct arguments {
|
||||
char* myname;
|
||||
char* logfile;
|
||||
char* workdir;
|
||||
int verbose;
|
||||
};
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{ "workdir", 'w', "DIR", 0, "The work directory of xce controller"},
|
||||
{ "workdir", 'w', "DIR", 0, "The work directory of xce controller" },
|
||||
{ "logfile", 'l', "FILE", 0, "The full path of log file" },
|
||||
{ "verbose", 'v', 0, 0, "Produce verbose logs" },
|
||||
{ "myname", 'n', "STR", 0, "The name of controller" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static error_t parse_opt(int key,
|
||||
char* arg,
|
||||
struct argp_state* state)
|
||||
static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
||||
{
|
||||
struct arguments* arguments = state->input;
|
||||
|
||||
|
|
@ -43,6 +44,9 @@ static error_t parse_opt(int key,
|
|||
case 'w':
|
||||
arguments->workdir = arg;
|
||||
break;
|
||||
case 'n':
|
||||
arguments->myname = arg;
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
@ -50,12 +54,7 @@ static error_t parse_opt(int key,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct argp argp = {
|
||||
options,
|
||||
parse_opt,
|
||||
args_doc,
|
||||
doc
|
||||
};
|
||||
static struct argp argp = { options, parse_opt, args_doc, doc };
|
||||
|
||||
static char* verbose_to_loglevel(int verbose)
|
||||
{
|
||||
|
|
@ -83,13 +82,14 @@ static char* verbose_to_loglevel(int verbose)
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
struct arguments arguments;
|
||||
myconf_t myconf;
|
||||
char* logfile = "/tmp/xce_controller.log";
|
||||
char* loglevel = "info";
|
||||
int logsize = 64 * 1024 * 1024;
|
||||
int logcount = 10;
|
||||
char conf_file[XCE_MAXPATH_LEN+1];
|
||||
struct arguments arguments;
|
||||
myconf_t myconf;
|
||||
char* logfile = "/tmp/xce_controller.log";
|
||||
char* loglevel = "info";
|
||||
int logsize = 64 * 1024 * 1024;
|
||||
int logcount = 10;
|
||||
char conf_file[XCE_MAXPATH_LEN + 1];
|
||||
char myname[XCE_MAXNAME_LEN + 1];
|
||||
|
||||
memset(&arguments, 0x0, sizeof(arguments));
|
||||
|
||||
|
|
@ -104,18 +104,27 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
mylog_init(logfile, loglevel, logsize, logcount);
|
||||
|
||||
|
||||
if (arguments.workdir == NULL) {
|
||||
INFO("no cluster work directory specified. The default work directory `"
|
||||
DEFAULT_WORKDIR
|
||||
"' will be used.");
|
||||
INFO("no cluster work directory specified. The default work directory "
|
||||
"`" DEFAULT_WORKDIR "' will be used.");
|
||||
arguments.workdir = DEFAULT_WORKDIR;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.myname == NULL) {
|
||||
if (get_myname(myname, sizeof(myname) - 1) < 0) {
|
||||
ERROR("get_myname");
|
||||
return -1;
|
||||
}
|
||||
arguments.myname = myname;
|
||||
}
|
||||
|
||||
INFO("My name is %s", myname);
|
||||
|
||||
memset(&conf_file, 0x0, sizeof(conf_file));
|
||||
snprintf(conf_file, XCE_MAXPATH_LEN,
|
||||
"%s/conf/current_config", arguments.workdir);
|
||||
|
||||
snprintf(conf_file, XCE_MAXPATH_LEN, "%s/%s/conf/current_config",
|
||||
arguments.workdir, myname);
|
||||
|
||||
myconf.cluster_config = NULL;
|
||||
myconf.conffile = conf_file;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ controller_src = [
|
|||
'task.c',
|
||||
'worker.c',
|
||||
'workermgr.c',
|
||||
'wrap.c',
|
||||
'xceobjs.c',
|
||||
'myconf.c'
|
||||
]
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@
|
|||
#include "xce/types.h"
|
||||
#include "xlist.h"
|
||||
|
||||
int add_to_xlist(xlist_t* l, void* data)
|
||||
{
|
||||
return xlist_store(l, data);
|
||||
}
|
||||
int add_to_xlist(xlist_t* l, void* data) { return xlist_store(l, data); }
|
||||
|
||||
int add_worker_to_xlist(xlist_t* l, void* data)
|
||||
{
|
||||
|
|
@ -43,17 +40,14 @@ int get_ep_role(endpoint_t* ep)
|
|||
|
||||
priv = (ep_private_t*)ep->data;
|
||||
if (priv == NULL) {
|
||||
ERROR("priv data of endpoint %p is NULL",
|
||||
ep);
|
||||
ERROR("priv data of endpoint %p is NULL", ep);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return priv->role;
|
||||
}
|
||||
|
||||
worker_t* get_ep_worker(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
int op)
|
||||
worker_t* get_ep_worker(cluster_t* c, endpoint_t* ep, int op)
|
||||
{
|
||||
int role, idx;
|
||||
worker_t* w = NULL;
|
||||
|
|
@ -78,10 +72,8 @@ worker_t* get_ep_worker(cluster_t* c,
|
|||
return w;
|
||||
}
|
||||
|
||||
int update_host_runusage(xce_job_runusage_t** runusage,
|
||||
char* host,
|
||||
int count,
|
||||
xce_rusage_t** usages)
|
||||
int update_host_runusage(xce_job_runusage_t** runusage, char* host, int count,
|
||||
xce_rusage_t** usages)
|
||||
{
|
||||
xce_job_runusage_t* rusages = NULL;
|
||||
int i, j;
|
||||
|
|
@ -105,8 +97,8 @@ int update_host_runusage(xce_job_runusage_t** runusage,
|
|||
|
||||
if (j < 0) {
|
||||
int cnt = rusages->num_hosts + 1;
|
||||
xce_host_runusage_t** hru = (xce_host_runusage_t**)realloc(rusages->host_runusage,
|
||||
cnt * sizeof(xce_host_runusage_t*));
|
||||
xce_host_runusage_t** hru = (xce_host_runusage_t**)realloc(
|
||||
rusages->host_runusage, cnt * sizeof(xce_host_runusage_t*));
|
||||
if (hru == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -138,9 +130,7 @@ int update_host_runusage(xce_job_runusage_t** runusage,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int update_pids(job_pidinfo_t** pidinfo,
|
||||
int npids,
|
||||
int* pids)
|
||||
int update_pids(job_pidinfo_t** pidinfo, int npids, int* pids)
|
||||
{
|
||||
job_pidinfo_t* info;
|
||||
int i;
|
||||
|
|
@ -158,8 +148,7 @@ int update_pids(job_pidinfo_t** pidinfo,
|
|||
info->pids = (unsigned int*)calloc(npids, sizeof(unsigned int));
|
||||
} else if (info->npids < npids) {
|
||||
unsigned int* ptr;
|
||||
ptr = (unsigned int*)realloc(info->pids,
|
||||
npids * sizeof(unsigned int));
|
||||
ptr = (unsigned int*)realloc(info->pids, npids * sizeof(unsigned int));
|
||||
if (ptr == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -176,9 +165,7 @@ int update_pids(job_pidinfo_t** pidinfo,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int update_pgids(job_pidinfo_t** pidinfo,
|
||||
int npgids,
|
||||
int* pgids)
|
||||
int update_pgids(job_pidinfo_t** pidinfo, int npgids, int* pgids)
|
||||
{
|
||||
job_pidinfo_t* info;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ int myapp_run(myconf_t* myconf)
|
|||
cluster_t c;
|
||||
int rc;
|
||||
|
||||
memset(&c, 0x0, sizeof(c));
|
||||
|
||||
c.myconf = myconf;
|
||||
|
||||
rc = cluster_init(&c);
|
||||
|
|
|
|||
|
|
@ -11,19 +11,13 @@
|
|||
#include "xce/cluster_def.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
int add_config(void* c,
|
||||
char* name,
|
||||
char* value)
|
||||
int add_config(void* c, char* name, char* value)
|
||||
{
|
||||
cluster_t* cls = (cluster_t*)c;
|
||||
xce_config_t var = {
|
||||
.name = name,
|
||||
.value = value
|
||||
};
|
||||
xce_config_t* cv = NULL;
|
||||
cluster_t* cls = (cluster_t*)c;
|
||||
xce_config_t var = { .name = name, .value = value };
|
||||
xce_config_t* cv = NULL;
|
||||
|
||||
cv = create_obj_by_typename(&(cls->objmgr), "xconfig",
|
||||
&var);
|
||||
cv = create_obj_by_typename(&(cls->objmgr), "xconfig", &var);
|
||||
if (cv == NULL) {
|
||||
return -errno;
|
||||
}
|
||||
|
|
@ -35,10 +29,7 @@ struct cluster_configuration {
|
|||
cluster_config_t* cluster;
|
||||
};
|
||||
|
||||
static int config_fini(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int config_fini(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
struct cluster_configuration* cf = (struct cluster_configuration*)data;
|
||||
|
||||
|
|
@ -55,10 +46,7 @@ static int config_fini(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cluster_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
static int cluster_hook_fun(int type, int situation, int detail, void* data,
|
||||
va_list ap)
|
||||
{
|
||||
if (detail == HOOK_DETAIL_CLUSTER_SHUTDOWN) {
|
||||
|
|
@ -68,11 +56,11 @@ static int cluster_hook_fun(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define SET_DEFAULT_IF_UNSET(var, unset, val) \
|
||||
do { \
|
||||
if ((var) == (unset)) { \
|
||||
(var) = (val); \
|
||||
} \
|
||||
#define SET_DEFAULT_IF_UNSET(var, unset, val) \
|
||||
do { \
|
||||
if ((var) == (unset)) { \
|
||||
(var) = (val); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static void fill_default_cluster_config(cluster_config_t* c)
|
||||
|
|
@ -83,8 +71,7 @@ static void fill_default_cluster_config(cluster_config_t* c)
|
|||
SET_DEFAULT_IF_UNSET(c->fetch_job_interval, 0, 10);
|
||||
}
|
||||
|
||||
static int load_cluster_config_from_file(char* file,
|
||||
cluster_config_t** config)
|
||||
static int load_cluster_config_from_file(char* file, cluster_config_t** config)
|
||||
{
|
||||
struct capn c;
|
||||
ClusterConfig_ptr p;
|
||||
|
|
@ -116,14 +103,17 @@ int load_cluster_config(cluster_t* c,
|
|||
cluster_config_t* cfg;
|
||||
int rc;
|
||||
|
||||
*cluster_config = (struct cluster_configuration*)calloc(1, sizeof(*cluster_config));
|
||||
*cluster_config
|
||||
= (struct cluster_configuration*)calloc(1, sizeof(*cluster_config));
|
||||
if ((*cluster_config) == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
rc = load_cluster_config_from_file(c->myconf->conffile, &((*cluster_config)->cluster));
|
||||
rc = load_cluster_config_from_file(c->myconf->conffile,
|
||||
&((*cluster_config)->cluster));
|
||||
|
||||
if (rc < 0) {
|
||||
ERROR("failed to load configuration file `%s'", c->myconf->conffile);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -135,10 +125,8 @@ int load_cluster_config(cluster_t* c,
|
|||
|
||||
fill_default_cluster_config(cfg);
|
||||
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
(hook_fn_t)cluster_hook_fun,
|
||||
(*cluster_config));
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
(hook_fn_t)cluster_hook_fun, (*cluster_config));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -160,4 +148,3 @@ cluster_config_t* get_default_conf(void* cl)
|
|||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,23 +9,17 @@
|
|||
#include "utils.h"
|
||||
#include "xce/cluster_def.h"
|
||||
|
||||
static int
|
||||
do_reply_reslist(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
static int do_reply_reslist(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
xce_reply_t reply;
|
||||
xce_resource_data_t resdata;
|
||||
xce_data_t getdata = {
|
||||
.table = request->body.getmsg->table,
|
||||
.data = {
|
||||
.resources = &resdata }
|
||||
};
|
||||
int rc = 0;
|
||||
xce_data_t getdata = { .table = request->body.getmsg->table,
|
||||
.data = { .resources = &resdata } };
|
||||
int rc = 0;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
collect_resources(c, NULL, &(resdata.n_total),
|
||||
&(resdata.resources));
|
||||
collect_resources(c, NULL, &(resdata.n_total), &(resdata.resources));
|
||||
|
||||
reply.status = 0;
|
||||
reply.data_which = RequestReply_data_getdata;
|
||||
|
|
@ -39,24 +33,17 @@ do_reply_reslist(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
do_reply_resvals(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
static int do_reply_resvals(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
xce_reply_t reply;
|
||||
xce_resval_data_t resvaldata;
|
||||
xce_get_t* getmsg = request->body.getmsg;
|
||||
xce_data_t getdata = {
|
||||
.data = {
|
||||
.resvals = &resvaldata }
|
||||
};
|
||||
int rc = 0;
|
||||
xce_val_t val;
|
||||
xce_resval_t resval;
|
||||
xce_resval_t* vals[] = {
|
||||
&resval
|
||||
};
|
||||
xce_data_t getdata = { .data = { .resvals = &resvaldata } };
|
||||
int rc = 0;
|
||||
xce_val_t val;
|
||||
xce_resval_t resval;
|
||||
xce_resval_t* vals[] = { &resval };
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
|
|
@ -69,8 +56,7 @@ do_reply_resvals(cluster_t* c,
|
|||
if (condition != NULL) {
|
||||
getdata.table = getmsg->table;
|
||||
rc = get_resval(c, condition->condition.reskey->resname,
|
||||
condition->condition.reskey->hostname,
|
||||
&val);
|
||||
condition->condition.reskey->hostname, &val);
|
||||
if (rc >= 0) {
|
||||
resval.val = &val;
|
||||
resval.name = condition->condition.reskey->resname;
|
||||
|
|
@ -103,10 +89,8 @@ int check_worker_(xce_worker_t* w)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
do_reply_workerlist(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
static int do_reply_workerlist(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
xce_reply_t reply;
|
||||
xce_workers_data_t workerdata;
|
||||
|
|
@ -121,21 +105,19 @@ do_reply_workerlist(cluster_t* c,
|
|||
int i;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_,
|
||||
&(workerdata.n_total), &(workerdata.workers));
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_, &(workerdata.n_total),
|
||||
&(workerdata.workers));
|
||||
|
||||
reply.status = 0;
|
||||
reply.data_which = RequestReply_data_getdata;
|
||||
reply.data.getdata = &getdata;
|
||||
|
||||
rc = xce_reply_get(ep, c->myhost, &reply,
|
||||
check_controller, c, 100);
|
||||
rc = xce_reply_get(ep, c->myhost, &reply, check_controller, c, 100);
|
||||
|
||||
for (i = 0; i < workerdata.n_total; i++) {
|
||||
xce_worker_t* w = workerdata.workers[i];
|
||||
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched),
|
||||
w->nresvals_to_sched);
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched), w->nresvals_to_sched);
|
||||
}
|
||||
|
||||
deref_objs(workerdata.n_total, (void**)workerdata.workers);
|
||||
|
|
@ -153,30 +135,24 @@ static int check_job_(xce_job_t* j)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
do_reply_joblist(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
static int do_reply_joblist(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
xce_reply_t reply;
|
||||
xce_jobs_data_t jobdata;
|
||||
xce_data_t getdata = {
|
||||
.table = request->body.getmsg->table,
|
||||
.data = {
|
||||
.jobs = &jobdata }
|
||||
};
|
||||
int rc = 0;
|
||||
xce_data_t getdata = { .table = request->body.getmsg->table,
|
||||
.data = { .jobs = &jobdata } };
|
||||
int rc = 0;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
collect_jobs(c, (collect_check_fn_t)check_job_,
|
||||
&(jobdata.n_total), &(jobdata.jobs));
|
||||
collect_jobs(c, (collect_check_fn_t)check_job_, &(jobdata.n_total),
|
||||
&(jobdata.jobs));
|
||||
|
||||
reply.status = 0;
|
||||
reply.data_which = RequestReply_data_getdata;
|
||||
reply.data.getdata = &getdata;
|
||||
|
||||
rc = xce_reply_get(ep, c->myhost, &reply,
|
||||
check_controller, c, 100);
|
||||
rc = xce_reply_get(ep, c->myhost, &reply, check_controller, c, 100);
|
||||
|
||||
deref_objs(jobdata.n_total, (void**)jobdata.jobs);
|
||||
FREEUP(jobdata.jobs);
|
||||
|
|
@ -184,15 +160,12 @@ do_reply_joblist(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int do_get_op(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int do_get_op(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
||||
TRACE("%s table %d",
|
||||
__func__, request->body.getmsg->table);
|
||||
TRACE("%s table %d", __func__, request->body.getmsg->table);
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,8 @@
|
|||
#include "cluster.h"
|
||||
#include "xce/cluster_def.h"
|
||||
|
||||
static int
|
||||
do_update_resvals(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
static int do_update_resvals(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
ep_private_t* priv = NULL;
|
||||
int rc = -EPERM;
|
||||
|
|
@ -27,25 +25,20 @@ do_update_resvals(cluster_t* c,
|
|||
if ((priv->role == HostRole_worker) && (idx >= 0)) {
|
||||
worker_t* w;
|
||||
|
||||
w = workermgr_lock_byid(&(c->workermgr),
|
||||
idx, OBJREF_UPDATE);
|
||||
w = workermgr_lock_byid(&(c->workermgr), idx, OBJREF_UPDATE);
|
||||
if (w == NULL) {
|
||||
rc = -E_XCE_BAD_WORKER;
|
||||
} else {
|
||||
xce_update_data_t* updatemsg = request->body.updatemsg;
|
||||
xce_resval_list_t* resvals = updatemsg->data.resvals;
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_RESOURCE_UPDATE,
|
||||
c, resvals);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
HOOK_BEFORE_EVENT, HOOK_DETAIL_RESOURCE_UPDATE, c,
|
||||
resvals);
|
||||
rc = update_resval_list(c, w, resvals);
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_RESOURCE_UPDATE,
|
||||
c, resvals);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
HOOK_AFTER_EVENT, HOOK_DETAIL_RESOURCE_UPDATE, c,
|
||||
resvals);
|
||||
DEREF_OBJ(w);
|
||||
}
|
||||
}
|
||||
|
|
@ -58,8 +51,7 @@ do_update_resvals(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_jobrusage(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
static int do_update_jobrusage(cluster_t* c, endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
|
|
@ -75,9 +67,7 @@ static int do_update_jobrusage(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int do_update_op(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int do_update_op(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
|
|
|||
|
|
@ -9,15 +9,11 @@
|
|||
|
||||
extern void queue_obj_killer(queue_t*);
|
||||
|
||||
int qmgr_init(qmgr_t* mgr,
|
||||
int nslots,
|
||||
int delta)
|
||||
int qmgr_init(qmgr_t* mgr, int nslots, int delta)
|
||||
{
|
||||
mylock_init(&(mgr->lock));
|
||||
ht_init(&(mgr->htab), nslots,
|
||||
string_hash_key);
|
||||
zarray_init(&(mgr->queues), delta,
|
||||
(zarray_item_killer_t)queue_obj_killer);
|
||||
ht_init(&(mgr->htab), nslots, string_hash_key);
|
||||
zarray_init(&(mgr->queues), delta, (zarray_item_killer_t)queue_obj_killer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -28,8 +24,7 @@ void qmgr_fini(qmgr_t* mgr)
|
|||
mylock_fini(&(mgr->lock));
|
||||
}
|
||||
|
||||
static int qmgr_add_(qmgr_t* mgr,
|
||||
queue_t* q)
|
||||
static int qmgr_add_(qmgr_t* mgr, queue_t* q)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -54,8 +49,7 @@ static int qmgr_add_(qmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
int qmgr_add(qmgr_t* mgr,
|
||||
queue_t* q)
|
||||
int qmgr_add(qmgr_t* mgr, queue_t* q)
|
||||
{
|
||||
int idx;
|
||||
|
||||
|
|
@ -69,9 +63,7 @@ int qmgr_add(qmgr_t* mgr,
|
|||
|
||||
return idx;
|
||||
}
|
||||
static queue_t* qmgr_lockq_(qmgr_t* mgr,
|
||||
char* name,
|
||||
int op)
|
||||
static queue_t* qmgr_lockq_(qmgr_t* mgr, char* name, int op)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -93,9 +85,7 @@ static queue_t* qmgr_lockq_(qmgr_t* mgr,
|
|||
|
||||
return obj_ref(q, op);
|
||||
}
|
||||
queue_t* qmgr_lockq(qmgr_t* mgr,
|
||||
char* name,
|
||||
int op)
|
||||
queue_t* qmgr_lockq(qmgr_t* mgr, char* name, int op)
|
||||
{
|
||||
queue_t* q = NULL;
|
||||
|
||||
|
|
@ -125,14 +115,12 @@ queue_t* qmgr_lockq(qmgr_t* mgr,
|
|||
return q;
|
||||
}
|
||||
|
||||
static void qmgr_delq_(qmgr_t* mgr,
|
||||
queue_t* q)
|
||||
static void qmgr_delq_(qmgr_t* mgr, queue_t* q)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
||||
e = ht_get(&(mgr->htab),
|
||||
(void*)q->queue.queue);
|
||||
e = ht_get(&(mgr->htab), (void*)q->queue.queue);
|
||||
if (e == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -145,8 +133,7 @@ static void qmgr_delq_(qmgr_t* mgr,
|
|||
zarray_del(&(mgr->queues), idx);
|
||||
}
|
||||
|
||||
void qmgr_delq(qmgr_t* mgr,
|
||||
queue_t* q)
|
||||
void qmgr_delq(qmgr_t* mgr, queue_t* q)
|
||||
{
|
||||
if ((mgr == NULL) || (q == NULL)) {
|
||||
return;
|
||||
|
|
@ -157,9 +144,7 @@ void qmgr_delq(qmgr_t* mgr,
|
|||
mylock_unlock(&(mgr->lock));
|
||||
}
|
||||
|
||||
int qmgr_iter(qmgr_t* mgr,
|
||||
xlist_t* l,
|
||||
void* arg)
|
||||
int qmgr_iter(qmgr_t* mgr, xlist_t* l, void* arg)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,16 +13,14 @@ void queue_fini(queue_t* q)
|
|||
}
|
||||
}
|
||||
|
||||
queue_t* create_queue(cluster_t* c,
|
||||
xce_queue_t* p)
|
||||
queue_t* create_queue(cluster_t* c, xce_queue_t* p)
|
||||
{
|
||||
queue_t q1;
|
||||
queue_t* q;
|
||||
|
||||
memcpy(&(q1.queue), p, sizeof(q1.queue));
|
||||
|
||||
q = create_obj_by_typename(&(c->objmgr), "xqueue",
|
||||
&q1);
|
||||
q = create_obj_by_typename(&(c->objmgr), "xqueue", &q1);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
|
@ -94,20 +92,15 @@ int queue_ctrl(cluster_t* c, xce_queuectrl_t* ctrl)
|
|||
break;
|
||||
}
|
||||
if (rc == 0) {
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_QUEUE,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_QUEUE_UPDATE,
|
||||
c, q);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_QUEUE,
|
||||
HOOK_AFTER_EVENT, HOOK_DETAIL_QUEUE_UPDATE, c, q);
|
||||
}
|
||||
clean:
|
||||
obj_deref(q);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int do_queuecontrol_op(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int do_queuecontrol_op(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
|
@ -122,16 +115,14 @@ int do_queuecontrol_op(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int get_queue_exec(cluster_t* c,
|
||||
char* queue,
|
||||
char** pre_exec,
|
||||
char** post_exec)
|
||||
int get_queue_exec(cluster_t* c, char* queue, char** pre_exec, char** post_exec)
|
||||
{
|
||||
queue_t* q = NULL;
|
||||
|
||||
TRACE("entering %s", __func__);
|
||||
|
||||
if ((c == NULL) || (queue == NULL) || (pre_exec == NULL) || (post_exec == NULL)) {
|
||||
if ((c == NULL) || (queue == NULL) || (pre_exec == NULL)
|
||||
|| (post_exec == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@
|
|||
#include "cluster.h"
|
||||
#include "xce/cluster_def.h"
|
||||
|
||||
int handle_clusterconf(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
int handle_clusterconf(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_reply_t reply;
|
||||
|
|
@ -45,26 +43,20 @@ int handle_clusterconf(cluster_t* c,
|
|||
collect_resources(c, NULL, &(clusterconf.reslist.count),
|
||||
&(clusterconf.reslist.res));
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_,
|
||||
&(clusterconf.wlist.count),
|
||||
&(clusterconf.wlist.workers));
|
||||
&(clusterconf.wlist.count), &(clusterconf.wlist.workers));
|
||||
|
||||
xce_reply(ep, c->myhost, &reply);
|
||||
|
||||
for (i = 0; i < clusterconf.wlist.count; i++) {
|
||||
xce_worker_t* w = clusterconf.wlist.workers[i];
|
||||
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched),
|
||||
w->nresvals_to_sched);
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched), w->nresvals_to_sched);
|
||||
}
|
||||
|
||||
deref_objs(clusterconf.cfglist.count,
|
||||
(void**)clusterconf.cfglist.configs);
|
||||
deref_objs(clusterconf.qlist.count,
|
||||
(void**)clusterconf.qlist.queues);
|
||||
deref_objs(clusterconf.reslist.count,
|
||||
(void**)clusterconf.reslist.res);
|
||||
deref_objs(clusterconf.wlist.count,
|
||||
(void**)clusterconf.wlist.workers);
|
||||
deref_objs(clusterconf.cfglist.count, (void**)clusterconf.cfglist.configs);
|
||||
deref_objs(clusterconf.qlist.count, (void**)clusterconf.qlist.queues);
|
||||
deref_objs(clusterconf.reslist.count, (void**)clusterconf.reslist.res);
|
||||
deref_objs(clusterconf.wlist.count, (void**)clusterconf.wlist.workers);
|
||||
|
||||
FREEUP(clusterconf.cfglist.configs);
|
||||
FREEUP(clusterconf.qlist.queues);
|
||||
|
|
|
|||
|
|
@ -13,21 +13,15 @@
|
|||
extern void res_obj_killer(xce_resource_t*);
|
||||
extern void resval_obj_killer(xce_resval_t*);
|
||||
|
||||
int resmgr_init(resmgr_t* mgr,
|
||||
int nslots,
|
||||
int delta,
|
||||
int inst_delta)
|
||||
int resmgr_init(resmgr_t* mgr, int nslots, int delta, int inst_delta)
|
||||
{
|
||||
TRACE("%s nslots %d delta %d inst_delta %d",
|
||||
__func__, nslots, delta,
|
||||
TRACE("%s nslots %d delta %d inst_delta %d", __func__, nslots, delta,
|
||||
inst_delta);
|
||||
|
||||
mylock_init(&(mgr->lock));
|
||||
|
||||
ht_init(&(mgr->htab), nslots,
|
||||
string_hash_key);
|
||||
zarray_init(&(mgr->defs), delta,
|
||||
(zarray_item_killer_t)res_obj_killer);
|
||||
ht_init(&(mgr->htab), nslots, string_hash_key);
|
||||
zarray_init(&(mgr->defs), delta, (zarray_item_killer_t)res_obj_killer);
|
||||
zarray_init(&(mgr->sharedinst), inst_delta,
|
||||
(zarray_item_killer_t)resval_obj_killer);
|
||||
mgr->nshared = 0;
|
||||
|
|
@ -47,8 +41,7 @@ void resmgr_fini(resmgr_t* mgr)
|
|||
return;
|
||||
}
|
||||
|
||||
static int32_t resmgr_add_res_(resmgr_t* mgr,
|
||||
xce_resource_t* res)
|
||||
static int32_t resmgr_add_res_(resmgr_t* mgr, xce_resource_t* res)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -63,8 +56,7 @@ static int32_t resmgr_add_res_(resmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
e = ht_add(&(mgr->htab),
|
||||
(void*)res->name);
|
||||
e = ht_add(&(mgr->htab), (void*)res->name);
|
||||
if (e == NULL) {
|
||||
zarray_del(&(mgr->defs), idx);
|
||||
return -errno;
|
||||
|
|
@ -81,8 +73,7 @@ static int32_t resmgr_add_res_(resmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
int32_t resmgr_add_res(resmgr_t* mgr,
|
||||
xce_resource_t* res)
|
||||
int32_t resmgr_add_res(resmgr_t* mgr, xce_resource_t* res)
|
||||
{
|
||||
int32_t idx;
|
||||
|
||||
|
|
@ -97,9 +88,7 @@ int32_t resmgr_add_res(resmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
static xce_resource_t* resmgr_lockres_(resmgr_t* mgr,
|
||||
char* resname,
|
||||
int op)
|
||||
static xce_resource_t* resmgr_lockres_(resmgr_t* mgr, char* resname, int op)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -125,9 +114,7 @@ static xce_resource_t* resmgr_lockres_(resmgr_t* mgr,
|
|||
|
||||
return obj_ref(r, op);
|
||||
}
|
||||
xce_resource_t* resmgr_lockres(resmgr_t* mgr,
|
||||
char* resname,
|
||||
int op)
|
||||
xce_resource_t* resmgr_lockres(resmgr_t* mgr, char* resname, int op)
|
||||
{
|
||||
xce_resource_t* r = NULL;
|
||||
|
||||
|
|
@ -157,14 +144,12 @@ xce_resource_t* resmgr_lockres(resmgr_t* mgr,
|
|||
return r;
|
||||
}
|
||||
|
||||
static void resmgr_del_res_(resmgr_t* mgr,
|
||||
xce_resource_t* r)
|
||||
static void resmgr_del_res_(resmgr_t* mgr, xce_resource_t* r)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
||||
e = ht_get(&(mgr->htab),
|
||||
(void*)r->name);
|
||||
e = ht_get(&(mgr->htab), (void*)r->name);
|
||||
if (e == NULL) {
|
||||
SET_ERROR(E_XCE_BAD_RES);
|
||||
|
||||
|
|
@ -181,8 +166,7 @@ static void resmgr_del_res_(resmgr_t* mgr,
|
|||
zarray_del(&(mgr->defs), idx);
|
||||
}
|
||||
|
||||
void resmgr_del_res(resmgr_t* mgr,
|
||||
xce_resource_t* r)
|
||||
void resmgr_del_res(resmgr_t* mgr, xce_resource_t* r)
|
||||
{
|
||||
if ((mgr == NULL) || (r == NULL)) {
|
||||
SET_ERROR(EINVAL);
|
||||
|
|
@ -195,9 +179,7 @@ void resmgr_del_res(resmgr_t* mgr,
|
|||
mylock_unlock(&(mgr->lock));
|
||||
}
|
||||
|
||||
int resmgr_iter(resmgr_t* mgr,
|
||||
xlist_t* l,
|
||||
void* arg)
|
||||
int resmgr_iter(resmgr_t* mgr, xlist_t* l, void* arg)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,50 +9,44 @@
|
|||
#include "xce/cluster_def.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
extern void collect_shared_resvals(cluster_t*, collect_check_fn_t,
|
||||
int*, xce_val_with_idx_t***);
|
||||
extern void collect_shared_resvals(cluster_t*, collect_check_fn_t, int*,
|
||||
xce_val_with_idx_t***);
|
||||
|
||||
static int xcesched_push_joblist(cluster_t* c,
|
||||
xlist_t* l)
|
||||
static int xcesched_push_joblist(cluster_t* c, xlist_t* l)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_jobs_data_t jobs = {
|
||||
.n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.jobs = (xce_job_t**)l->data
|
||||
};
|
||||
int rc = 0;
|
||||
xce_jobs_data_t jobs = { .n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.jobs = (xce_job_t**)l->data };
|
||||
int rc = 0;
|
||||
|
||||
memset(&data, 0x0, sizeof(data));
|
||||
|
||||
data.table = Data_data_schedjobs;
|
||||
data.data.jobs = &jobs;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int xcesched_push_workerlist(cluster_t* c,
|
||||
xlist_t* l)
|
||||
static int xcesched_push_workerlist(cluster_t* c, xlist_t* l)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_workers_data_t workers = {
|
||||
.n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.workers = (xce_worker_t**)l->data
|
||||
};
|
||||
int rc = 0;
|
||||
xce_workers_data_t workers = { .n_total = l->count,
|
||||
.pos = 0,
|
||||
.count = l->count,
|
||||
.workers = (xce_worker_t**)l->data };
|
||||
int rc = 0;
|
||||
|
||||
memset(&data, 0x0, sizeof(data));
|
||||
|
||||
data.table = Data_data_schedworkers;
|
||||
data.data.workers = &workers;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +57,8 @@ static int xcesched_push_configs(cluster_t* c)
|
|||
|
||||
memset(&configdata, 0x0, sizeof(configdata));
|
||||
|
||||
configdata.data.conf4sched = (xce_conf4sched_t*)calloc(1, sizeof(xce_conf4sched_t));
|
||||
configdata.data.conf4sched
|
||||
= (xce_conf4sched_t*)calloc(1, sizeof(xce_conf4sched_t));
|
||||
if (configdata.data.conf4sched == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -83,11 +78,11 @@ static int xcesched_push_configs(cluster_t* c)
|
|||
configdata.data.conf4sched->hgroups = c->myconf->cluster_config->hgroups;
|
||||
|
||||
/* add resources */
|
||||
configdata.data_which = ConfigData_data_schedconfig;
|
||||
configdata.data.conf4sched->clustername = c->myconf->cluster_config->clustername;
|
||||
configdata.data_which = ConfigData_data_schedconfig;
|
||||
configdata.data.conf4sched->clustername
|
||||
= c->myconf->cluster_config->clustername;
|
||||
|
||||
rc = xce_pushconfig_req(c->sched.ep, c->myhost,
|
||||
&configdata);
|
||||
rc = xce_pushconfig_req(c->sched.ep, c->myhost, &configdata);
|
||||
|
||||
free_resval_with_idx_list(&(configdata.data.conf4sched->resvals),
|
||||
configdata.data.conf4sched->nresvals);
|
||||
|
|
@ -120,25 +115,20 @@ static int check_job_(xce_job_t* j)
|
|||
static int xcesched_push_jobs(cluster_t* c)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_jobs_data_t jobs = {
|
||||
.n_total = 0,
|
||||
.pos = 0,
|
||||
.count = 0,
|
||||
.jobs = NULL
|
||||
};
|
||||
int rc = 0;
|
||||
xce_jobs_data_t jobs = { .n_total = 0, .pos = 0, .count = 0, .jobs = NULL };
|
||||
int rc = 0;
|
||||
|
||||
memset(&data, 0x0, sizeof(data));
|
||||
|
||||
data.table = Data_data_schedjobs;
|
||||
data.data.jobs = &jobs;
|
||||
|
||||
collect_jobs(c, (collect_check_fn_t)check_job_,
|
||||
&(jobs.n_total), &(jobs.jobs));
|
||||
collect_jobs(c, (collect_check_fn_t)check_job_, &(jobs.n_total),
|
||||
&(jobs.jobs));
|
||||
jobs.count = jobs.n_total;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
deref_objs(jobs.n_total, (void**)jobs.jobs);
|
||||
FREEUP(jobs.jobs);
|
||||
|
||||
|
|
@ -148,12 +138,8 @@ static int xcesched_push_jobs(cluster_t* c)
|
|||
static int xcesched_push_workers(cluster_t* c)
|
||||
{
|
||||
xce_data_t data;
|
||||
xce_workers_data_t workers = {
|
||||
.n_total = 0,
|
||||
.pos = 0,
|
||||
.count = 0,
|
||||
.workers = NULL
|
||||
};
|
||||
xce_workers_data_t workers
|
||||
= { .n_total = 0, .pos = 0, .count = 0, .workers = NULL };
|
||||
int rc = 0;
|
||||
int i;
|
||||
|
||||
|
|
@ -162,12 +148,12 @@ static int xcesched_push_workers(cluster_t* c)
|
|||
data.table = Data_data_schedworkers;
|
||||
data.data.workers = &workers;
|
||||
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_,
|
||||
&(workers.n_total), &(workers.workers));
|
||||
collect_workers(c, (collect_check_fn_t)check_worker_, &(workers.n_total),
|
||||
&(workers.workers));
|
||||
workers.count = workers.n_total;
|
||||
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data,
|
||||
check_controller, c, 100);
|
||||
rc = xce_push_data_req(c->sched.ep, c->myhost, &data, check_controller, c,
|
||||
100);
|
||||
|
||||
/* free up collected resource value which used
|
||||
passed to scheduler
|
||||
|
|
@ -175,8 +161,7 @@ static int xcesched_push_workers(cluster_t* c)
|
|||
for (i = 0; i < workers.n_total; i++) {
|
||||
xce_worker_t* w = workers.workers[i];
|
||||
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched),
|
||||
w->nresvals_to_sched);
|
||||
free_resval_with_idx_list(&(w->resvals_to_sched), w->nresvals_to_sched);
|
||||
}
|
||||
|
||||
deref_objs(workers.n_total, (void**)workers.workers);
|
||||
|
|
@ -185,10 +170,7 @@ static int xcesched_push_workers(cluster_t* c)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_new_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_new_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
xlist_t* l = va_arg(ap, xlist_t*);
|
||||
|
|
@ -212,10 +194,7 @@ static int sched_job_new_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_start_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_start_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
job_pidinfo_t* info = va_arg(ap, job_pidinfo_t*);
|
||||
|
|
@ -245,10 +224,7 @@ static int sched_job_start_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_exit_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_exit_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
xce_jobfinish_t* info = va_arg(ap, xce_jobfinish_t*);
|
||||
|
|
@ -278,10 +254,7 @@ static int sched_job_exit_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_fail_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_fail_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
job_failinfo_t* info = va_arg(ap, job_failinfo_t*);
|
||||
|
|
@ -311,10 +284,7 @@ static int sched_job_fail_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_update_fun(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_job_update_fun(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
job_t* job = va_arg(ap, job_t*);
|
||||
|
|
@ -344,47 +314,34 @@ static int sched_job_update_fun(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_job_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
static int sched_job_hook_fun(int type, int situation, int detail, void* data,
|
||||
va_list ap)
|
||||
{
|
||||
switch (detail) {
|
||||
case HOOK_DETAIL_JOB_NEW:
|
||||
return sched_job_new_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_new_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_START:
|
||||
return sched_job_start_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_start_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_EXIT:
|
||||
return sched_job_exit_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_exit_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_UPDATE:
|
||||
return sched_job_update_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_update_fun(type, situation, data, ap);
|
||||
case HOOK_DETAIL_JOB_FAIL:
|
||||
return sched_job_fail_fun(type, situation,
|
||||
data, ap);
|
||||
return sched_job_fail_fun(type, situation, data, ap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int sched_worker_change(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
cluster_t* c,
|
||||
worker_t* w)
|
||||
static int sched_worker_change(int type, int situation, void* data,
|
||||
cluster_t* c, worker_t* w)
|
||||
{
|
||||
int rc = 0;
|
||||
xlist_t wlist;
|
||||
|
||||
TRACE("%s worker %s idx %d situation %d",
|
||||
__func__, w->host.name,
|
||||
w->idx, situation);
|
||||
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),
|
||||
collect_resval_with_idx(&(w->host.resvals), &(w->host.nresvals_to_sched),
|
||||
&(w->host.resvals_to_sched));
|
||||
|
||||
mylock_lock(&(c->sched.lock));
|
||||
|
|
@ -408,10 +365,7 @@ static int sched_worker_change(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_worker_join(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_join(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
char* name = va_arg(ap, char*);
|
||||
|
|
@ -423,11 +377,9 @@ static int sched_worker_join(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
w = workermgr_lock(&(c->workermgr), name,
|
||||
OBJREF_READ);
|
||||
w = workermgr_lock(&(c->workermgr), name, OBJREF_READ);
|
||||
|
||||
rc = sched_worker_change(type, situation, data,
|
||||
c, w);
|
||||
rc = sched_worker_change(type, situation, data, c, w);
|
||||
|
||||
/* FIXME: need to mark the jobs in this worker */
|
||||
obj_deref(w);
|
||||
|
|
@ -435,10 +387,7 @@ static int sched_worker_join(int type,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sched_worker_dead(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_dead(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
worker_t* w = va_arg(ap, worker_t*);
|
||||
|
|
@ -448,14 +397,10 @@ static int sched_worker_dead(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return sched_worker_change(type, situation, data,
|
||||
c, w);
|
||||
return sched_worker_change(type, situation, data, c, w);
|
||||
}
|
||||
|
||||
static int sched_worker_update(int type,
|
||||
int situation,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_update(int type, int situation, void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
worker_t* w = va_arg(ap, worker_t*);
|
||||
|
|
@ -464,44 +409,31 @@ static int sched_worker_update(int type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return sched_worker_change(type, situation, data,
|
||||
c, w);
|
||||
return sched_worker_change(type, situation, data, c, w);
|
||||
}
|
||||
static int sched_worker_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_worker_hook_fun(int type, int situation, int detail,
|
||||
void* data, va_list ap)
|
||||
{
|
||||
switch (detail) {
|
||||
case HOOK_DETAIL_WORKER_JOIN:
|
||||
return sched_worker_join(type, situation,
|
||||
data, ap);
|
||||
return sched_worker_join(type, situation, data, ap);
|
||||
case HOOK_DETAIL_WORKER_DEAD:
|
||||
return sched_worker_dead(type, situation,
|
||||
data, ap);
|
||||
return sched_worker_dead(type, situation, data, ap);
|
||||
case HOOK_DETAIL_WORKER_UPDATE:
|
||||
return sched_worker_update(type, situation,
|
||||
data, ap);
|
||||
return sched_worker_update(type, situation, data, ap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sched_resource_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
va_list ap)
|
||||
static int sched_resource_hook_fun(int type, int situation, int detail,
|
||||
void* data, va_list ap)
|
||||
{
|
||||
cluster_t* c = va_arg(ap, cluster_t*);
|
||||
xce_resval_list_t* resvals = va_arg(ap, xce_resval_list_t*);
|
||||
/* clang-format on */
|
||||
xce_notify_data_t xdata = {
|
||||
.event = NotifyData_data_schedUpdateResvals,
|
||||
.data = {
|
||||
.sched_update_resvals = resvals }
|
||||
};
|
||||
xce_notify_data_t xdata = { .event = NotifyData_data_schedUpdateResvals,
|
||||
.data = { .sched_update_resvals = resvals } };
|
||||
/* clang-format off */
|
||||
int rc = 0;
|
||||
|
||||
|
|
@ -557,10 +489,7 @@ static int sched_queue_update(int type,
|
|||
|
||||
return rc;
|
||||
}
|
||||
static int sched_queue_hook_fun(int type,
|
||||
int situation,
|
||||
int detail,
|
||||
void* data,
|
||||
static int sched_queue_hook_fun(int type, int situation, int detail, void* data,
|
||||
va_list ap)
|
||||
{
|
||||
switch (detail) {
|
||||
|
|
@ -588,22 +517,14 @@ int on_scheduler_join(cluster_t* c)
|
|||
if (!hook_installed) {
|
||||
hook_installed = 1;
|
||||
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_JOB,
|
||||
(hook_fn_t)sched_job_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
(hook_fn_t)sched_worker_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
(hook_fn_t)sched_resource_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_QUEUE,
|
||||
(hook_fn_t)sched_queue_hook_fun,
|
||||
NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_JOB,
|
||||
(hook_fn_t)sched_job_hook_fun, NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER,
|
||||
(hook_fn_t)sched_worker_hook_fun, NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_RESOURCE,
|
||||
(hook_fn_t)sched_resource_hook_fun, NULL);
|
||||
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_QUEUE,
|
||||
(hook_fn_t)sched_queue_hook_fun, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -611,8 +532,7 @@ int on_scheduler_join(cluster_t* c)
|
|||
int handle_scheduler_leave(cluster_t* c)
|
||||
{
|
||||
/* we need to mark the cluster status */
|
||||
TRACE("%s scheduler leave",
|
||||
__func__);
|
||||
TRACE("%s scheduler leave", __func__);
|
||||
mylock_lock(&(c->sched.lock));
|
||||
c->sched.ep = NULL;
|
||||
mylock_unlock(&(c->sched.lock));
|
||||
|
|
|
|||
|
|
@ -7,20 +7,16 @@
|
|||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
static int run_tasks_on_host(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
uint64_t jobid,
|
||||
static int run_tasks_on_host(cluster_t* c, endpoint_t* ep, uint64_t jobid,
|
||||
xce_taskhost_t* info)
|
||||
{
|
||||
worker_t* w;
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
xce_taskrun_t runmsg = {
|
||||
.nhosts = 1,
|
||||
.jobid = jobid,
|
||||
.clientidx = ep->idx,
|
||||
.taskhosts = (xce_taskhost_t*[]) { info }
|
||||
};
|
||||
xce_taskrun_t runmsg = { .nhosts = 1,
|
||||
.jobid = jobid,
|
||||
.clientidx = ep->idx,
|
||||
.taskhosts = (xce_taskhost_t*[]) { info } };
|
||||
|
||||
w = workermgr_lock(&(c->workermgr), info->host, OBJREF_READ);
|
||||
if (w == NULL) {
|
||||
|
|
@ -45,16 +41,14 @@ static int run_tasks_on_host(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int check_task_hosts(cluster_t* c,
|
||||
xce_taskrun_t* runmsg)
|
||||
static int check_task_hosts(cluster_t* c, xce_taskrun_t* runmsg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < runmsg->nhosts; i++) {
|
||||
worker_t* w;
|
||||
|
||||
w = workermgr_lock(&(c->workermgr),
|
||||
runmsg->taskhosts[i]->host,
|
||||
w = workermgr_lock(&(c->workermgr), runmsg->taskhosts[i]->host,
|
||||
OBJREF_READ);
|
||||
if (w == NULL) {
|
||||
return -ENOENT;
|
||||
|
|
@ -69,9 +63,7 @@ static int check_task_hosts(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int do_runtasks(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* req)
|
||||
int do_runtasks(cluster_t* c, endpoint_t* ep, xce_request_t* req)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
|
@ -94,22 +86,16 @@ int do_runtasks(cluster_t* c,
|
|||
for (i = 0; i < runmsg->nhosts; i++) {
|
||||
int rc1;
|
||||
|
||||
rc1 = run_tasks_on_host(c, ep,
|
||||
runmsg->jobid,
|
||||
runmsg->taskhosts[i]);
|
||||
rc1 = run_tasks_on_host(c, ep, runmsg->jobid, runmsg->taskhosts[i]);
|
||||
if (rc1 < 0) {
|
||||
xce_task_failinfo_t failinfo = {
|
||||
.jobid = runmsg->jobid,
|
||||
.host = runmsg->taskhosts[i]->host,
|
||||
.taskidx = -1, /* all tasks failed */
|
||||
.code = rc1,
|
||||
.detail = NULL
|
||||
};
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskFailInfo,
|
||||
.data = {
|
||||
.taskfailinfo = &failinfo }
|
||||
};
|
||||
xce_task_failinfo_t failinfo
|
||||
= { .jobid = runmsg->jobid,
|
||||
.host = runmsg->taskhosts[i]->host,
|
||||
.taskidx = -1, /* all tasks failed */
|
||||
.code = rc1,
|
||||
.detail = NULL };
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskFailInfo,
|
||||
.data = { .taskfailinfo = &failinfo } };
|
||||
|
||||
/* notify client that run tasks on host fail */
|
||||
notify(c, ep, &data);
|
||||
|
|
@ -121,16 +107,12 @@ int do_runtasks(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int on_task_start(cluster_t* c,
|
||||
xce_task_pidinfo_t* info)
|
||||
int on_task_start(cluster_t* c, xce_task_pidinfo_t* info)
|
||||
{
|
||||
endpoint_t* ep;
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskPidInfo,
|
||||
.data = {
|
||||
.taskinfo = info }
|
||||
};
|
||||
int clientidx = info->clientidx;
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskPidInfo,
|
||||
.data = { .taskinfo = info } };
|
||||
int clientidx = info->clientidx;
|
||||
|
||||
if (clientidx < 0) {
|
||||
ERROR("incorrect client idx %d", clientidx);
|
||||
|
|
@ -148,16 +130,12 @@ int on_task_start(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_task_fail(cluster_t* c,
|
||||
xce_task_failinfo_t* info)
|
||||
int on_task_fail(cluster_t* c, xce_task_failinfo_t* info)
|
||||
{
|
||||
endpoint_t* ep;
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskFailInfo,
|
||||
.data = {
|
||||
.taskfailinfo = info }
|
||||
};
|
||||
int clientidx = info->clientidx;
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskFailInfo,
|
||||
.data = { .taskfailinfo = info } };
|
||||
int clientidx = info->clientidx;
|
||||
|
||||
if (clientidx < 0) {
|
||||
ERROR("incorrect client idx %d", clientidx);
|
||||
|
|
@ -175,16 +153,12 @@ int on_task_fail(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_task_finish(cluster_t* c,
|
||||
xce_task_finish_t* info)
|
||||
int on_task_finish(cluster_t* c, xce_task_finish_t* info)
|
||||
{
|
||||
endpoint_t* ep;
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskFinish,
|
||||
.data = {
|
||||
.taskfinish = info }
|
||||
};
|
||||
int clientidx = info->clientidx;
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskFinish,
|
||||
.data = { .taskfinish = info } };
|
||||
int clientidx = info->clientidx;
|
||||
|
||||
if (clientidx < 0) {
|
||||
ERROR("incorrect client idx %d", clientidx);
|
||||
|
|
|
|||
|
|
@ -117,12 +117,10 @@ static command_t top_commands[] = {
|
|||
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
|
||||
};
|
||||
|
||||
static command_ctx_t topctx = {
|
||||
.parent = NULL,
|
||||
.prompt = "xce",
|
||||
.settings = settings,
|
||||
.commands = top_commands
|
||||
};
|
||||
static command_ctx_t topctx = { .parent = NULL,
|
||||
.prompt = "xce",
|
||||
.settings = settings,
|
||||
.commands = top_commands };
|
||||
|
||||
static command_t worker_commands[] = {
|
||||
{ "..", cmd_up, "Goto upper context" },
|
||||
|
|
@ -134,12 +132,10 @@ static command_t worker_commands[] = {
|
|||
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
|
||||
};
|
||||
|
||||
static command_ctx_t workerctx = {
|
||||
.parent = &topctx,
|
||||
.prompt = "worker",
|
||||
.settings = settings,
|
||||
.commands = worker_commands
|
||||
};
|
||||
static command_ctx_t workerctx = { .parent = &topctx,
|
||||
.prompt = "worker",
|
||||
.settings = settings,
|
||||
.commands = worker_commands };
|
||||
|
||||
static command_t client_commands[] = {
|
||||
{ "..", cmd_up, "Goto upper context" },
|
||||
|
|
@ -160,12 +156,10 @@ static command_t client_commands[] = {
|
|||
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
|
||||
};
|
||||
|
||||
static command_ctx_t clientctx = {
|
||||
.parent = &topctx,
|
||||
.prompt = "client",
|
||||
.settings = settings,
|
||||
.commands = client_commands
|
||||
};
|
||||
static command_ctx_t clientctx = { .parent = &topctx,
|
||||
.prompt = "client",
|
||||
.settings = settings,
|
||||
.commands = client_commands };
|
||||
|
||||
static command_t scheduler_commands[] = {
|
||||
{ "..", cmd_up, "Goto upper context" },
|
||||
|
|
@ -176,12 +170,10 @@ static command_t scheduler_commands[] = {
|
|||
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
|
||||
};
|
||||
|
||||
static command_ctx_t schedulerctx = {
|
||||
.parent = &topctx,
|
||||
.prompt = "scheduler",
|
||||
.settings = settings,
|
||||
.commands = scheduler_commands
|
||||
};
|
||||
static command_ctx_t schedulerctx = { .parent = &topctx,
|
||||
.prompt = "scheduler",
|
||||
.settings = settings,
|
||||
.commands = scheduler_commands };
|
||||
|
||||
static command_ctx_t* active_ctx = &topctx;
|
||||
|
||||
|
|
@ -191,7 +183,8 @@ static int break_out = 0;
|
|||
static char doc[] = "xce_test";
|
||||
static char args_doc[] = "";
|
||||
|
||||
const char* argp_program_version = MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID));
|
||||
const char* argp_program_version
|
||||
= MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID));
|
||||
const char* argp_program_bug_address = BUG_EMAIL;
|
||||
|
||||
struct arguments {
|
||||
|
|
@ -203,9 +196,7 @@ static struct argp_option options[] = {
|
|||
{ 0 }
|
||||
};
|
||||
|
||||
static error_t parse_opt(int key,
|
||||
char* arg,
|
||||
struct argp_state* state)
|
||||
static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
||||
{
|
||||
struct arguments* arguments = state->input;
|
||||
|
||||
|
|
@ -220,12 +211,7 @@ static error_t parse_opt(int key,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct argp argp = {
|
||||
options,
|
||||
parse_opt,
|
||||
args_doc,
|
||||
doc
|
||||
};
|
||||
static struct argp argp = { options, parse_opt, args_doc, doc };
|
||||
|
||||
static char* verbose_to_loglevel(int verbose)
|
||||
{
|
||||
|
|
@ -251,10 +237,7 @@ static char* verbose_to_loglevel(int verbose)
|
|||
return loglevel;
|
||||
}
|
||||
|
||||
void sigbreak(int signo)
|
||||
{
|
||||
break_out = 1;
|
||||
}
|
||||
void sigbreak(int signo) { break_out = 1; }
|
||||
|
||||
static char* get_setting(char* key)
|
||||
{
|
||||
|
|
@ -272,8 +255,7 @@ static char* get_setting(char* key)
|
|||
return active_ctx->settings[i].defval;
|
||||
}
|
||||
|
||||
printf("Key `%s' is not in settings\n",
|
||||
key);
|
||||
printf("Key `%s' is not in settings\n", key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -312,8 +294,7 @@ int leave_ctx(command_ctx_t* ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int fill_prompt(command_ctx_t* ctx,
|
||||
char* buf)
|
||||
static int fill_prompt(command_ctx_t* ctx, char* buf)
|
||||
{
|
||||
if (ctx->parent != NULL) {
|
||||
fill_prompt(ctx->parent, buf);
|
||||
|
|
@ -360,8 +341,7 @@ int execute_line(char* line)
|
|||
command = find_command(argv[0]);
|
||||
|
||||
if (!command) {
|
||||
fprintf(stderr, "%s: No such command for xce test.\n",
|
||||
argv[0]);
|
||||
fprintf(stderr, "%s: No such command for xce test.\n", argv[0]);
|
||||
free_argv(argv, argc);
|
||||
return (-1);
|
||||
}
|
||||
|
|
@ -382,8 +362,7 @@ int cmd_help(int argc, char* argv[])
|
|||
|
||||
for (i = 0; active_ctx->commands[i].name != NULL; i++) {
|
||||
if (strcmp(argv[1], active_ctx->commands[i].name) == 0) {
|
||||
printf("%s\t\t%s.\n",
|
||||
active_ctx->commands[i].name,
|
||||
printf("%s\t\t%s.\n", active_ctx->commands[i].name,
|
||||
active_ctx->commands[i].doc);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -394,8 +373,7 @@ int cmd_help(int argc, char* argv[])
|
|||
}
|
||||
|
||||
for (i = 0; active_ctx->commands[i].name != NULL; i++) {
|
||||
printf("\t%-12s\t%s\n",
|
||||
active_ctx->commands[i].name,
|
||||
printf("\t%-12s\t%s\n", active_ctx->commands[i].name,
|
||||
active_ctx->commands[i].doc);
|
||||
}
|
||||
|
||||
|
|
@ -485,7 +463,7 @@ int cmd_quit(int argc, char* argv[])
|
|||
|
||||
int cmd_hello(int argc, char* argv[])
|
||||
{
|
||||
int rc;
|
||||
int rc = 0;
|
||||
int opt;
|
||||
char* msg = "Greeting from xce client";
|
||||
int count = 1;
|
||||
|
|
@ -542,15 +520,11 @@ int cmd_reslist(int argc, char* argv[])
|
|||
return rc;
|
||||
}
|
||||
|
||||
printf("%10s%10s%10s%64s\n",
|
||||
"Name", "Flags",
|
||||
"Interval", "Description");
|
||||
printf("%10s%10s%10s%64s\n", "Name", "Flags", "Interval", "Description");
|
||||
|
||||
for (i = 0; i < rc; i++) {
|
||||
printf("%10s%10x%10d%64s\n",
|
||||
res[i]->name,
|
||||
res[i]->flags, res[i]->interval,
|
||||
res[i]->desc);
|
||||
printf("%10s%10x%10d%64s\n", res[i]->name, res[i]->flags,
|
||||
res[i]->interval, res[i]->desc);
|
||||
}
|
||||
|
||||
free(res);
|
||||
|
|
@ -588,23 +562,17 @@ int cmd_workerlist(int argc, char* argv[])
|
|||
return rc;
|
||||
}
|
||||
|
||||
printf("%-20s%-8s%-15s%-15s%12s%12s%12s%12s%12s%12s\n",
|
||||
"HostName", "Status", "HostType", "HostModel",
|
||||
"CPUfactor", "MaxCPU", "MaxMem",
|
||||
printf("%-20s%-8s%-15s%-15s%12s%12s%12s%12s%12s%12s\n", "HostName",
|
||||
"Status", "HostType", "HostModel", "CPUfactor", "MaxCPU", "MaxMem",
|
||||
"MaxSwap", "MaxTmp", "NDisks");
|
||||
|
||||
for (i = 0; i < rc; i++) {
|
||||
printf("%-20s%-8s%-15s%-15s%12f%12d%12f%12f%12f%12d\n",
|
||||
workers[i]->name,
|
||||
worker_status_str(workers[i]->status),
|
||||
workers[i]->attrs->hosttype,
|
||||
workers[i]->attrs->hostmodel,
|
||||
workers[i]->attrs->cpufactor,
|
||||
workers[i]->attrs->maxcpus,
|
||||
workers[i]->attrs->maxmem,
|
||||
workers[i]->attrs->maxswap,
|
||||
workers[i]->attrs->maxtmp,
|
||||
workers[i]->attrs->ndisks);
|
||||
workers[i]->name, worker_status_str(workers[i]->status),
|
||||
workers[i]->attrs->hosttype, workers[i]->attrs->hostmodel,
|
||||
workers[i]->attrs->cpufactor, workers[i]->attrs->maxcpus,
|
||||
workers[i]->attrs->maxmem, workers[i]->attrs->maxswap,
|
||||
workers[i]->attrs->maxtmp, workers[i]->attrs->ndisks);
|
||||
}
|
||||
|
||||
free(workers);
|
||||
|
|
@ -651,23 +619,16 @@ int cmd_joblist(int argc, char* argv[])
|
|||
return rc;
|
||||
}
|
||||
|
||||
printf("%-16s%-10s%-10s%-8s%-16s%-16s%-16s%10s%30s\n",
|
||||
"JobId", "User", "Queue", "State",
|
||||
"SubmitTime", "StartTime", "FinishTime",
|
||||
"NTasks", "Command");
|
||||
printf("%-16s%-10s%-10s%-8s%-16s%-16s%-16s%10s%30s\n", "JobId", "User",
|
||||
"Queue", "State", "SubmitTime", "StartTime", "FinishTime", "NTasks",
|
||||
"Command");
|
||||
|
||||
for (i = 0; i < rc; i++) {
|
||||
printf("%-16ld%-10s%-10s%-8s%-16ld%-16ld%-16ld%4d,%-5d%30s\n",
|
||||
jobs[i]->jobid,
|
||||
jobs[i]->user,
|
||||
jobs[i]->queue,
|
||||
job_state_str(jobs[i]->state),
|
||||
jobs[i]->queue_time,
|
||||
jobs[i]->start_time,
|
||||
jobs[i]->finish_time,
|
||||
jobs[i]->mintasks,
|
||||
jobs[i]->maxtasks,
|
||||
jobs[i]->start_info->cmdline);
|
||||
jobs[i]->jobid, jobs[i]->user, jobs[i]->queue,
|
||||
job_state_str(jobs[i]->state), jobs[i]->queue_time,
|
||||
jobs[i]->start_time, jobs[i]->finish_time, jobs[i]->mintasks,
|
||||
jobs[i]->maxtasks, jobs[i]->start_info->cmdline);
|
||||
}
|
||||
|
||||
free(jobs);
|
||||
|
|
@ -675,9 +636,8 @@ int cmd_joblist(int argc, char* argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int fill_job_alloc(xce_job_alloc_t* jalloc,
|
||||
int nhosts,
|
||||
host_task_t* hosts)
|
||||
static int fill_job_alloc(xce_job_alloc_t* jalloc, int nhosts,
|
||||
host_task_t* hosts)
|
||||
{
|
||||
xce_host_alloc_t** halloc = NULL;
|
||||
int i;
|
||||
|
|
@ -722,13 +682,11 @@ int cmd_jobrun(int argc, char* argv[])
|
|||
{
|
||||
int rc;
|
||||
int opt;
|
||||
uint64_t jobid;
|
||||
uint64_t jobid = 0;
|
||||
host_task_t hosts[MAX_TASK_HOSTS];
|
||||
xce_job_alloc_t jalloc;
|
||||
xce_job_dispatch_t jdispatch = {
|
||||
.njobs = 1,
|
||||
.allocs = (xce_job_alloc_t*[]) { &jalloc }
|
||||
};
|
||||
xce_job_dispatch_t jdispatch
|
||||
= { .njobs = 1, .allocs = (xce_job_alloc_t*[]) { &jalloc } };
|
||||
int nhosts = 0;
|
||||
char* host;
|
||||
int count;
|
||||
|
|
@ -739,7 +697,8 @@ int cmd_jobrun(int argc, char* argv[])
|
|||
switch (opt) {
|
||||
case 'm':
|
||||
if (nhosts >= MAX_TASK_HOSTS) {
|
||||
fprintf(stderr, "too many run hosts, we only support max %d hosts\n",
|
||||
fprintf(stderr,
|
||||
"too many run hosts, we only support max %d hosts\n",
|
||||
MAX_TASK_HOSTS);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -765,10 +724,19 @@ int cmd_jobrun(int argc, char* argv[])
|
|||
break;
|
||||
case 'j':
|
||||
jobid = atol(optarg);
|
||||
if (jobid == 0) {
|
||||
printf("you need to specify a positive jobid with -j");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (jobid == 0) {
|
||||
printf("no jobid specified");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fill_job_alloc(&jalloc, nhosts, &hosts[0]);
|
||||
|
||||
jalloc.jobid = jobid;
|
||||
|
|
@ -828,7 +796,8 @@ int cmd_jobsub(int argc, char* argv[])
|
|||
min = atoi(buf);
|
||||
|
||||
if (max == 0) {
|
||||
printf("Incorrect setting of max tasks count, set to same as min task value\n");
|
||||
printf("Incorrect setting of max tasks count, set to same "
|
||||
"as min task value\n");
|
||||
max = min;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -837,7 +806,8 @@ int cmd_jobsub(int argc, char* argv[])
|
|||
}
|
||||
break;
|
||||
default:
|
||||
printf("jobsub -u <user> -q <queue> -R <resreq> -c <command line>\n");
|
||||
printf(
|
||||
"jobsub -u <user> -q <queue> -R <resreq> -c <command line>\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -913,16 +883,15 @@ int cmd_resval(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
rc = xcecli_resval(active_ctx->ctx, host,
|
||||
res, &vals);
|
||||
rc = xcecli_resval(active_ctx->ctx, host, res, &vals);
|
||||
if (rc > 0) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < rc; i++) {
|
||||
xce_resval_t* val = vals[i];
|
||||
|
||||
printf("resource %s@%s:\n",
|
||||
val->name, (val->host == NULL) ? "cluster" : val->host);
|
||||
printf("resource %s@%s:\n", val->name,
|
||||
(val->host == NULL) ? "cluster" : val->host);
|
||||
printf("value: ");
|
||||
switch (val->val->which) {
|
||||
case Value_u_svalue:
|
||||
|
|
@ -932,8 +901,7 @@ int cmd_resval(int argc, char* argv[])
|
|||
printf("%f\n", val->val->u.fvalue);
|
||||
break;
|
||||
case Value_u_bvalue:
|
||||
printf("%s\n",
|
||||
(val->val->u.bvalue == 0) ? "false" : "true");
|
||||
printf("%s\n", (val->val->u.bvalue == 0) ? "false" : "true");
|
||||
break;
|
||||
default:
|
||||
printf(" <unknown type>\n");
|
||||
|
|
@ -1107,7 +1075,7 @@ int cmd_qctrl(int argc, char* argv[])
|
|||
int cmd_runtasks(int argc, char* argv[])
|
||||
{
|
||||
xce_taskhost_t hosts[MAX_TASK_HOSTS];
|
||||
int nhosts = 0;
|
||||
size_t nhosts = 0;
|
||||
xce_taskrun_t taskrun;
|
||||
int opt;
|
||||
int rc;
|
||||
|
|
@ -1128,7 +1096,8 @@ int cmd_runtasks(int argc, char* argv[])
|
|||
switch (opt) {
|
||||
case 'm':
|
||||
if (nhosts >= MAX_TASK_HOSTS) {
|
||||
fprintf(stderr, "too many run hosts, just support %d run hosts\n",
|
||||
fprintf(stderr,
|
||||
"too many run hosts, just support %d run hosts\n",
|
||||
MAX_TASK_HOSTS);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1203,7 +1172,8 @@ int cmd_runtasks(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
taskrun.taskhosts = (xce_taskhost_t**)calloc(nhosts, sizeof(xce_taskhost_t*));
|
||||
taskrun.taskhosts
|
||||
= (xce_taskhost_t**)calloc(nhosts, sizeof(xce_taskhost_t*));
|
||||
taskrun.clientidx = -1;
|
||||
|
||||
if (taskrun.taskhosts != NULL) {
|
||||
|
|
@ -1233,14 +1203,12 @@ int cmd_join_worker(int argc, char* argv[])
|
|||
int rc;
|
||||
int role;
|
||||
int opt;
|
||||
hostattrs_t attrs = {
|
||||
.cpufactor = 1.0,
|
||||
.maxcpus = 4,
|
||||
.maxmem = 64,
|
||||
.maxswap = 1024,
|
||||
.maxtmp = 2048,
|
||||
.ndisks = 1
|
||||
};
|
||||
hostattrs_t attrs = { .cpufactor = 1.0,
|
||||
.maxcpus = 4,
|
||||
.maxmem = 64,
|
||||
.maxswap = 1024,
|
||||
.maxtmp = 2048,
|
||||
.ndisks = 1 };
|
||||
|
||||
role = HostRole_worker;
|
||||
|
||||
|
|
@ -1270,7 +1238,8 @@ int cmd_join_worker(int argc, char* argv[])
|
|||
attrs.ndisks = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
printf(" join [-f cpufactor] [-c maxcpus] [-m maxmem] [-s maxswap] [-t maxtmp] [-d ndisks]\n");
|
||||
printf(" join [-f cpufactor] [-c maxcpus] [-m maxmem] [-s maxswap] "
|
||||
"[-t maxtmp] [-d ndisks]\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -1330,10 +1299,7 @@ int cmd_jobfinish(int argc, char* argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_resval(xce_resval_t* vals,
|
||||
int idx,
|
||||
char* name,
|
||||
char* val)
|
||||
static int set_resval(xce_resval_t* vals, int idx, char* name, char* val)
|
||||
{
|
||||
static struct {
|
||||
char* name;
|
||||
|
|
@ -1433,10 +1399,10 @@ int cmd_resupdate(int argc, char* argv[])
|
|||
switch (opt) {
|
||||
case 'n':
|
||||
if (resname != NULL) {
|
||||
printf("res `%s' has no value specified, default will be used\n",
|
||||
resname);
|
||||
rc = set_resval(vals, nres,
|
||||
resname, NULL);
|
||||
printf(
|
||||
"res `%s' has no value specified, default will be used\n",
|
||||
resname);
|
||||
rc = set_resval(vals, nres, resname, NULL);
|
||||
if (rc >= 0) {
|
||||
valptrs[nres] = &vals[nres];
|
||||
nres++;
|
||||
|
|
@ -1448,23 +1414,20 @@ int cmd_resupdate(int argc, char* argv[])
|
|||
break;
|
||||
case 'v':
|
||||
if (resname != NULL) {
|
||||
rc = set_resval(vals, nres,
|
||||
resname, optarg);
|
||||
rc = set_resval(vals, nres, resname, optarg);
|
||||
if (rc >= 0) {
|
||||
valptrs[nres] = &vals[nres];
|
||||
nres++;
|
||||
}
|
||||
resname = NULL;
|
||||
} else {
|
||||
printf("ignore res value `%s' as no res name found\n",
|
||||
optarg);
|
||||
printf("ignore res value `%s' as no res name found\n", optarg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rc = xcecli_update_resvals(active_ctx->ctx,
|
||||
nres, &valptrs[0]);
|
||||
rc = xcecli_update_resvals(active_ctx->ctx, nres, &valptrs[0]);
|
||||
if (rc >= 0) {
|
||||
printf("resource update ok!\n");
|
||||
} else {
|
||||
|
|
@ -1496,10 +1459,8 @@ static int print_reslist(xce_reslist_t reslist)
|
|||
|
||||
for (i = 0; i < reslist.count; i++) {
|
||||
printf("name: %s\nflags: %d\ninterval: %d\ndesc: %s\n\n",
|
||||
reslist.res[i]->name,
|
||||
reslist.res[i]->flags,
|
||||
reslist.res[i]->interval,
|
||||
reslist.res[i]->desc);
|
||||
reslist.res[i]->name, reslist.res[i]->flags,
|
||||
reslist.res[i]->interval, reslist.res[i]->desc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1509,10 +1470,8 @@ static int print_queuelist(xce_queuelist_t qlist)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < qlist.count; i++) {
|
||||
printf("name: %s\nstatus: %d\npriority: %d\n\n",
|
||||
qlist.queues[i]->queue,
|
||||
qlist.queues[i]->status,
|
||||
qlist.queues[i]->priority);
|
||||
printf("name: %s\nstatus: %d\npriority: %d\n\n", qlist.queues[i]->queue,
|
||||
qlist.queues[i]->status, qlist.queues[i]->priority);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1522,22 +1481,15 @@ static int print_workerlist(xce_workerlist_t wlist)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < wlist.count; i++) {
|
||||
printf("name: %s\nstatus: %d\n\n",
|
||||
wlist.workers[i]->name,
|
||||
printf("name: %s\nstatus: %d\n\n", wlist.workers[i]->name,
|
||||
wlist.workers[i]->status);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_grouplist(xce_grouplist_t glist)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int print_grouplist(xce_grouplist_t glist) { return 0; }
|
||||
|
||||
static int print_configlist(xce_configlist_t clist)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int print_configlist(xce_configlist_t clist) { return 0; }
|
||||
|
||||
int cmd_getconf(int argc, char* argv[])
|
||||
{
|
||||
|
|
@ -1583,8 +1535,7 @@ int cmd_set(int argc, char* argv[])
|
|||
|
||||
if (argc == 1) {
|
||||
for (i = 0; active_ctx->settings[i].key; i++) {
|
||||
printf("%-12s:%s default: %s\n",
|
||||
active_ctx->settings[i].key,
|
||||
printf("%-12s:%s default: %s\n", active_ctx->settings[i].key,
|
||||
KVAL(active_ctx->settings[i].value),
|
||||
KVAL(active_ctx->settings[i].defval));
|
||||
}
|
||||
|
|
@ -1664,26 +1615,21 @@ static int get_avail_run_task_slots()
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int sched_on_jobs(int njobs,
|
||||
xce_job_t** jobs)
|
||||
static int sched_on_jobs(int njobs, xce_job_t** jobs)
|
||||
{
|
||||
printf("%s %d jobs gotten\n",
|
||||
__func__, njobs);
|
||||
printf("%s %d jobs gotten\n", __func__, njobs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sched_on_workers(int nworkers,
|
||||
xce_worker_t** workers)
|
||||
static int sched_on_workers(int nworkers, xce_worker_t** workers)
|
||||
{
|
||||
printf("%s %d workers gotten\n",
|
||||
__func__, nworkers);
|
||||
printf("%s %d workers gotten\n", __func__, nworkers);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void notify_job_fail(uint64_t jobid,
|
||||
int code)
|
||||
static void notify_job_fail(uint64_t jobid, int code)
|
||||
{
|
||||
/* clang-format off */
|
||||
job_failinfo_t failinfo = {
|
||||
|
|
@ -1733,32 +1679,27 @@ static void notify_jobstart(uint64_t jobid,
|
|||
return;
|
||||
}
|
||||
|
||||
static void notify_task_start(uint64_t jobid,
|
||||
int clientidx,
|
||||
int taskidx,
|
||||
int pid,
|
||||
int pgid)
|
||||
static void notify_task_start(uint64_t jobid, int clientidx, int taskidx,
|
||||
int pid, int pgid)
|
||||
{
|
||||
xce_task_pidinfo_t pidinfo = {
|
||||
.jobid = jobid,
|
||||
.host = get_setting("myname"),
|
||||
.clientidx = clientidx,
|
||||
.taskidx = taskidx,
|
||||
.npids = 1,
|
||||
.pids = (unsigned int[]) { (unsigned int)pid },
|
||||
.npgids = 1,
|
||||
.pgids = (unsigned int[]) { (unsigned int)pgid },
|
||||
.exdata = NULL
|
||||
};
|
||||
xce_task_pidinfo_t pidinfo
|
||||
= { .jobid = jobid,
|
||||
.host = get_setting("myname"),
|
||||
.clientidx = clientidx,
|
||||
.taskidx = taskidx,
|
||||
.npids = 1,
|
||||
.pids = (unsigned int[]) { (unsigned int)pid },
|
||||
.npgids = 1,
|
||||
.pgids = (unsigned int[]) { (unsigned int)pgid },
|
||||
.exdata = NULL };
|
||||
|
||||
xcecli_notify_taskstart(active_ctx->ctx, &pidinfo);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int run_task_remote(uint64_t jobid,
|
||||
job_startinfo_t* startinfo,
|
||||
xce_launch_t* launchinfo)
|
||||
static int run_task_remote(uint64_t jobid, job_startinfo_t* startinfo,
|
||||
xce_launch_t* launchinfo)
|
||||
{
|
||||
xce_taskhost_t hosts[launchinfo->nhosts - 1];
|
||||
xce_taskrun_t taskrun;
|
||||
|
|
@ -1805,9 +1746,8 @@ static int run_task_remote(uint64_t jobid,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int run_task_local(uint64_t jobid,
|
||||
job_startinfo_t* startinfo,
|
||||
int ntasks)
|
||||
static int run_task_local(uint64_t jobid, job_startinfo_t* startinfo,
|
||||
int ntasks)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
|
|
@ -1869,8 +1809,7 @@ static int run_task_local(uint64_t jobid,
|
|||
exit(rc);
|
||||
}
|
||||
|
||||
printf("Job %lu started, PID: %d\n",
|
||||
jobid, pid);
|
||||
printf("Job %lu started, PID: %d\n", jobid, pid);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
|
@ -1899,9 +1838,11 @@ int run_job(xce_job_exec_t* startmsg)
|
|||
printf("%s: q_post_exec= %s\n", __func__,
|
||||
(startinfo->q_post_exec == NULL) ? "NULL" : startinfo->q_post_exec);
|
||||
printf("%s: job_pre_exec= %s\n", __func__,
|
||||
(startinfo->job_pre_exec == NULL) ? "NULL" : startinfo->job_pre_exec);
|
||||
(startinfo->job_pre_exec == NULL) ? "NULL"
|
||||
: startinfo->job_pre_exec);
|
||||
printf("%s: job_post_exec= %s\n", __func__,
|
||||
(startinfo->job_post_exec == NULL) ? "NULL" : startinfo->job_post_exec);
|
||||
(startinfo->job_post_exec == NULL) ? "NULL"
|
||||
: startinfo->job_post_exec);
|
||||
|
||||
if (launchinfo->nhosts > 1) {
|
||||
rc = run_task_remote(jobid, startinfo, launchinfo);
|
||||
|
|
@ -1911,8 +1852,7 @@ int run_job(xce_job_exec_t* startmsg)
|
|||
}
|
||||
}
|
||||
|
||||
rc = run_task_local(jobid, startinfo,
|
||||
launchinfo->hosts[0]->nranks);
|
||||
rc = run_task_local(jobid, startinfo, launchinfo->hosts[0]->nranks);
|
||||
if (rc < 0) {
|
||||
notify_job_fail(jobid, rc);
|
||||
} else {
|
||||
|
|
@ -1947,22 +1887,17 @@ static int handle_notify(xce_request_t* request)
|
|||
switch (data->event) {
|
||||
case NotifyData_data_taskPidInfo:
|
||||
printf("job %lu host %s taskidx %d pid %d\n",
|
||||
data->data.taskinfo->jobid,
|
||||
data->data.taskinfo->host,
|
||||
data->data.taskinfo->taskidx,
|
||||
data->data.taskinfo->pids[0]);
|
||||
data->data.taskinfo->jobid, data->data.taskinfo->host,
|
||||
data->data.taskinfo->taskidx, data->data.taskinfo->pids[0]);
|
||||
break;
|
||||
case NotifyData_data_taskFailInfo:
|
||||
printf("job %lu host %s task %d error code %d\n",
|
||||
data->data.taskfailinfo->jobid,
|
||||
data->data.taskfailinfo->host,
|
||||
data->data.taskfailinfo->taskidx,
|
||||
data->data.taskfailinfo->code);
|
||||
data->data.taskfailinfo->jobid, data->data.taskfailinfo->host,
|
||||
data->data.taskfailinfo->taskidx, data->data.taskfailinfo->code);
|
||||
break;
|
||||
case NotifyData_data_taskFinish:
|
||||
printf("job %lu host %s task %d exit code %d\n",
|
||||
data->data.taskfinish->jobid,
|
||||
data->data.taskfinish->host,
|
||||
data->data.taskfinish->jobid, data->data.taskfinish->host,
|
||||
data->data.taskfinish->taskidx,
|
||||
data->data.taskfinish->exit_code);
|
||||
break;
|
||||
|
|
@ -1970,8 +1905,7 @@ static int handle_notify(xce_request_t* request)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int job_kill(uint64_t jobid,
|
||||
int signo)
|
||||
static int job_kill(uint64_t jobid, int signo)
|
||||
{
|
||||
int i;
|
||||
int killed = 0;
|
||||
|
|
@ -1990,23 +1924,21 @@ static int job_kill(uint64_t jobid,
|
|||
return killed;
|
||||
}
|
||||
|
||||
static int job_chkpnt(uint64_t jobid,
|
||||
char* method,
|
||||
int kill)
|
||||
static int job_chkpnt(uint64_t jobid, char* method, int kill)
|
||||
{
|
||||
char buf[128];
|
||||
char info[256];
|
||||
|
||||
printf("checkpoint job %ld by method %s\n",
|
||||
jobid, method);
|
||||
printf("checkpoint job %ld by method %s\n", jobid, method);
|
||||
sprintf(buf, "/tmp/%ld/ckpt_dir", jobid);
|
||||
|
||||
/* do some actions to checkpoint jobs */
|
||||
|
||||
sprintf(info, "{\nhost_select=\"criu\"; \nrestart_command=\"cd %s; criu restore -vvv\"}\n",
|
||||
sprintf(info,
|
||||
"{\nhost_select=\"criu\"; \nrestart_command=\"cd %s; criu restore "
|
||||
"-vvv\"}\n",
|
||||
buf);
|
||||
xcecli_notify_jobchkpt(active_ctx->ctx,
|
||||
jobid, info);
|
||||
xcecli_notify_jobchkpt(active_ctx->ctx, jobid, info);
|
||||
|
||||
if (kill) {
|
||||
job_kill(jobid, SIGTERM);
|
||||
|
|
@ -2029,14 +1961,12 @@ static int handle_jobcontrol(xce_request_t* request)
|
|||
rc = job_kill(jobid, signo);
|
||||
break;
|
||||
case JobControl_u_ckptoption:
|
||||
rc = job_chkpnt(jobctrl->jobid,
|
||||
jobctrl->u.ckptoption->method,
|
||||
rc = job_chkpnt(jobctrl->jobid, jobctrl->u.ckptoption->method,
|
||||
jobctrl->u.ckptoption->kill);
|
||||
break;
|
||||
default:
|
||||
rc = -EINVAL;
|
||||
ERROR("unknown job control action %d",
|
||||
jobctrl->action);
|
||||
ERROR("unknown job control action %d", jobctrl->action);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2056,9 +1986,7 @@ static int handle_runtasks(xce_request_t* request)
|
|||
/* something wrong */
|
||||
rc = -EINVAL;
|
||||
|
||||
notify_task_fail(runmsg->jobid,
|
||||
runmsg->clientidx,
|
||||
-1, rc);
|
||||
notify_task_fail(runmsg->jobid, runmsg->clientidx, -1, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -2066,9 +1994,7 @@ static int handle_runtasks(xce_request_t* request)
|
|||
/* something wrong */
|
||||
rc = -EINVAL;
|
||||
|
||||
notify_task_fail(runmsg->jobid,
|
||||
runmsg->clientidx,
|
||||
-1, rc);
|
||||
notify_task_fail(runmsg->jobid, runmsg->clientidx, -1, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -2093,14 +2019,11 @@ static int handle_runtasks(xce_request_t* request)
|
|||
|
||||
rc = run_task(runmsg->taskhosts[0]->cmdline, &pid);
|
||||
if (rc < 0) {
|
||||
notify_task_fail(runmsg->jobid,
|
||||
runmsg->clientidx,
|
||||
i, rc);
|
||||
notify_task_fail(runmsg->jobid, runmsg->clientidx, i, rc);
|
||||
} else {
|
||||
int idx;
|
||||
|
||||
printf("job %lu task %d started, PID: %d\n",
|
||||
runmsg->jobid, i, pid);
|
||||
printf("job %lu task %d started, PID: %d\n", runmsg->jobid, i, pid);
|
||||
|
||||
idx = get_avail_run_task_slots();
|
||||
if (idx < 0) {
|
||||
|
|
@ -2112,9 +2035,7 @@ static int handle_runtasks(xce_request_t* request)
|
|||
run_tasks[idx].pid = pid;
|
||||
run_tasks[idx].ts = 0;
|
||||
}
|
||||
notify_task_start(runmsg->jobid,
|
||||
runmsg->clientidx,
|
||||
i, pid, pgid);
|
||||
notify_task_start(runmsg->jobid, runmsg->clientidx, i, pid, pgid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2133,13 +2054,11 @@ static int myreq_handler(xce_request_t* request)
|
|||
switch (datamsg->table) {
|
||||
case Data_data_schedjobs:
|
||||
case Data_data_jobs:
|
||||
sched_on_jobs(datamsg->nrows,
|
||||
(xce_job_t**)datamsg->rows);
|
||||
sched_on_jobs(datamsg->nrows, (xce_job_t**)datamsg->rows);
|
||||
break;
|
||||
case Data_data_schedworkers:
|
||||
case Data_data_workers:
|
||||
sched_on_workers(datamsg->nrows,
|
||||
(xce_worker_t**)datamsg->rows);
|
||||
sched_on_workers(datamsg->nrows, (xce_worker_t**)datamsg->rows);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -2181,7 +2100,8 @@ static void check_run_jobs()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (waitpid(run_jobs[i].pid, &wstatus, WNOHANG | WUNTRACED | WCONTINUED) <= 0) {
|
||||
if (waitpid(run_jobs[i].pid, &wstatus, WNOHANG | WUNTRACED | WCONTINUED)
|
||||
<= 0) {
|
||||
/* fake job rusage */
|
||||
int npids = 1;
|
||||
int npgids = 0;
|
||||
|
|
@ -2190,15 +2110,12 @@ static void check_run_jobs()
|
|||
{ "cputime", 100.0 },
|
||||
{ "mem", 200.0 }
|
||||
};
|
||||
xce_rusage_t* usages[] = {
|
||||
&(data[0]),
|
||||
&(data[1])
|
||||
};
|
||||
xce_rusage_t* usages[] = { &(data[0]), &(data[1]) };
|
||||
|
||||
if (now - run_jobs[i].ts > RUSAGE_UPDATE_INTERVAL) {
|
||||
xcecli_update_jusage(active_ctx->ctx, run_jobs[i].jobid,
|
||||
npids, &(run_jobs[i].pid), npgids, NULL,
|
||||
nusage, &usages[0]);
|
||||
xcecli_update_jusage(active_ctx->ctx, run_jobs[i].jobid, npids,
|
||||
&(run_jobs[i].pid), npgids, NULL, nusage,
|
||||
&usages[0]);
|
||||
run_jobs[i].ts = now;
|
||||
}
|
||||
|
||||
|
|
@ -2220,8 +2137,7 @@ static void check_run_jobs()
|
|||
finish.exit_code = 128 + WTERMSIG(wstatus);
|
||||
}
|
||||
|
||||
printf("job %lu exit code %d\n",
|
||||
finish.jobid, finish.exit_code);
|
||||
printf("job %lu exit code %d\n", finish.jobid, finish.exit_code);
|
||||
xcecli_notify_jobfinish(active_ctx->ctx, &finish);
|
||||
run_jobs[i].jobid = 0;
|
||||
run_jobs[i].pid = 0;
|
||||
|
|
@ -2245,7 +2161,9 @@ static void check_run_tasks()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (waitpid(run_tasks[i].pid, &wstatus, WNOHANG | WUNTRACED | WCONTINUED) <= 0) {
|
||||
if (waitpid(run_tasks[i].pid, &wstatus,
|
||||
WNOHANG | WUNTRACED | WCONTINUED)
|
||||
<= 0) {
|
||||
/* fake job rusage */
|
||||
int npids = 1;
|
||||
int npgids = 0;
|
||||
|
|
@ -2254,28 +2172,23 @@ static void check_run_tasks()
|
|||
{ "cputime", 100.0 },
|
||||
{ "mem", 200.0 }
|
||||
};
|
||||
xce_rusage_t* usages[] = {
|
||||
&(data[0]),
|
||||
&(data[1])
|
||||
};
|
||||
xce_rusage_t* usages[] = { &(data[0]), &(data[1]) };
|
||||
|
||||
if (now - run_tasks[i].ts > RUSAGE_UPDATE_INTERVAL) {
|
||||
xcecli_update_jusage(active_ctx->ctx, run_tasks[i].jobid,
|
||||
npids, &(run_tasks[i].pid), npgids, NULL,
|
||||
nusage, &usages[0]);
|
||||
xcecli_update_jusage(active_ctx->ctx, run_tasks[i].jobid, npids,
|
||||
&(run_tasks[i].pid), npgids, NULL, nusage,
|
||||
&usages[0]);
|
||||
run_tasks[i].ts = now;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (WIFEXITED(wstatus) || WIFSIGNALED(wstatus)) {
|
||||
xce_task_finish_t finish = {
|
||||
.jobid = run_tasks[i].jobid,
|
||||
.host = get_setting("myname"),
|
||||
.taskidx = run_tasks[i].taskid,
|
||||
.clientidx = run_tasks[i].clientidx,
|
||||
.exit_code = 0
|
||||
};
|
||||
xce_task_finish_t finish = { .jobid = run_tasks[i].jobid,
|
||||
.host = get_setting("myname"),
|
||||
.taskidx = run_tasks[i].taskid,
|
||||
.clientidx = run_tasks[i].clientidx,
|
||||
.exit_code = 0 };
|
||||
|
||||
if (WIFEXITED(wstatus)) {
|
||||
finish.exit_code = WEXITSTATUS(wstatus);
|
||||
|
|
@ -2283,9 +2196,8 @@ static void check_run_tasks()
|
|||
finish.exit_code = 128 + WTERMSIG(wstatus);
|
||||
}
|
||||
|
||||
printf("job %lu task %d exit code %d\n",
|
||||
finish.jobid, finish.taskidx,
|
||||
finish.exit_code);
|
||||
printf("job %lu task %d exit code %d\n", finish.jobid,
|
||||
finish.taskidx, finish.exit_code);
|
||||
xcecli_notify_taskfinish(active_ctx->ctx, &finish);
|
||||
run_tasks[i].jobid = 0;
|
||||
run_tasks[i].pid = 0;
|
||||
|
|
@ -2311,7 +2223,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
struct arguments arguments;
|
||||
char* buf;
|
||||
char* logfile = "/tmp/xce_test.log";
|
||||
char* logfile = "/tmp/xce_test.log";
|
||||
char* loglevel = "info";
|
||||
int logsize = 64 * 1024 * 1024;
|
||||
int logcount = 10;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
#include "xce/cluster_def.h"
|
||||
#include "xce/errnox.h"
|
||||
|
||||
static int hostmatched(const char* pattern,
|
||||
const char* name)
|
||||
static int hostmatched(const char* pattern, const char* name)
|
||||
{
|
||||
if (strcmp(pattern, name) == 0) {
|
||||
return 1;
|
||||
|
|
@ -16,8 +15,7 @@ static int hostmatched(const char* pattern,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static xce_hostconfig_t* find_matched_hostconfig(cluster_t* c,
|
||||
const char* name)
|
||||
static xce_hostconfig_t* find_matched_hostconfig(cluster_t* c, const char* name)
|
||||
{
|
||||
xce_hostconfig_t* defaultconfig = NULL;
|
||||
xce_hostconfig_t** hconfigs = NULL;
|
||||
|
|
@ -56,10 +54,8 @@ static xce_hostconfig_t* find_matched_hostconfig(cluster_t* c,
|
|||
return defaultconfig;
|
||||
}
|
||||
|
||||
static int update_val_res(cluster_t* c,
|
||||
worker_t* w,
|
||||
xce_resource_t* r,
|
||||
xce_val_t* val)
|
||||
static int update_val_res(cluster_t* c, worker_t* w, xce_resource_t* r,
|
||||
xce_val_t* val)
|
||||
{
|
||||
int idx;
|
||||
zarray_t* array = NULL;
|
||||
|
|
@ -97,26 +93,20 @@ static int update_val_res(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int update_resval(cluster_t* c,
|
||||
worker_t* w,
|
||||
xce_resval_t* val)
|
||||
static int update_resval(cluster_t* c, worker_t* w, xce_resval_t* val)
|
||||
{
|
||||
xce_resource_t* r;
|
||||
xce_val_t* v = NULL;
|
||||
int rc;
|
||||
|
||||
r = resmgr_lockres(&(c->resmgr),
|
||||
val->name,
|
||||
OBJREF_READ);
|
||||
r = resmgr_lockres(&(c->resmgr), val->name, OBJREF_READ);
|
||||
if (r == NULL) {
|
||||
ERROR("resource `%s' can not be found",
|
||||
val->name);
|
||||
ERROR("resource `%s' can not be found", val->name);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (r->idx < 0) {
|
||||
ERROR("invalid resource definition for %s",
|
||||
val->name);
|
||||
ERROR("invalid resource definition for %s", val->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -129,10 +119,7 @@ static int update_resval(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int update_resvals(cluster_t* c,
|
||||
worker_t* w,
|
||||
int nres,
|
||||
xce_resval_t* vals)
|
||||
int update_resvals(cluster_t* c, worker_t* w, int nres, xce_resval_t* vals)
|
||||
{
|
||||
int rc = 0;
|
||||
int i;
|
||||
|
|
@ -147,9 +134,7 @@ int update_resvals(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int update_resval_list(cluster_t* c,
|
||||
worker_t* w,
|
||||
xce_resval_list_t* l)
|
||||
int update_resval_list(cluster_t* c, worker_t* w, xce_resval_list_t* l)
|
||||
{
|
||||
int rc = 0;
|
||||
int i;
|
||||
|
|
@ -164,9 +149,7 @@ int update_resval_list(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mark_host_res(cluster_t* c,
|
||||
worker_t* w,
|
||||
xce_config_t* config)
|
||||
static int mark_host_res(cluster_t* c, worker_t* w, xce_config_t* config)
|
||||
{
|
||||
xce_resource_t* r;
|
||||
char* n = config->name;
|
||||
|
|
@ -177,14 +160,12 @@ static int mark_host_res(cluster_t* c,
|
|||
|
||||
r = resmgr_lockres(&(c->resmgr), n, OBJREF_READ);
|
||||
if (r == NULL) {
|
||||
ERROR("resource `%s' can not be found",
|
||||
n);
|
||||
ERROR("resource `%s' can not be found", n);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (r->idx < 0) {
|
||||
ERROR("invalid resource definition for `%s'",
|
||||
n);
|
||||
ERROR("invalid resource definition for `%s'", n);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -222,19 +203,20 @@ static int mark_host_res(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int add_hostattrs_resvals(cluster_t* c,
|
||||
worker_t* w)
|
||||
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->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 } }
|
||||
{ .which = Value_u_svalue, .u = { .svalue = w->host.attrs->hosttype } },
|
||||
{ .which = Value_u_svalue,
|
||||
.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 } }
|
||||
};
|
||||
xce_resval_t resvals[N_HOST_ATTRS] = {
|
||||
{ .name = "type", .val = &values[0] },
|
||||
|
|
@ -247,13 +229,10 @@ static int add_hostattrs_resvals(cluster_t* c,
|
|||
{ .name = "ndisks", .val = &values[7] }
|
||||
};
|
||||
|
||||
return update_resvals(c, w, N_HOST_ATTRS,
|
||||
&(resvals[0]));
|
||||
return update_resvals(c, w, N_HOST_ATTRS, &(resvals[0]));
|
||||
}
|
||||
|
||||
static int set_host_slots(cluster_t* c,
|
||||
worker_t* w,
|
||||
int nslots)
|
||||
static int set_host_slots(cluster_t* c, worker_t* w, int nslots)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_val_t values[1] = {
|
||||
|
|
@ -275,10 +254,7 @@ static int set_host_slots(cluster_t* c,
|
|||
return update_resvals(c, w, 1, &(resvals[0]));
|
||||
}
|
||||
|
||||
int add_worker(void* cls,
|
||||
endpoint_t* ep,
|
||||
const char* host,
|
||||
hostattrs_t* attrs)
|
||||
int add_worker(void* cls, endpoint_t* ep, const char* host, hostattrs_t* attrs)
|
||||
{
|
||||
cluster_t* c = (cluster_t*)cls;
|
||||
/* clang-format off */
|
||||
|
|
@ -317,17 +293,15 @@ int add_worker(void* cls,
|
|||
/* override host type? */
|
||||
if (strcmp(hconfig->hosttype, "!") != 0) {
|
||||
obj_deref(w->host.attrs->hosttype);
|
||||
w->host.attrs->hosttype = create_obj_by_typename(&(c->objmgr),
|
||||
"xstring",
|
||||
hconfig->hosttype);
|
||||
w->host.attrs->hosttype = create_obj_by_typename(
|
||||
&(c->objmgr), "xstring", hconfig->hosttype);
|
||||
}
|
||||
|
||||
/* override host model */
|
||||
if (strcmp(hconfig->hostmodel, "!") != 0) {
|
||||
obj_deref(w->host.attrs->hostmodel);
|
||||
w->host.attrs->hostmodel = create_obj_by_typename(&(c->objmgr),
|
||||
"xstring",
|
||||
hconfig->hostmodel);
|
||||
w->host.attrs->hostmodel = create_obj_by_typename(
|
||||
&(c->objmgr), "xstring", hconfig->hostmodel);
|
||||
}
|
||||
add_hostattrs_resvals(c, w);
|
||||
idx = w->idx;
|
||||
|
|
@ -346,12 +320,12 @@ int add_worker(void* cls,
|
|||
}
|
||||
|
||||
if (hconfig->dispatchwindow != NULL) {
|
||||
w->host.dispatch_window_config = dup_timewindow_config(hconfig->dispatchwindow);
|
||||
w->host.dispatch_window_config
|
||||
= dup_timewindow_config(hconfig->dispatchwindow);
|
||||
}
|
||||
|
||||
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.thresholds = NULL;
|
||||
}
|
||||
|
|
@ -372,8 +346,7 @@ int add_worker(void* cls,
|
|||
return idx;
|
||||
}
|
||||
|
||||
int restore_worker(void* cls,
|
||||
xce_worker_t host)
|
||||
int restore_worker(void* cls, xce_worker_t host)
|
||||
{
|
||||
cluster_t* c = (cluster_t*)cls;
|
||||
int idx = 0;
|
||||
|
|
@ -415,15 +388,15 @@ static int check_conf4worker_(xce_config_t* c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int worker_push_config(cluster_t* c,
|
||||
endpoint_t* ep)
|
||||
static int worker_push_config(cluster_t* c, endpoint_t* ep)
|
||||
{
|
||||
xce_configdata_t configdata;
|
||||
int rc = 0;
|
||||
|
||||
memset(&configdata, 0x0, sizeof(configdata));
|
||||
|
||||
configdata.data.conf4worker = (xce_conf4worker_t*)calloc(1, sizeof(xce_conf4worker_t));
|
||||
configdata.data.conf4worker
|
||||
= (xce_conf4worker_t*)calloc(1, sizeof(xce_conf4worker_t));
|
||||
if (configdata.data.conf4worker == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
@ -431,8 +404,9 @@ static int worker_push_config(cluster_t* c,
|
|||
collect_confvars(c, (collect_check_fn_t)check_conf4worker_,
|
||||
&(configdata.data.conf4worker->n_confvars),
|
||||
&(configdata.data.conf4worker->confvars));
|
||||
configdata.data_which = ConfigData_data_workerconfig;
|
||||
configdata.data.conf4worker->clustername = c->myconf->cluster_config->clustername;
|
||||
configdata.data_which = ConfigData_data_workerconfig;
|
||||
configdata.data.conf4worker->clustername
|
||||
= c->myconf->cluster_config->clustername;
|
||||
|
||||
rc = xce_pushconfig_req(ep, c->myhost, &configdata);
|
||||
|
||||
|
|
@ -446,8 +420,7 @@ static int worker_push_config(cluster_t* c,
|
|||
}
|
||||
|
||||
/* consider to push jobs on hosts to */
|
||||
int on_worker_join(void* cls,
|
||||
endpoint_t* ep)
|
||||
int on_worker_join(void* cls, endpoint_t* ep)
|
||||
{
|
||||
cluster_t* c = (cluster_t*)cls;
|
||||
int rc = 0;
|
||||
|
|
@ -457,19 +430,14 @@ int on_worker_join(void* cls,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int get_resval(cluster_t* c,
|
||||
char* resname,
|
||||
char* host,
|
||||
xce_val_t* val)
|
||||
int get_resval(cluster_t* c, char* resname, char* host, xce_val_t* val)
|
||||
{
|
||||
xce_resource_t* r;
|
||||
zarray_t* array = NULL;
|
||||
xce_val_t* v = NULL;
|
||||
worker_t* w = NULL;
|
||||
|
||||
r = resmgr_lockres(&(c->resmgr),
|
||||
resname,
|
||||
OBJREF_READ);
|
||||
r = resmgr_lockres(&(c->resmgr), resname, OBJREF_READ);
|
||||
if (r == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
@ -481,8 +449,7 @@ int get_resval(cluster_t* c,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
w = workermgr_lock(&(c->workermgr),
|
||||
host, OBJREF_READ);
|
||||
w = workermgr_lock(&(c->workermgr), host, OBJREF_READ);
|
||||
if (w == NULL) {
|
||||
DEREF_OBJ(r);
|
||||
return -ENOENT;
|
||||
|
|
@ -509,13 +476,11 @@ int get_resval(cluster_t* c,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int handle_worker_leave(cluster_t* c,
|
||||
int idx)
|
||||
int handle_worker_leave(cluster_t* c, int idx)
|
||||
{
|
||||
worker_t* w = NULL;
|
||||
|
||||
TRACE("%s worker %d broken connection",
|
||||
__func__, idx);
|
||||
TRACE("%s worker %d broken connection", __func__, idx);
|
||||
|
||||
if (c == NULL) {
|
||||
SET_ERROR(EINVAL);
|
||||
|
|
@ -527,27 +492,20 @@ int handle_worker_leave(cluster_t* c,
|
|||
return -errno;
|
||||
}
|
||||
|
||||
w = workermgr_lock_byid(&(c->workermgr),
|
||||
idx, OBJREF_UPDATE);
|
||||
w = workermgr_lock_byid(&(c->workermgr), idx, OBJREF_UPDATE);
|
||||
if (w == NULL) {
|
||||
ERROR("fail to find worker by id %d", idx);
|
||||
SET_ERROR(E_XCE_BAD_WORKER);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
HOOK_BEFORE_EVENT,
|
||||
HOOK_DETAIL_WORKER_DEAD,
|
||||
c, 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->ep = NULL;
|
||||
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_DEAD,
|
||||
c, w);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_DEAD, c, w);
|
||||
obj_deref(w);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -587,11 +545,8 @@ int worker_ctrl(cluster_t* c, xce_hostctrl_t* ctrl)
|
|||
break;
|
||||
}
|
||||
if (rc == 0) {
|
||||
xce_run_hooks(&(c->hooksys),
|
||||
XCE_CONTROLLER_HOOK_WORKER,
|
||||
HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_UPDATE,
|
||||
c, w);
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER,
|
||||
HOOK_AFTER_EVENT, HOOK_DETAIL_WORKER_UPDATE, c, w);
|
||||
}
|
||||
clean:
|
||||
obj_deref(w);
|
||||
|
|
|
|||
|
|
@ -11,16 +11,12 @@
|
|||
|
||||
extern void worker_obj_killer(worker_t*);
|
||||
|
||||
int workermgr_init(workermgr_t* mgr,
|
||||
int nslots,
|
||||
int delta)
|
||||
int workermgr_init(workermgr_t* mgr, int nslots, int delta)
|
||||
{
|
||||
TRACE("%s nslots %d delta %d",
|
||||
__func__, nslots, delta);
|
||||
TRACE("%s nslots %d delta %d", __func__, nslots, delta);
|
||||
|
||||
mylock_init(&(mgr->lock));
|
||||
ht_init(&(mgr->htab), nslots,
|
||||
string_hash_key);
|
||||
ht_init(&(mgr->htab), nslots, string_hash_key);
|
||||
zarray_init(&(mgr->workers), delta,
|
||||
(zarray_item_killer_t)worker_obj_killer);
|
||||
return 0;
|
||||
|
|
@ -33,8 +29,7 @@ void workermgr_fini(workermgr_t* mgr)
|
|||
mylock_fini(&(mgr->lock));
|
||||
}
|
||||
|
||||
static int32_t workermgr_add_(workermgr_t* mgr,
|
||||
worker_t* w)
|
||||
static int32_t workermgr_add_(workermgr_t* mgr, worker_t* w)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -49,8 +44,7 @@ static int32_t workermgr_add_(workermgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
e = ht_add(&(mgr->htab),
|
||||
(void*)w->host.name);
|
||||
e = ht_add(&(mgr->htab), (void*)w->host.name);
|
||||
if (e == NULL) {
|
||||
zarray_del(&(mgr->workers), idx);
|
||||
return -errno;
|
||||
|
|
@ -61,8 +55,7 @@ static int32_t workermgr_add_(workermgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
int32_t workermgr_add(workermgr_t* mgr,
|
||||
worker_t* w)
|
||||
int32_t workermgr_add(workermgr_t* mgr, worker_t* w)
|
||||
{
|
||||
int idx;
|
||||
|
||||
|
|
@ -77,9 +70,7 @@ int32_t workermgr_add(workermgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
static worker_t* workermgr_lock_(workermgr_t* mgr,
|
||||
char* name,
|
||||
int op)
|
||||
static worker_t* workermgr_lock_(workermgr_t* mgr, char* name, int op)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -102,9 +93,7 @@ static worker_t* workermgr_lock_(workermgr_t* mgr,
|
|||
return obj_ref(w, op);
|
||||
}
|
||||
|
||||
worker_t* workermgr_lock(workermgr_t* mgr,
|
||||
char* name,
|
||||
int op)
|
||||
worker_t* workermgr_lock(workermgr_t* mgr, char* name, int op)
|
||||
{
|
||||
worker_t* w = NULL;
|
||||
|
||||
|
|
@ -134,9 +123,7 @@ worker_t* workermgr_lock(workermgr_t* mgr,
|
|||
return w;
|
||||
}
|
||||
|
||||
worker_t* workermgr_lock_byid(workermgr_t* mgr,
|
||||
int idx,
|
||||
int op)
|
||||
worker_t* workermgr_lock_byid(workermgr_t* mgr, int idx, int op)
|
||||
{
|
||||
worker_t* w = NULL;
|
||||
|
||||
|
|
@ -169,14 +156,12 @@ worker_t* workermgr_lock_byid(workermgr_t* mgr,
|
|||
return w;
|
||||
}
|
||||
|
||||
static void workermgr_del_(workermgr_t* mgr,
|
||||
worker_t* w)
|
||||
static void workermgr_del_(workermgr_t* mgr, worker_t* w)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
||||
e = ht_get(&(mgr->htab),
|
||||
(void*)w->host.name);
|
||||
e = ht_get(&(mgr->htab), (void*)w->host.name);
|
||||
if (e == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -189,8 +174,7 @@ static void workermgr_del_(workermgr_t* mgr,
|
|||
zarray_del(&(mgr->workers), idx);
|
||||
}
|
||||
|
||||
void workermgr_del(workermgr_t* mgr,
|
||||
worker_t* w)
|
||||
void workermgr_del(workermgr_t* mgr, worker_t* w)
|
||||
{
|
||||
if ((mgr == NULL) || (w == NULL)) {
|
||||
SET_ERROR(EINVAL);
|
||||
|
|
@ -202,9 +186,7 @@ void workermgr_del(workermgr_t* mgr,
|
|||
mylock_unlock(&(mgr->lock));
|
||||
}
|
||||
|
||||
int workermgr_iter(workermgr_t* mgr,
|
||||
xlist_t* l,
|
||||
void* arg)
|
||||
int workermgr_iter(workermgr_t* mgr, xlist_t* l, void* arg)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "xce/errnox.h"
|
||||
|
||||
int __wrap___xpg_strerror_r(int errnum,
|
||||
char* buf,
|
||||
size_t bufsize)
|
||||
{
|
||||
return xce_strerror_r(errnum, buf, bufsize);
|
||||
}
|
||||
|
||||
static void xce_perror_(const char* s, int errnum)
|
||||
{
|
||||
char buf[XCE_MAX_ERRMSG_LEN];
|
||||
ectx_t* ectx = get_ectx();
|
||||
|
||||
xce_strerror_r(errnum, buf, sizeof(buf));
|
||||
|
||||
if (tlog_get_root() == NULL) {
|
||||
if ((ectx->file != NULL) && (ectx->func != NULL) && (ectx->line > 0) && (ectx->code == errnum)) {
|
||||
fprintf(stderr, "%s: %s at %s:%d %s\n",
|
||||
s, buf, ectx->file,
|
||||
ectx->line, ectx->func);
|
||||
} else {
|
||||
fprintf(stderr, "%s: %s", s, buf);
|
||||
}
|
||||
} else {
|
||||
if ((ectx->file != NULL) && (ectx->func != NULL) && (ectx->line > 0) && (ectx->code == errnum)) {
|
||||
tlog_error("%s: %s at %s:%d %s\n",
|
||||
s, buf, ectx->file,
|
||||
ectx->line, ectx->func);
|
||||
} else {
|
||||
tlog_error("%s: %s", s, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void xce_perror(const char* s)
|
||||
{
|
||||
xce_perror_(s, errno);
|
||||
}
|
||||
|
||||
void __wrap_perror(const char* s)
|
||||
{
|
||||
xce_perror(s);
|
||||
}
|
||||
|
||||
int __wrap_printf(const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rc;
|
||||
|
||||
va_start(ap, fmt);
|
||||
rc = xce_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -86,9 +86,7 @@ static objtype_t types[] = {
|
|||
};
|
||||
/* clang-format on */
|
||||
|
||||
static void* xjob_create(objmgr_t* mgr,
|
||||
objtype_t* type,
|
||||
va_list ap)
|
||||
static void* xjob_create(objmgr_t* mgr, objtype_t* type, va_list ap)
|
||||
{
|
||||
jobmgr_t* jobmgr = &(((cluster_t*)type->typedata)->jobmgr);
|
||||
xce_job_t* submit = va_arg(ap, xce_job_t*);
|
||||
|
|
@ -117,32 +115,29 @@ static void* xjob_create(objmgr_t* mgr,
|
|||
job = MYOBJ_TO_OBJ(job_t*, obj);
|
||||
/* fill job data */
|
||||
job->job.jobid = submit->jobid;
|
||||
job->job.queue = create_obj_by_typename(mgr, "xstring",
|
||||
submit->queue);
|
||||
job->job.queue = create_obj_by_typename(mgr, "xstring", submit->queue);
|
||||
job->job.sub_time = submit->sub_time;
|
||||
job->job.queue_time = submit->queue_time;
|
||||
if (job->job.queue_time == 0) {
|
||||
job->job.queue_time = job->job.sub_time;
|
||||
}
|
||||
job->job.state = submit->state;
|
||||
job->job.user = create_obj_by_typename(mgr, "xstring",
|
||||
submit->user);
|
||||
job->job.start_time = submit->start_time;
|
||||
job->job.finish_time = submit->finish_time;
|
||||
job->job.job_name = create_obj_by_typename(mgr, "xstring",
|
||||
submit->job_name);
|
||||
job->job.project_name = create_obj_by_typename(mgr, "xstring",
|
||||
submit->project_name);
|
||||
job->job.user_group = create_obj_by_typename(mgr, "xstring",
|
||||
submit->user_group);
|
||||
job->job.job_description = create_obj_by_typename(mgr, "xstring",
|
||||
submit->job_description);
|
||||
job->job.resreq = create_obj_by_typename(mgr, "xstring",
|
||||
submit->resreq);
|
||||
job->job.run_time = submit->run_time;
|
||||
job->job.mintasks = submit->mintasks;
|
||||
job->job.maxtasks = submit->maxtasks;
|
||||
job->job.pending_ctrl = submit->pending_ctrl;
|
||||
job->job.state = submit->state;
|
||||
job->job.user = create_obj_by_typename(mgr, "xstring", submit->user);
|
||||
job->job.start_time = submit->start_time;
|
||||
job->job.finish_time = submit->finish_time;
|
||||
job->job.job_name
|
||||
= create_obj_by_typename(mgr, "xstring", submit->job_name);
|
||||
job->job.project_name
|
||||
= create_obj_by_typename(mgr, "xstring", submit->project_name);
|
||||
job->job.user_group
|
||||
= create_obj_by_typename(mgr, "xstring", submit->user_group);
|
||||
job->job.job_description
|
||||
= create_obj_by_typename(mgr, "xstring", submit->job_description);
|
||||
job->job.resreq = create_obj_by_typename(mgr, "xstring", submit->resreq);
|
||||
job->job.run_time = submit->run_time;
|
||||
job->job.mintasks = submit->mintasks;
|
||||
job->job.maxtasks = submit->maxtasks;
|
||||
job->job.pending_ctrl = submit->pending_ctrl;
|
||||
|
||||
job->job.pidinfo = NULL;
|
||||
|
||||
|
|
@ -152,44 +147,47 @@ static void* xjob_create(objmgr_t* mgr,
|
|||
SET_ERROR(ENOMEM);
|
||||
goto clean_job;
|
||||
}
|
||||
job->job.pidinfo->npids = copy_int_list((int**)&(job->job.pidinfo->pids),
|
||||
(int*)submit->pidinfo->pids, submit->pidinfo->npids);
|
||||
job->job.pidinfo->npgids = copy_int_list((int**)&(job->job.pidinfo->pgids),
|
||||
(int*)submit->pidinfo->pgids, submit->pidinfo->npgids);
|
||||
job->job.pidinfo->npids = copy_int_list(
|
||||
(int**)&(job->job.pidinfo->pids), (int*)submit->pidinfo->pids,
|
||||
submit->pidinfo->npids);
|
||||
job->job.pidinfo->npgids = copy_int_list(
|
||||
(int**)&(job->job.pidinfo->pgids), (int*)submit->pidinfo->pgids,
|
||||
submit->pidinfo->npgids);
|
||||
if (submit->pidinfo->exdata) {
|
||||
job->job.pidinfo->exdata = create_obj_by_typename(mgr, "xstring",
|
||||
submit->pidinfo->exdata);
|
||||
job->job.pidinfo->exdata = create_obj_by_typename(
|
||||
mgr, "xstring", submit->pidinfo->exdata);
|
||||
}
|
||||
}
|
||||
|
||||
job->job.start_info = NULL;
|
||||
|
||||
if (submit->start_info != NULL) {
|
||||
job->job.start_info = (job_startinfo_t*)calloc(1, sizeof(job_startinfo_t));
|
||||
job->job.start_info
|
||||
= (job_startinfo_t*)calloc(1, sizeof(job_startinfo_t));
|
||||
if (job->job.start_info == NULL) {
|
||||
SET_ERROR(ENOMEM);
|
||||
goto clean_job;
|
||||
}
|
||||
job->job.start_info->cmdline = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->cmdline);
|
||||
job->job.start_info->exdata = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->exdata);
|
||||
job->job.start_info->execcwd = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->execcwd);
|
||||
job->job.start_info->exechome = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->exechome);
|
||||
job->job.start_info->execuser = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->execuser);
|
||||
job->job.start_info->launch_type = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->launch_type);
|
||||
job->job.start_info->cmdline = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->cmdline);
|
||||
job->job.start_info->exdata = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->exdata);
|
||||
job->job.start_info->execcwd = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->execcwd);
|
||||
job->job.start_info->exechome = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->exechome);
|
||||
job->job.start_info->execuser = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->execuser);
|
||||
job->job.start_info->launch_type = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->launch_type);
|
||||
if (submit->start_info->job_pre_exec != NULL) {
|
||||
job->job.start_info->job_pre_exec = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->job_pre_exec);
|
||||
job->job.start_info->job_pre_exec = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->job_pre_exec);
|
||||
}
|
||||
|
||||
if (submit->start_info->job_post_exec != NULL) {
|
||||
job->job.start_info->job_post_exec = create_obj_by_typename(mgr, "xstring",
|
||||
submit->start_info->job_post_exec);
|
||||
job->job.start_info->job_post_exec = create_obj_by_typename(
|
||||
mgr, "xstring", submit->start_info->job_post_exec);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -263,7 +261,8 @@ void job_obj_killer(job_t* job)
|
|||
for (int i = 0; i < job->job.allocs->nhosts; i++) {
|
||||
FREEUP(job->job.allocs->allocs[i]->host);
|
||||
for (int k = 0; k < job->job.allocs->allocs[i]->nallocs; k++) {
|
||||
xce_alloc_t* alloc = (xce_alloc_t*)job->job.allocs->allocs[i]->allocs[k];
|
||||
xce_alloc_t* alloc
|
||||
= (xce_alloc_t*)job->job.allocs->allocs[i]->allocs[k];
|
||||
if (alloc == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -329,10 +328,7 @@ static void xjob_fini(void* j)
|
|||
return;
|
||||
}
|
||||
|
||||
static void xjob_type_fini(objtype_t* typeval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xjob_type_fini(objtype_t* typeval) { return; }
|
||||
|
||||
int register_types(cluster_t* c)
|
||||
{
|
||||
|
|
@ -351,13 +347,8 @@ int register_types(cluster_t* c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void resval_obj_killer(xce_resval_t* v)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void* xres_create(objmgr_t* mgr,
|
||||
objtype_t* type,
|
||||
va_list ap)
|
||||
void resval_obj_killer(xce_resval_t* v) { return; }
|
||||
static void* xres_create(objmgr_t* mgr, objtype_t* type, va_list ap)
|
||||
{
|
||||
resmgr_t* resmgr = &(((cluster_t*)type->typedata)->resmgr);
|
||||
xce_resource_t* r = va_arg(ap, xce_resource_t*);
|
||||
|
|
@ -478,10 +469,7 @@ static void xres_fini(void* p)
|
|||
return;
|
||||
}
|
||||
|
||||
static void xres_type_fini(objtype_t* typeval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xres_type_fini(objtype_t* typeval) { return; }
|
||||
|
||||
void worker_obj_killer(worker_t* w)
|
||||
{
|
||||
|
|
@ -496,8 +484,7 @@ void worker_obj_killer(worker_t* w)
|
|||
DEREF_OBJ(w->host.name);
|
||||
|
||||
if ((w->host.thresholds != NULL) && (w->host.nthresholds > 0)) {
|
||||
free_resource_thresholds(w->host.thresholds,
|
||||
w->host.nthresholds);
|
||||
free_resource_thresholds(w->host.thresholds, w->host.nthresholds);
|
||||
w->host.thresholds = NULL;
|
||||
w->host.nthresholds = 0;
|
||||
}
|
||||
|
|
@ -529,9 +516,7 @@ static void kill_resval(void* p)
|
|||
free(p);
|
||||
}
|
||||
|
||||
static void* xworker_create(objmgr_t* mgr,
|
||||
objtype_t* typeval,
|
||||
va_list ap)
|
||||
static void* xworker_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
|
||||
{
|
||||
workermgr_t* workermgr = &(((cluster_t*)typeval->typedata)->workermgr);
|
||||
worker_t* w = va_arg(ap, worker_t*);
|
||||
|
|
@ -560,8 +545,7 @@ static void* xworker_create(objmgr_t* mgr,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
w1->host.name = create_obj_by_typename(mgr, "xstring",
|
||||
w->host.name);
|
||||
w1->host.name = create_obj_by_typename(mgr, "xstring", w->host.name);
|
||||
|
||||
idx = workermgr_add(workermgr, w1);
|
||||
obj_init(mgr, typeval, idx, obj);
|
||||
|
|
@ -571,8 +555,7 @@ static void* xworker_create(objmgr_t* mgr,
|
|||
w1 = obj_ref(w1, OBJREF_UPDATE);
|
||||
w1->host.attrs->hosttype = NULL;
|
||||
w1->host.attrs->hostmodel = NULL;
|
||||
zarray_init(&(w1->host.resvals), 64,
|
||||
kill_resval);
|
||||
zarray_init(&(w1->host.resvals), 64, kill_resval);
|
||||
}
|
||||
|
||||
DEREF_OBJ(w1->host.attrs->hosttype);
|
||||
|
|
@ -581,13 +564,15 @@ static void* xworker_create(objmgr_t* mgr,
|
|||
if (w->host.attrs) {
|
||||
memcpy(w1->host.attrs, w->host.attrs, sizeof(*(w1->host.attrs)));
|
||||
|
||||
w1->host.attrs->hosttype = create_obj_by_typename(mgr, "xstring",
|
||||
w->host.attrs->hosttype);
|
||||
w1->host.attrs->hostmodel = create_obj_by_typename(mgr, "xstring",
|
||||
w->host.attrs->hostmodel);
|
||||
w1->host.attrs->hosttype
|
||||
= create_obj_by_typename(mgr, "xstring", w->host.attrs->hosttype);
|
||||
w1->host.attrs->hostmodel
|
||||
= create_obj_by_typename(mgr, "xstring", w->host.attrs->hostmodel);
|
||||
} else {
|
||||
w1->host.attrs->hosttype = create_obj_by_typename(mgr, "xstring", "Unknown");
|
||||
w1->host.attrs->hostmodel = create_obj_by_typename(mgr, "xstring", "Unknown");
|
||||
w1->host.attrs->hosttype
|
||||
= create_obj_by_typename(mgr, "xstring", "Unknown");
|
||||
w1->host.attrs->hostmodel
|
||||
= create_obj_by_typename(mgr, "xstring", "Unknown");
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
|
|
@ -627,10 +612,7 @@ static void xworker_fini(void* p)
|
|||
return;
|
||||
}
|
||||
|
||||
static void xworker_type_fini(objtype_t* typeval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xworker_type_fini(objtype_t* typeval) { return; }
|
||||
|
||||
void queue_obj_killer(queue_t* q)
|
||||
{
|
||||
|
|
@ -712,9 +694,7 @@ void queue_obj_killer(queue_t* q)
|
|||
FREEUP(obj);
|
||||
}
|
||||
|
||||
static void* xqueue_create(objmgr_t* mgr,
|
||||
objtype_t* typeval,
|
||||
va_list ap)
|
||||
static void* xqueue_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
|
||||
{
|
||||
qmgr_t* qmgr = &(((cluster_t*)typeval->typedata)->qmgr);
|
||||
queue_t* q = va_arg(ap, queue_t*);
|
||||
|
|
@ -742,8 +722,7 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
}
|
||||
|
||||
q1 = MYOBJ_TO_OBJ(queue_t*, obj);
|
||||
q1->queue.queue = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.queue);
|
||||
q1->queue.queue = create_obj_by_typename(mgr, "xstring", q->queue.queue);
|
||||
if (q1->queue.queue == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -759,8 +738,8 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
q1->queue.post_exec = NULL;
|
||||
|
||||
if (q->queue.resreq != NULL) {
|
||||
q1->queue.resreq = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.resreq);
|
||||
q1->queue.resreq
|
||||
= create_obj_by_typename(mgr, "xstring", q->queue.resreq);
|
||||
if (q1->queue.resreq == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -769,8 +748,8 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
}
|
||||
|
||||
if (q->queue.pre_exec != NULL) {
|
||||
q1->queue.pre_exec = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.pre_exec);
|
||||
q1->queue.pre_exec
|
||||
= create_obj_by_typename(mgr, "xstring", q->queue.pre_exec);
|
||||
if (q1->queue.pre_exec == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -779,8 +758,8 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
}
|
||||
|
||||
if (q->queue.post_exec != NULL) {
|
||||
q1->queue.post_exec = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.post_exec);
|
||||
q1->queue.post_exec
|
||||
= create_obj_by_typename(mgr, "xstring", q->queue.post_exec);
|
||||
if (q1->queue.post_exec == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -807,11 +786,12 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
return NULL;
|
||||
}
|
||||
if (q->queue.users->name) {
|
||||
q1->queue.users->name = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.users->name);
|
||||
q1->queue.users->name
|
||||
= create_obj_by_typename(mgr, "xstring", q->queue.users->name);
|
||||
}
|
||||
q1->queue.users->members.count = q->queue.users->members.count;
|
||||
q1->queue.users->members.data = (char**)calloc(q1->queue.users->members.count, sizeof(char*));
|
||||
q1->queue.users->members.data
|
||||
= (char**)calloc(q1->queue.users->members.count, sizeof(char*));
|
||||
if (q1->queue.users->members.data == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -821,11 +801,12 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
if (q->queue.users->members.data[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
q1->queue.users->members.data[i] = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.users->members.data[i]);
|
||||
q1->queue.users->members.data[i] = create_obj_by_typename(
|
||||
mgr, "xstring", q->queue.users->members.data[i]);
|
||||
}
|
||||
q1->queue.users->ex_members.count = q->queue.users->ex_members.count;
|
||||
q1->queue.users->ex_members.data = (char**)calloc(q1->queue.users->ex_members.count, sizeof(char*));
|
||||
q1->queue.users->ex_members.data
|
||||
= (char**)calloc(q1->queue.users->ex_members.count, sizeof(char*));
|
||||
if (q1->queue.users->ex_members.data == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -835,8 +816,8 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
if (q->queue.users->ex_members.data[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
q1->queue.users->ex_members.data[i] = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.users->ex_members.data[i]);
|
||||
q1->queue.users->ex_members.data[i] = create_obj_by_typename(
|
||||
mgr, "xstring", q->queue.users->ex_members.data[i]);
|
||||
}
|
||||
}
|
||||
if (q->queue.hosts != NULL) {
|
||||
|
|
@ -847,11 +828,12 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
return NULL;
|
||||
}
|
||||
if (q->queue.hosts->name) {
|
||||
q1->queue.hosts->name = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.hosts->name);
|
||||
q1->queue.hosts->name
|
||||
= create_obj_by_typename(mgr, "xstring", q->queue.hosts->name);
|
||||
}
|
||||
q1->queue.hosts->members.count = q->queue.hosts->members.count;
|
||||
q1->queue.hosts->members.data = (char**)calloc(q1->queue.hosts->members.count, sizeof(char*));
|
||||
q1->queue.hosts->members.data
|
||||
= (char**)calloc(q1->queue.hosts->members.count, sizeof(char*));
|
||||
if (q1->queue.hosts->members.data == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -861,11 +843,12 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
if (q->queue.hosts->members.data[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
q1->queue.hosts->members.data[i] = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.hosts->members.data[i]);
|
||||
q1->queue.hosts->members.data[i] = create_obj_by_typename(
|
||||
mgr, "xstring", q->queue.hosts->members.data[i]);
|
||||
}
|
||||
q1->queue.hosts->ex_members.count = q->queue.hosts->ex_members.count;
|
||||
q1->queue.hosts->ex_members.data = (char**)calloc(q1->queue.hosts->ex_members.count, sizeof(char*));
|
||||
q1->queue.hosts->ex_members.data
|
||||
= (char**)calloc(q1->queue.hosts->ex_members.count, sizeof(char*));
|
||||
if (q1->queue.hosts->ex_members.data == NULL) {
|
||||
queue_obj_killer(q1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -875,19 +858,21 @@ static void* xqueue_create(objmgr_t* mgr,
|
|||
if (q->queue.hosts->ex_members.data[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
q1->queue.hosts->ex_members.data[i] = create_obj_by_typename(mgr, "xstring",
|
||||
q->queue.hosts->ex_members.data[i]);
|
||||
q1->queue.hosts->ex_members.data[i] = create_obj_by_typename(
|
||||
mgr, "xstring", q->queue.hosts->ex_members.data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
q1->queue.runwindow_config = NULL;
|
||||
if (q->queue.runwindow_config != NULL) {
|
||||
q1->queue.runwindow_config = dup_timewindow_config(q->queue.runwindow_config);
|
||||
q1->queue.runwindow_config
|
||||
= dup_timewindow_config(q->queue.runwindow_config);
|
||||
}
|
||||
|
||||
q1->queue.dispatchwindow_config = NULL;
|
||||
if (q->queue.dispatchwindow_config != NULL) {
|
||||
q1->queue.dispatchwindow_config = dup_timewindow_config(q->queue.dispatchwindow_config);
|
||||
q1->queue.dispatchwindow_config
|
||||
= dup_timewindow_config(q->queue.dispatchwindow_config);
|
||||
}
|
||||
|
||||
/* leave run windows parse & dispatch parse later */
|
||||
|
|
@ -920,25 +905,14 @@ static void xqueue_fini(void* p)
|
|||
|
||||
return;
|
||||
}
|
||||
static void xqueue_type_fini(objtype_t* typeval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xqueue_type_fini(objtype_t* typeval) { return; }
|
||||
|
||||
static void* xresval_create(objmgr_t* mgr,
|
||||
objtype_t* typeval,
|
||||
va_list ap)
|
||||
static void* xresval_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
static void xresval_fini(void* r)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xresval_type_fini(objtype_t* typeval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xresval_fini(void* r) { return; }
|
||||
static void xresval_type_fini(objtype_t* typeval) { return; }
|
||||
|
||||
void config_obj_killer(xce_config_t* c)
|
||||
{
|
||||
|
|
@ -955,9 +929,7 @@ void config_obj_killer(xce_config_t* c)
|
|||
FREEUP(obj);
|
||||
}
|
||||
|
||||
static void* xconfig_create(objmgr_t* mgr,
|
||||
objtype_t* typeval,
|
||||
va_list ap)
|
||||
static void* xconfig_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
|
||||
{
|
||||
cluster_t* c = (cluster_t*)typeval->typedata;
|
||||
xce_config_t* kv = va_arg(ap, xce_config_t*);
|
||||
|
|
@ -988,10 +960,8 @@ static void* xconfig_create(objmgr_t* mgr,
|
|||
}
|
||||
|
||||
kv1 = MYOBJ_TO_OBJ(xce_config_t*, obj);
|
||||
kv1->name = create_obj_by_typename(mgr, "xstring",
|
||||
kv->name);
|
||||
kv1->value = create_obj_by_typename(mgr, "xstring",
|
||||
kv->value);
|
||||
kv1->name = create_obj_by_typename(mgr, "xstring", kv->name);
|
||||
kv1->value = create_obj_by_typename(mgr, "xstring", kv->value);
|
||||
if ((kv1->name == NULL) || (kv1->value == NULL)) {
|
||||
config_obj_killer(kv1);
|
||||
SET_ERROR(ENOMEM);
|
||||
|
|
@ -1023,22 +993,11 @@ static void xconfig_fini(void* p)
|
|||
|
||||
return;
|
||||
}
|
||||
static void xconfig_type_fini(objtype_t* typeval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xconfig_type_fini(objtype_t* typeval) { return; }
|
||||
|
||||
static void* xgroup_create(objmgr_t* mgr,
|
||||
objtype_t* typeval,
|
||||
va_list ap)
|
||||
static void* xgroup_create(objmgr_t* mgr, objtype_t* typeval, va_list ap)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
static void xgroup_fini(void* g)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xgroup_type_fini(objtype_t* typeval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void xgroup_fini(void* g) { return; }
|
||||
static void xgroup_type_fini(objtype_t* typeval) { return; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue