reformat code and job array
This commit is contained in:
parent
a665ccd4fe
commit
9ff857db9f
64 changed files with 1497 additions and 2476 deletions
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
BasedOnStyle: webkit
|
||||
ColumnLimit: 80
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: Left
|
||||
AlignConsecutiveAssignments:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -22,60 +22,52 @@ typedef struct {
|
|||
char* key;
|
||||
} xce_client_config_t;
|
||||
|
||||
#define xcecli_jobfinish(ctx, finish) \
|
||||
xcecli_notify_jobfinish(ctx, finish)
|
||||
#define xcecli_jobfinish(ctx, finish) xcecli_notify_jobfinish(ctx, finish)
|
||||
|
||||
extern int xcecli_ctx_init(xcecli_ctx_t*, xce_client_config_t*);
|
||||
extern void xcecli_ctx_fini(xcecli_ctx_t);
|
||||
extern int xcecli_set_handler(xcecli_ctx_t, xce_request_handler_t);
|
||||
extern int xcecli_start(xcecli_ctx_t);
|
||||
extern int xcecli_stop(xcecli_ctx_t);
|
||||
extern int xcecli_wakeup(xcecli_ctx_t, int);
|
||||
extern int xcecli_hello(xcecli_ctx_t, char*);
|
||||
extern int xcecli_shutdown(xcecli_ctx_t);
|
||||
extern int xcecli_reslist(xcecli_ctx_t, xce_resource_t***);
|
||||
extern int xcecli_join(xcecli_ctx_t, int, hostattrs_t*);
|
||||
extern int xcecli_workerlist(xcecli_ctx_t, xce_worker_t***);
|
||||
extern int xcecli_jobdispatch(xcecli_ctx_t, xce_job_dispatch_t*);
|
||||
extern int xcecli_joblist(xcecli_ctx_t, xce_job_t***);
|
||||
extern int xcecli_clusterconf(xcecli_ctx_t, xce_clusterconf_t**);
|
||||
extern int xcecli_notify_jobfinish(xcecli_ctx_t, xce_jobfinish_t*);
|
||||
extern int xcecli_notify_jobstart(xcecli_ctx_t, job_pidinfo_t*);
|
||||
extern int xcecli_notify_jobfail(xcecli_ctx_t c, job_failinfo_t*);
|
||||
extern int xcecli_notify_jobstop(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_notify_jobresume(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_notify_jobpostdone(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_jobsubmit(xcecli_ctx_t, xce_job_submit_t*,
|
||||
uint64_t*);
|
||||
extern int xcecli_update_resvals(xcecli_ctx_t, int, xce_resval_t**);
|
||||
extern int xcecli_resval(xcecli_ctx_t, char*,
|
||||
char*, xce_resval_t***);
|
||||
extern int xcecli_update_jusage(xcecli_ctx_t, uint64_t, int, int*,
|
||||
int, int*, int, xce_rusage_t**);
|
||||
extern int xcecli_notify(xcecli_ctx_t, xce_notify_data_t*);
|
||||
extern int xcecli_jobctrl(xcecli_ctx_t, xce_jobctrl_t*);
|
||||
extern int xcecli_notify_jobchkpt(xcecli_ctx_t, uint64_t, char*);
|
||||
extern int xcecli_queuectrl(xcecli_ctx_t, xce_queuectrl_t*);
|
||||
extern int xcecli_runtask(xcecli_ctx_t, xce_taskrun_t*);
|
||||
extern int xcecli_notify_taskstart(xcecli_ctx_t, xce_task_pidinfo_t*);
|
||||
extern int xcecli_notify_taskfail(xcecli_ctx_t, xce_task_failinfo_t*);
|
||||
extern int xcecli_notify_taskfinish(xcecli_ctx_t, xce_task_finish_t*);
|
||||
extern int xcecli_ctx_init(xcecli_ctx_t*, xce_client_config_t*);
|
||||
extern void xcecli_ctx_fini(xcecli_ctx_t);
|
||||
extern int xcecli_set_handler(xcecli_ctx_t, xce_request_handler_t);
|
||||
extern int xcecli_start(xcecli_ctx_t);
|
||||
extern int xcecli_stop(xcecli_ctx_t);
|
||||
extern int xcecli_wakeup(xcecli_ctx_t, int);
|
||||
extern int xcecli_hello(xcecli_ctx_t, char*);
|
||||
extern int xcecli_shutdown(xcecli_ctx_t);
|
||||
extern int xcecli_reslist(xcecli_ctx_t, xce_resource_t***);
|
||||
extern int xcecli_join(xcecli_ctx_t, int, hostattrs_t*);
|
||||
extern int xcecli_workerlist(xcecli_ctx_t, xce_worker_t***);
|
||||
extern int xcecli_jobdispatch(xcecli_ctx_t, xce_job_dispatch_t*);
|
||||
extern int xcecli_joblist(xcecli_ctx_t, xce_job_t***);
|
||||
extern int xcecli_clusterconf(xcecli_ctx_t, xce_clusterconf_t**);
|
||||
extern int xcecli_notify_jobfinish(xcecli_ctx_t, xce_jobfinish_t*);
|
||||
extern int xcecli_notify_jobstart(xcecli_ctx_t, job_pidinfo_t*);
|
||||
extern int xcecli_notify_jobfail(xcecli_ctx_t c, job_failinfo_t*);
|
||||
extern int xcecli_notify_jobstop(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_notify_jobresume(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_notify_jobpostdone(xcecli_ctx_t, uint64_t);
|
||||
extern int xcecli_jobsubmit(xcecli_ctx_t, xce_job_submit_t*, uint64_t*);
|
||||
extern int xcecli_update_resvals(xcecli_ctx_t, int, xce_resval_t**);
|
||||
extern int xcecli_resval(xcecli_ctx_t, char*, char*, xce_resval_t***);
|
||||
extern int xcecli_update_jusage(xcecli_ctx_t, uint64_t, int, int*, int, int*,
|
||||
int, xce_rusage_t**);
|
||||
extern int xcecli_notify(xcecli_ctx_t, xce_notify_data_t*);
|
||||
extern int xcecli_jobctrl(xcecli_ctx_t, xce_jobctrl_t*);
|
||||
extern int xcecli_notify_jobchkpt(xcecli_ctx_t, uint64_t, char*);
|
||||
extern int xcecli_queuectrl(xcecli_ctx_t, xce_queuectrl_t*);
|
||||
extern int xcecli_runtask(xcecli_ctx_t, xce_taskrun_t*);
|
||||
extern int xcecli_notify_taskstart(xcecli_ctx_t, xce_task_pidinfo_t*);
|
||||
extern int xcecli_notify_taskfail(xcecli_ctx_t, xce_task_failinfo_t*);
|
||||
extern int xcecli_notify_taskfinish(xcecli_ctx_t, xce_task_finish_t*);
|
||||
extern endpoint_t* xcecli_get_my_endpoint(xcecli_ctx_t);
|
||||
extern xce_peerinfo_t* xcecli_get_myinfo(xcecli_ctx_t);
|
||||
extern void xcecli_block_tasks(xcecli_ctx_t);
|
||||
extern void xcecli_unblock_tasks(xcecli_ctx_t);
|
||||
|
||||
#define xcecli_free_ress(nres, ress) \
|
||||
xce_free_ress(nres, ress)
|
||||
#define xcecli_free_workers(nworkers, workers) \
|
||||
#define xcecli_free_ress(nres, ress) xce_free_ress(nres, ress)
|
||||
#define xcecli_free_workers(nworkers, workers) \
|
||||
xce_free_workers(nworkers, workers)
|
||||
#define xcecli_free_jobs(njobs, jobs) \
|
||||
xce_free_jobs(njobs, jobs)
|
||||
#define xcecli_free_queues(nqueues, queues) \
|
||||
xce_free_queues(nqueues, queues)
|
||||
#define xcecli_free_groups(ngroups, groups) \
|
||||
xce_free_groups(ngroups, groups)
|
||||
#define xcecli_free_clusterconf(conf) \
|
||||
xce_free_clusterconf(conf)
|
||||
#define xcecli_free_jobs(njobs, jobs) xce_free_jobs(njobs, jobs)
|
||||
#define xcecli_free_queues(nqueues, queues) xce_free_queues(nqueues, queues)
|
||||
#define xcecli_free_groups(ngroups, groups) xce_free_groups(ngroups, groups)
|
||||
#define xcecli_free_clusterconf(conf) xce_free_clusterconf(conf)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
#define _CONFIG_H_
|
||||
|
||||
#define BUG_EMAIL "rshen@shenrs.eu"
|
||||
#define DEFAULT_WORKDIR "/tmp/xce"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint64_t jobid_t;
|
||||
|
||||
#define BUG_EMAIL "rshen@shenrs.eu"
|
||||
#define DEFAULT_WORKDIR "/tmp/xce"
|
||||
|
||||
#define XCE_MAXNAME_LEN (64)
|
||||
#define XCE_MAXHOSTNAME_LEN (256) /* hostname suggest to 256 */
|
||||
|
|
@ -19,4 +23,34 @@
|
|||
#define XCE_MAXCMD_LEN (4096)
|
||||
#define XCE_MAX_ERRMSG_LEN (4096)
|
||||
|
||||
#define N_JOBID_BITS (sizeof(jobid_t) * 8)
|
||||
|
||||
#define N_CLUSTER_ID_BITS (6)
|
||||
#define CLUSTER_ID_SHIFT (N_JOBID_BITS - N_CLUSTER_ID_BITS)
|
||||
|
||||
#define N_APISERVER_ID_BITS (4)
|
||||
#define APISERVER_ID_SHIFT (CLUSTER_ID_SHIFT - N_APISERVER_ID_BITS)
|
||||
|
||||
#define N_TIMESTAMP_BITS (32)
|
||||
#define TIMESTAMP_SHIFT (APISERVER_ID_SHIFT - N_TIMESTAMP_BITS)
|
||||
|
||||
#define N_TAG_BITS (2)
|
||||
#define TAG_SHIFT (TIMESTAMP_SHIFT - N_TAG_BITS)
|
||||
|
||||
#define N_ARRAY_IDX_BITS (15)
|
||||
|
||||
#define TAG_JOB_ARRAY (0x01)
|
||||
|
||||
#define N_SEQENCE_BITS \
|
||||
(N_JOBID_BITS - N_CLUSTER_ID_BITS - N_APISERVER_ID_BITS - N_TIMESTAMP_BITS \
|
||||
- N_TAG_BITS)
|
||||
|
||||
#define SEQUENCE_HIGH_SHIFT (N_ARRAY_IDX_BITS)
|
||||
|
||||
#define UMAX_BITS(w) ((((uint64_t)0x01) << (int)w) - 1)
|
||||
|
||||
#define MAX_CLUSTER_ID (UMAX_BITS(N_CLUSTER_ID_BITS))
|
||||
#define MAX_APISERVER_ID (UMAX_BITS(N_APISERVER_ID_BITS))
|
||||
#define MAX_ARRAY_IDX (UMAX_BITS(N_ARRAY_IDX_BITS))
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ typedef struct {
|
|||
} hooksys_t;
|
||||
|
||||
extern int xce_hook_init(hooksys_t*, int);
|
||||
extern int xce_add_hook(hooksys_t*, int,
|
||||
hook_fn_t, void*);
|
||||
extern int xce_add_hook(hooksys_t*, int, hook_fn_t, void*);
|
||||
extern int xce_run_hooks(hooksys_t*, int, int, int, ...);
|
||||
extern void xce_hook_fini(hooksys_t*);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ typedef struct {
|
|||
extern hash_key_fn_t string_hash_key;
|
||||
extern hash_key_fn_t int_hash_key;
|
||||
|
||||
extern int ht_init(htab_t*, int,
|
||||
hash_key_fn_t);
|
||||
extern int ht_init(htab_t*, int, hash_key_fn_t);
|
||||
extern void ht_fini(htab_t*);
|
||||
extern hent_t* ht_get(htab_t*, void*);
|
||||
extern hent_t* ht_add(htab_t*, void*);
|
||||
|
|
|
|||
|
|
@ -13,10 +13,8 @@ typedef struct {
|
|||
zarray_t data;
|
||||
} kvmgr_t;
|
||||
|
||||
extern int kvmgr_init(kvmgr_t*, hash_key_fn_t,
|
||||
int, int,
|
||||
zarray_item_killer_t);
|
||||
extern void kvmgr_fini(kvmgr_t*);
|
||||
extern int kvmgr_init(kvmgr_t*, hash_key_fn_t, int, int, zarray_item_killer_t);
|
||||
extern void kvmgr_fini(kvmgr_t*);
|
||||
extern void* kvmgr_lock(kvmgr_t*, void*, int);
|
||||
extern int32_t kvmgr_add(kvmgr_t*, void*, void*);
|
||||
extern void kvmgr_del(kvmgr_t*, void*);
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
#define OBJ_MAGIC (0x4a424f58)
|
||||
|
||||
#define OBJREF_NOP (0) /* ref obj without lock, \
|
||||
#define OBJREF_NOP \
|
||||
(0) /* ref obj without lock, \
|
||||
* just keep object alive */
|
||||
#define OBJREF_READ (1) /* ref obj with read lock */
|
||||
#define OBJREF_UPDATE (2) /* ref obj with write lock */
|
||||
|
||||
typedef void* (*obj_create_fn_t)(void*, void*,
|
||||
va_list);
|
||||
typedef void* (*obj_create_fn_t)(void*, void*, va_list);
|
||||
typedef void (*obj_fini_fn_t)(void*);
|
||||
typedef void (*objtype_fini_fn_t)(void*);
|
||||
|
||||
|
|
@ -50,16 +50,14 @@ typedef struct {
|
|||
zarray_t types;
|
||||
} objmgr_t;
|
||||
|
||||
#define MYOBJ_TO_OBJ(type, myobj) \
|
||||
((type)(((char*)myobj) + sizeof(myobj_t)))
|
||||
#define MYOBJ_TO_OBJ(type, myobj) ((type)(((char*)myobj) + sizeof(myobj_t)))
|
||||
|
||||
#define TO_MYOBJ(obj) \
|
||||
((myobj_t*)(((char*)obj) - sizeof(myobj_t)))
|
||||
#define TO_MYOBJ(obj) ((myobj_t*)(((char*)obj) - sizeof(myobj_t)))
|
||||
|
||||
#define DEREF_OBJ(obj) \
|
||||
if ((obj) != NULL) { \
|
||||
obj_deref(obj); \
|
||||
(obj) = NULL; \
|
||||
#define DEREF_OBJ(obj) \
|
||||
if ((obj) != NULL) { \
|
||||
obj_deref(obj); \
|
||||
(obj) = NULL; \
|
||||
}
|
||||
|
||||
extern int objmgr_init(objmgr_t*);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ typedef struct {
|
|||
uint32_t nrefs;
|
||||
} ioctx_t;
|
||||
|
||||
#define ITPTR_TO_IOCTX(p) \
|
||||
((ioctx_t*)(((char*)p) - offsetof(ioctx_t, link)))
|
||||
#define ITPTR_TO_IOCTX(p) ((ioctx_t*)(((char*)p) - offsetof(ioctx_t, link)))
|
||||
|
||||
typedef int (*xce_check_fn_t)(void*);
|
||||
|
||||
|
|
@ -43,35 +42,29 @@ extern int xce_nop_req(ioctx_t*);
|
|||
extern int xce_shutdown_req(ioctx_t*);
|
||||
extern void init_reply_by_req(xce_reply_t*, xce_request_t*);
|
||||
extern int xce_join_req(ioctx_t*, int, hostattrs_t*);
|
||||
extern int xce_pushconfig_req(endpoint_t*,
|
||||
xce_peerinfo_t*,
|
||||
xce_configdata_t*);
|
||||
extern int xce_push_data_req(endpoint_t*, xce_peerinfo_t*,
|
||||
xce_data_t*, xce_check_fn_t,
|
||||
void*, int);
|
||||
extern int xce_pushconfig_req(endpoint_t*, xce_peerinfo_t*, xce_configdata_t*);
|
||||
extern int xce_push_data_req(endpoint_t*, xce_peerinfo_t*, xce_data_t*,
|
||||
xce_check_fn_t, void*, int);
|
||||
|
||||
extern int xce_workerlist_req(ioctx_t*, xce_peerinfo_t*);
|
||||
extern int xce_reply_workerlist(endpoint_t*, uint64_t, int,
|
||||
xce_peerinfo_t*, xce_workerlist_t*);
|
||||
extern int xce_reply_workerlist(endpoint_t*, uint64_t, int, xce_peerinfo_t*,
|
||||
xce_workerlist_t*);
|
||||
extern int xce_jobdispatch_req(ioctx_t*, xce_job_dispatch_t*);
|
||||
extern int xce_jobsubmit_req(ioctx_t*, xce_job_submit_t*);
|
||||
extern int xce_reply_jobdispatch(endpoint_t*, uint64_t, int32_t,
|
||||
xce_peerinfo_t*);
|
||||
extern int xce_reply_jobid(endpoint_t*, int,
|
||||
uint64_t, uint64_t,
|
||||
extern int xce_reply_jobid(endpoint_t*, int, uint64_t, uint64_t,
|
||||
xce_peerinfo_t*);
|
||||
extern int xce_joblist_req(ioctx_t*, xce_peerinfo_t*);
|
||||
extern int xce_reply_joblist(endpoint_t*, uint64_t, int,
|
||||
xce_peerinfo_t*, xce_job_list_t*);
|
||||
extern int xce_reply_joblist(endpoint_t*, uint64_t, int, xce_peerinfo_t*,
|
||||
xce_job_list_t*);
|
||||
extern int xce_startjob_req(ioctx_t*, xce_job_exec_t*);
|
||||
extern int xce_clusterconf_req(ioctx_t*);
|
||||
extern int xce_reply_clusterconf(endpoint_t*, uint64_t, int,
|
||||
xce_peerinfo_t*,
|
||||
extern int xce_reply_clusterconf(endpoint_t*, uint64_t, int, xce_peerinfo_t*,
|
||||
xce_clusterconf_t*);
|
||||
extern int xce_get_req(ioctx_t*, xce_get_t*);
|
||||
extern int xce_reply_get(endpoint_t*, xce_peerinfo_t*,
|
||||
xce_reply_t*, xce_check_fn_t,
|
||||
void*, int);
|
||||
extern int xce_reply_get(endpoint_t*, xce_peerinfo_t*, xce_reply_t*,
|
||||
xce_check_fn_t, void*, int);
|
||||
extern int xce_notify_req(ioctx_t*, xce_notify_data_t*);
|
||||
extern int extract_data(dataset_t*, xce_data_t*);
|
||||
extern int xce_update_req(ioctx_t*, xce_update_data_t*);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@
|
|||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
#define MAKE_JOBID(cluster, apiserver, timestamp, tag, sequence) \
|
||||
((((uint64_t)cluster) << CLUSTER_ID_SHIFT) \
|
||||
| (((uint64_t)apiserver) << APISERVER_ID_SHIFT) \
|
||||
| (((uint64_t)timestamp) << TIMESTAMP_SHIFT) \
|
||||
| (((uint64_t)tag) << TAG_SHIFT) | sequence)
|
||||
|
||||
#define xce_use(x) (void)(x)
|
||||
|
||||
#define float_near_zero (0.000001)
|
||||
|
|
@ -26,36 +32,31 @@
|
|||
#define MK_VERSION(ver, commit) ver commit
|
||||
|
||||
#ifndef FREEUP
|
||||
#define FREEUP(p) \
|
||||
if ((p) != NULL) { \
|
||||
free(p); \
|
||||
(p) = NULL; \
|
||||
#define FREEUP(p) \
|
||||
if ((p) != NULL) { \
|
||||
free(p); \
|
||||
(p) = NULL; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) \
|
||||
((void*)(((char*)p) + (delta)))
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) ((void*)(((char*)p) + (delta)))
|
||||
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) \
|
||||
((void*)(((char*)p) + (delta)))
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) ((void*)(((char*)p) + (delta)))
|
||||
|
||||
/* move the owner ship of pointer from src to dst */
|
||||
#define MOVE_PTR(dst, src) \
|
||||
do { \
|
||||
(dst) = (src); \
|
||||
(src) = NULL; \
|
||||
#define MOVE_PTR(dst, src) \
|
||||
do { \
|
||||
(dst) = (src); \
|
||||
(src) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define NULLSTR(p) (((p) == NULL) || (strlen(p) == 0))
|
||||
|
||||
#define SET_ERROR(code) \
|
||||
do { \
|
||||
set_error((char*)__FILE__, \
|
||||
(char*)__func__, \
|
||||
__LINE__, \
|
||||
(code)); \
|
||||
#define SET_ERROR(code) \
|
||||
do { \
|
||||
set_error((char*)__FILE__, (char*)__func__, __LINE__, (code)); \
|
||||
} while (0)
|
||||
|
||||
#define TRACE(...) tlog_debug3(__VA_ARGS__)
|
||||
|
|
@ -75,26 +76,26 @@ typedef struct {
|
|||
int code;
|
||||
} ectx_t;
|
||||
|
||||
extern capn_text chars_to_text(const char*);
|
||||
extern int parse_argv(char*, char***);
|
||||
extern void free_argv(char**, int);
|
||||
extern void freeup_kvs(int, xce_kv_t*);
|
||||
extern int mylog_init(char*, char*, int, int);
|
||||
extern void mylog_fini(void);
|
||||
extern int mylog_setlevel(char*);
|
||||
extern void set_error(char*, char*, int, int);
|
||||
extern ectx_t* get_ectx(void);
|
||||
extern int xce_vprintf(const char*, va_list);
|
||||
extern int xce_strerror_r(int, char*, size_t);
|
||||
extern void xce_perror(const char*);
|
||||
extern char* frame_symbol(int);
|
||||
extern int copy_int_list(int**, int*, int);
|
||||
extern int copy_strlist(xce_strlist_t*, xce_strlist_t);
|
||||
extern void free_timewindow_config(xce_timewindow_config_t*);
|
||||
extern int parse_argv(char*, char***);
|
||||
extern void free_argv(char**, int);
|
||||
extern int get_myname(char*, size_t);
|
||||
extern int mylog_init(char*, char*, int, int);
|
||||
extern void mylog_fini(void);
|
||||
extern int mylog_setlevel(char*);
|
||||
extern void set_error(char*, char*, int, int);
|
||||
extern ectx_t* get_ectx(void);
|
||||
extern int xce_vprintf(const char*, va_list);
|
||||
extern int xce_strerror_r(int, char*, size_t);
|
||||
extern void xce_perror(const char*);
|
||||
extern char* frame_symbol(int);
|
||||
extern int copy_int_list(int**, int*, int);
|
||||
extern int copy_strlist(xce_strlist_t*, xce_strlist_t);
|
||||
extern void free_timewindow_config(xce_timewindow_config_t*);
|
||||
extern xce_timewindow_config_t* dup_timewindow_config(xce_timewindow_config_t*);
|
||||
extern void free_resource_thresholds(xce_res_threshold_t**, int);
|
||||
extern xce_res_threshold_t** dup_resource_thresholds(xce_res_threshold_t**, int);
|
||||
extern void free_resval_with_idx_list(xce_val_with_idx_t***, int);
|
||||
extern void free_strlist(xce_strlist_t*);
|
||||
extern void free_resource_thresholds(xce_res_threshold_t**, int);
|
||||
extern xce_res_threshold_t** dup_resource_thresholds(xce_res_threshold_t**,
|
||||
int);
|
||||
extern void free_resval_with_idx_list(xce_val_with_idx_t***, int);
|
||||
extern void free_strlist(xce_strlist_t*);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ typedef struct {
|
|||
vtask_func_t entry;
|
||||
} vtask_t;
|
||||
|
||||
#define ITPTR_TO_VTASK(p) \
|
||||
#define ITPTR_TO_VTASK(p) \
|
||||
((vtask_t*)(((char*)p) - offsetof(ioctx_t, link) - offsetof(vtask_t, ctx)))
|
||||
|
||||
typedef enum {
|
||||
|
|
|
|||
|
|
@ -170,16 +170,12 @@ typedef struct {
|
|||
#define XCE_WORKER_BUSY (0x00080000)
|
||||
#define XCE_WORKER_CLOSED (0x00100000)
|
||||
|
||||
#define IS_WORKER_UNAVAIL(status) \
|
||||
(((status) & XCE_WORKER_UNAVAIL) != 0)
|
||||
#define IS_WORKER_LOCKEDU(status) \
|
||||
(((status) & XCE_WORKER_LOCKEDU) != 0)
|
||||
#define IS_WORKER_LOCKEDW(status) \
|
||||
(((status) & XCE_WORKER_LOCKEDW) != 0)
|
||||
#define IS_WORKER_LOCKED(status) \
|
||||
#define IS_WORKER_UNAVAIL(status) (((status) & XCE_WORKER_UNAVAIL) != 0)
|
||||
#define IS_WORKER_LOCKEDU(status) (((status) & XCE_WORKER_LOCKEDU) != 0)
|
||||
#define IS_WORKER_LOCKEDW(status) (((status) & XCE_WORKER_LOCKEDW) != 0)
|
||||
#define IS_WORKER_LOCKED(status) \
|
||||
(IS_WORKER_LOCKEDU(status) || IS_WORKER_LOCKEDW(status))
|
||||
#define IS_WORKER_BUSY(status) \
|
||||
(((status) & XCE_WORKER_BUSY) != 0)
|
||||
#define IS_WORKER_BUSY(status) (((status) & XCE_WORKER_BUSY) != 0)
|
||||
|
||||
typedef struct {
|
||||
char* hosttype;
|
||||
|
|
@ -303,25 +299,29 @@ typedef struct {
|
|||
int exitcode;
|
||||
} job_exitinfo_t;
|
||||
|
||||
#define JOB_STAT_NULL 0x00 /**< NULL. */
|
||||
#define JOB_STAT_PEND 0x01 /**< Job is submitted. */
|
||||
#define JOB_STAT_RUN 0x02 /**< Job is running. */
|
||||
#define JOB_STAT_EXIT 0x04 /**< Job is exit. */
|
||||
#define JOB_STAT_DONE 0x08 /**< Job is done. */
|
||||
#define JOB_STAT_PSUSP 0x10 /**< Job is pending and suspend*/
|
||||
#define JOB_STAT_USUSP 0x20 /**< Job is user suspend*/
|
||||
#define JOB_STAT_SSUSP 0x40 /**< Job is system suspend*/
|
||||
#define JOB_STAT_NULL 0x00 /**< NULL. */
|
||||
#define JOB_STAT_PEND 0x01 /**< Job is submitted. */
|
||||
#define JOB_STAT_RUN 0x02 /**< Job is running. */
|
||||
#define JOB_STAT_EXIT 0x04 /**< Job is exit. */
|
||||
#define JOB_STAT_DONE 0x08 /**< Job is done. */
|
||||
#define JOB_STAT_PSUSP 0x10 /**< Job is pending and suspend*/
|
||||
#define JOB_STAT_USUSP 0x20 /**< Job is user suspend*/
|
||||
#define JOB_STAT_SSUSP 0x40 /**< Job is system suspend*/
|
||||
|
||||
#define JOB_STAT_PDONE (0x80) /**< Post job process done successfully */
|
||||
#define JOB_STAT_PERR (0x100) /**< Post job process has error */
|
||||
#define JOB_STAT_WAIT (0x200) /**< Chunk job waiting its turn to exec */
|
||||
#define JOB_STAT_RUNKWN 0x8000 /* Flag : Job status is UNKWN caused by losting contact with remote cluster */
|
||||
#define JOB_STAT_UNKWN 0x10000 /**< The worker on the host on which the \
|
||||
* job is processed has lost contact with controller */
|
||||
#define JOB_STAT_PROV (0x20000) /**< this state shows that the job is dispatched to a standby \
|
||||
* power saved host, and this host is \
|
||||
* being waken up or started up */
|
||||
#define JOB_STAT_ERR (0x40000) /**ERROR */
|
||||
#define JOB_STAT_PDONE (0x80) /**< Post job process done successfully */
|
||||
#define JOB_STAT_PERR (0x100) /**< Post job process has error */
|
||||
#define JOB_STAT_WAIT (0x200) /**< Chunk job waiting its turn to exec */
|
||||
#define JOB_STAT_RUNKWN \
|
||||
0x8000 /* Flag : Job status is UNKWN caused by losting contact with remote \
|
||||
cluster */
|
||||
#define JOB_STAT_UNKWN \
|
||||
0x10000 /**< The worker on the host on which the \
|
||||
* job is processed has lost contact with controller */
|
||||
#define JOB_STAT_PROV \
|
||||
(0x20000) /**< this state shows that the job is dispatched to a standby \
|
||||
* power saved host, and this host is \
|
||||
* being waken up or started up */
|
||||
#define JOB_STAT_ERR (0x40000) /**ERROR */
|
||||
|
||||
#define JOB_EXEC_STAGE_Q_PRE_EXEC (0)
|
||||
#define JOB_EXEC_STAGE_PRE_EXEC (1)
|
||||
|
|
@ -329,13 +329,15 @@ typedef struct {
|
|||
#define JOB_EXEC_STAGE_POST_EXEC (3)
|
||||
#define JOB_EXEC_STAGE_Q_POST_EXEC (4)
|
||||
|
||||
#define QUEUE_STAT_OPEN 0x00 /**< OPEN. */
|
||||
#define QUEUE_STAT_CLOSED 0x01 /**< The queue is closed */
|
||||
#define QUEUE_STAT_INACT_WINDOW 0x02 /**< The queue inactivated due to dispatch or run windows closed */
|
||||
#define QUEUE_STAT_INACT_ADMIN 0x04 /**< The queue inactivated by admin */
|
||||
#define QUEUE_STAT_NOPERM 0x08 /**< Remote queue rejecting jobs. */
|
||||
#define QUEUE_STAT_DISC 0x10 /**< Remote queue status is disconnected. */
|
||||
#define QUEUE_STAT_FAIRSHARE_DEFAULT 0x20 /**< Fairshare queue with null user share defined*/
|
||||
#define QUEUE_STAT_OPEN 0x00 /**< OPEN. */
|
||||
#define QUEUE_STAT_CLOSED 0x01 /**< The queue is closed */
|
||||
#define QUEUE_STAT_INACT_WINDOW \
|
||||
0x02 /**< The queue inactivated due to dispatch or run windows closed */
|
||||
#define QUEUE_STAT_INACT_ADMIN 0x04 /**< The queue inactivated by admin */
|
||||
#define QUEUE_STAT_NOPERM 0x08 /**< Remote queue rejecting jobs. */
|
||||
#define QUEUE_STAT_DISC 0x10 /**< Remote queue status is disconnected. */
|
||||
#define QUEUE_STAT_FAIRSHARE_DEFAULT \
|
||||
0x20 /**< Fairshare queue with null user share defined*/
|
||||
|
||||
typedef enum {
|
||||
NORMAL = 0,
|
||||
|
|
|
|||
|
|
@ -13,22 +13,19 @@ extern int xce_reslist(xce_ctx_t*, xce_resource_t***);
|
|||
extern int xce_join(xce_ctx_t*, int, hostattrs_t*);
|
||||
extern int xce_workerlist(xce_ctx_t*, xce_worker_t***);
|
||||
extern int xce_jobdispatch(xce_ctx_t*, xce_job_dispatch_t*);
|
||||
extern int xce_jobsubmit(xce_ctx_t*, xce_job_submit_t*,
|
||||
uint64_t*);
|
||||
extern int xce_jobsubmit(xce_ctx_t*, xce_job_submit_t*, uint64_t*);
|
||||
extern int xce_joblist(xce_ctx_t*, xce_job_t***);
|
||||
extern int xce_clusterconf(xce_ctx_t*, xce_clusterconf_t**);
|
||||
extern int xce_push(xce_ctx_t*, xce_check_fn_t,
|
||||
void*, int, int, int, void**);
|
||||
extern int xce_push(xce_ctx_t*, xce_check_fn_t, void*, int, int, int, void**);
|
||||
extern int xce_update_rows(xce_ctx_t*, int, int, xlist_t*);
|
||||
extern int xce_resval(xce_ctx_t*, char*,
|
||||
char*, xce_resval_t***);
|
||||
extern int xce_resval(xce_ctx_t*, char*, char*, xce_resval_t***);
|
||||
|
||||
extern int xce_notify(xce_ctx_t*, xce_notify_data_t*);
|
||||
extern int xce_update_resvals(xce_ctx_t*, int, xce_resval_t**);
|
||||
extern int xce_jobctrl(xce_ctx_t*, xce_jobctrl_t*);
|
||||
extern int xce_queuectrl(xce_ctx_t*, xce_queuectrl_t*);
|
||||
extern int xce_runtask(xce_ctx_t*, xce_taskrun_t*);
|
||||
extern int xce_update_jusage(xce_ctx_t*, uint64_t, int,
|
||||
int*, int, int*, int, xce_rusage_t**);
|
||||
extern int xce_update_jusage(xce_ctx_t*, uint64_t, int, int*, int, int*, int,
|
||||
xce_rusage_t**);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ typedef struct {
|
|||
|
||||
extern int xce_ctx_init(xce_ctx_t*, char*, char*);
|
||||
extern void xce_ctx_fini(xce_ctx_t*);
|
||||
extern int xce_ctx_set_handler(xce_ctx_t*,
|
||||
xce_request_handler_t);
|
||||
extern int xce_ctx_set_handler(xce_ctx_t*, xce_request_handler_t);
|
||||
extern int xce_ctx_start(xce_ctx_t*);
|
||||
extern int xce_ctx_stop(xce_ctx_t*);
|
||||
extern int xce_wakeup(xce_ctx_t*, int);
|
||||
|
|
|
|||
|
|
@ -9,15 +9,14 @@ typedef struct {
|
|||
zarray_t strings;
|
||||
} xstring_typedata_t;
|
||||
|
||||
#define XSTRING_OBJ_TYPE_HTAB(obj) \
|
||||
#define XSTRING_OBJ_TYPE_HTAB(obj) \
|
||||
(((xstring_typedata_t*)obj->type->typedata)->tab)
|
||||
#define XSTRING_OBJ_TYPE_STRINGS(obj) \
|
||||
#define XSTRING_OBJ_TYPE_STRINGS(obj) \
|
||||
(((xstring_typedata_t*)obj->type->typedata)->strings)
|
||||
|
||||
#define XSTRING_TYPE_HTAB(type) \
|
||||
(((xstring_typedata_t*)type->typedata)->tab)
|
||||
#define XSTRING_TYPE_HTAB(type) (((xstring_typedata_t*)type->typedata)->tab)
|
||||
|
||||
#define XSTRING_TYPE_STRINGS(type) \
|
||||
#define XSTRING_TYPE_STRINGS(type) \
|
||||
(((xstring_typedata_t*)type->typedata)->strings)
|
||||
|
||||
extern int register_xstring(objmgr_t*, int, int);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ typedef struct {
|
|||
void** data;
|
||||
} zarray_t;
|
||||
|
||||
extern int zarray_init(zarray_t*, int,
|
||||
zarray_item_killer_t);
|
||||
extern int zarray_init(zarray_t*, int, zarray_item_killer_t);
|
||||
extern int zarray_store(zarray_t*, void*);
|
||||
extern int zarray_clear(zarray_t*, int);
|
||||
extern int zarray_iter_ex(zarray_t*, xlist_t*, void*);
|
||||
|
|
|
|||
112
src/lib/client.c
112
src/lib/client.c
|
|
@ -26,8 +26,7 @@ typedef struct {
|
|||
xce_ctx_t ctx;
|
||||
} api_ctx_t;
|
||||
|
||||
int xcecli_ctx_init(xcecli_ctx_t* c,
|
||||
xce_client_config_t* cfg)
|
||||
int xcecli_ctx_init(xcecli_ctx_t* c, xce_client_config_t* cfg)
|
||||
{
|
||||
api_ctx_t* ctx;
|
||||
int rc;
|
||||
|
|
@ -46,16 +45,13 @@ int xcecli_ctx_init(xcecli_ctx_t* c,
|
|||
}
|
||||
|
||||
ctx->conf = cfg;
|
||||
rc = xce_ctx_init(&(ctx->ctx),
|
||||
ctx->conf->from,
|
||||
ctx->conf->key);
|
||||
rc = xce_ctx_init(&(ctx->ctx), ctx->conf->from, ctx->conf->key);
|
||||
if (rc < 0) {
|
||||
free(ctx);
|
||||
return rc;
|
||||
}
|
||||
|
||||
endpoint_init(&(ctx->ep), AF_INET,
|
||||
SOCK_STREAM, 0, 0);
|
||||
endpoint_init(&(ctx->ep), AF_INET, SOCK_STREAM, 0, 0);
|
||||
|
||||
xce_ctx_set_endpoint(&(ctx->ctx), &(ctx->ep));
|
||||
|
||||
|
|
@ -77,8 +73,7 @@ void xcecli_ctx_fini(xcecli_ctx_t c)
|
|||
free(ctx);
|
||||
}
|
||||
|
||||
int xcecli_set_handler(xcecli_ctx_t c,
|
||||
xce_request_handler_t handler)
|
||||
int xcecli_set_handler(xcecli_ctx_t c, xce_request_handler_t handler)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -89,8 +84,7 @@ int xcecli_set_handler(xcecli_ctx_t c,
|
|||
return xce_ctx_set_handler(&(ctx->ctx), handler);
|
||||
}
|
||||
|
||||
int xcecli_wakeup(xcecli_ctx_t c,
|
||||
int status)
|
||||
int xcecli_wakeup(xcecli_ctx_t c, int status)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -101,8 +95,7 @@ int xcecli_wakeup(xcecli_ctx_t c,
|
|||
return xce_wakeup(&(ctx->ctx), status);
|
||||
}
|
||||
|
||||
int xcecli_try_wakeup(xcecli_ctx_t c,
|
||||
int status)
|
||||
int xcecli_try_wakeup(xcecli_ctx_t c, int status)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -122,8 +115,7 @@ int xcecli_start(xcecli_ctx_t c)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = endpoint_connect(&(ctx->ep),
|
||||
ctx->conf->masters[0],
|
||||
rc = endpoint_connect(&(ctx->ep), ctx->conf->masters[0],
|
||||
ctx->conf->master_ports[0]);
|
||||
if (rc < 0) {
|
||||
endpoint_deref(&(ctx->ep));
|
||||
|
|
@ -169,8 +161,7 @@ xce_peerinfo_t* xcecli_get_myinfo(xcecli_ctx_t c)
|
|||
return &(ctx->ctx.myinfo);
|
||||
}
|
||||
|
||||
int xcecli_hello(xcecli_ctx_t c,
|
||||
char* msg)
|
||||
int xcecli_hello(xcecli_ctx_t c, char* msg)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -192,8 +183,7 @@ int xcecli_shutdown(xcecli_ctx_t c)
|
|||
return xce_shutdown(&(ctx->ctx));
|
||||
}
|
||||
|
||||
int xcecli_reslist(xcecli_ctx_t c,
|
||||
xce_resource_t*** res)
|
||||
int xcecli_reslist(xcecli_ctx_t c, xce_resource_t*** res)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -204,9 +194,7 @@ int xcecli_reslist(xcecli_ctx_t c,
|
|||
return xce_reslist(&(ctx->ctx), res);
|
||||
}
|
||||
|
||||
int xcecli_join(xcecli_ctx_t c,
|
||||
int role,
|
||||
hostattrs_t* attrs)
|
||||
int xcecli_join(xcecli_ctx_t c, int role, hostattrs_t* attrs)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
if (ctx == NULL) {
|
||||
|
|
@ -216,8 +204,7 @@ int xcecli_join(xcecli_ctx_t c,
|
|||
return xce_join(&(ctx->ctx), role, attrs);
|
||||
}
|
||||
|
||||
int xcecli_workerlist(xcecli_ctx_t c,
|
||||
xce_worker_t*** workers)
|
||||
int xcecli_workerlist(xcecli_ctx_t c, xce_worker_t*** workers)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
if (ctx == NULL) {
|
||||
|
|
@ -227,8 +214,7 @@ int xcecli_workerlist(xcecli_ctx_t c,
|
|||
return xce_workerlist(&(ctx->ctx), workers);
|
||||
}
|
||||
|
||||
int xcecli_jobdispatch(xcecli_ctx_t c,
|
||||
xce_job_dispatch_t* info)
|
||||
int xcecli_jobdispatch(xcecli_ctx_t c, xce_job_dispatch_t* info)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -239,9 +225,7 @@ int xcecli_jobdispatch(xcecli_ctx_t c,
|
|||
return xce_jobdispatch(&(ctx->ctx), info);
|
||||
}
|
||||
|
||||
int xcecli_jobsubmit(xcecli_ctx_t c,
|
||||
xce_job_submit_t* submit,
|
||||
uint64_t* jobid)
|
||||
int xcecli_jobsubmit(xcecli_ctx_t c, xce_job_submit_t* submit, uint64_t* jobid)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -252,8 +236,7 @@ int xcecli_jobsubmit(xcecli_ctx_t c,
|
|||
return xce_jobsubmit(&(ctx->ctx), submit, jobid);
|
||||
}
|
||||
|
||||
int xcecli_joblist(xcecli_ctx_t c,
|
||||
xce_job_t*** jobs)
|
||||
int xcecli_joblist(xcecli_ctx_t c, xce_job_t*** jobs)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -264,8 +247,7 @@ int xcecli_joblist(xcecli_ctx_t c,
|
|||
return xce_joblist(&(ctx->ctx), jobs);
|
||||
}
|
||||
|
||||
int xcecli_clusterconf(xcecli_ctx_t c,
|
||||
xce_clusterconf_t** conf)
|
||||
int xcecli_clusterconf(xcecli_ctx_t c, xce_clusterconf_t** conf)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -276,8 +258,7 @@ int xcecli_clusterconf(xcecli_ctx_t c,
|
|||
return xce_clusterconf(&(ctx->ctx), conf);
|
||||
}
|
||||
|
||||
int xcecli_notify_jobfinish(xcecli_ctx_t c,
|
||||
xce_jobfinish_t* jfinish)
|
||||
int xcecli_notify_jobfinish(xcecli_ctx_t c, xce_jobfinish_t* jfinish)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -300,9 +281,7 @@ int xcecli_notify_jobfinish(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_update_resvals(xcecli_ctx_t c,
|
||||
int nres,
|
||||
xce_resval_t** vals)
|
||||
int xcecli_update_resvals(xcecli_ctx_t c, int nres, xce_resval_t** vals)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
int rc;
|
||||
|
|
@ -316,13 +295,8 @@ int xcecli_update_resvals(xcecli_ctx_t c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xcecli_update_jusage(xcecli_ctx_t c,
|
||||
uint64_t jobid,
|
||||
int npids,
|
||||
int* pids,
|
||||
int npgids,
|
||||
int* pgids,
|
||||
int nusage,
|
||||
int xcecli_update_jusage(xcecli_ctx_t c, uint64_t jobid, int npids, int* pids,
|
||||
int npgids, int* pgids, int nusage,
|
||||
xce_rusage_t** usages)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
|
@ -332,17 +306,13 @@ int xcecli_update_jusage(xcecli_ctx_t c,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = xce_update_jusage(&(ctx->ctx), jobid,
|
||||
npids, pids, npgids, pgids,
|
||||
rc = xce_update_jusage(&(ctx->ctx), jobid, npids, pids, npgids, pgids,
|
||||
nusage, usages);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int xcecli_resval(xcecli_ctx_t c,
|
||||
char* host,
|
||||
char* res,
|
||||
xce_resval_t*** val)
|
||||
int xcecli_resval(xcecli_ctx_t c, char* host, char* res, xce_resval_t*** val)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -357,8 +327,7 @@ int xcecli_resval(xcecli_ctx_t c,
|
|||
return xce_resval(&(ctx->ctx), host, res, val);
|
||||
}
|
||||
|
||||
int xcecli_notify(xcecli_ctx_t c,
|
||||
xce_notify_data_t* data)
|
||||
int xcecli_notify(xcecli_ctx_t c, xce_notify_data_t* data)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -373,8 +342,7 @@ int xcecli_notify(xcecli_ctx_t c,
|
|||
return xce_notify(&(ctx->ctx), data);
|
||||
}
|
||||
|
||||
int xcecli_notify_jobstart(xcecli_ctx_t c,
|
||||
job_pidinfo_t* pidinfo)
|
||||
int xcecli_notify_jobstart(xcecli_ctx_t c, job_pidinfo_t* pidinfo)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -393,8 +361,7 @@ int xcecli_notify_jobstart(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_notify_jobfail(xcecli_ctx_t c,
|
||||
job_failinfo_t* failinfo)
|
||||
int xcecli_notify_jobfail(xcecli_ctx_t c, job_failinfo_t* failinfo)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -413,8 +380,7 @@ int xcecli_notify_jobfail(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_jobctrl(xcecli_ctx_t c,
|
||||
xce_jobctrl_t* ctrlinfo)
|
||||
int xcecli_jobctrl(xcecli_ctx_t c, xce_jobctrl_t* ctrlinfo)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
int rc;
|
||||
|
|
@ -428,8 +394,7 @@ int xcecli_jobctrl(xcecli_ctx_t c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xcecli_notify_jobstop(xcecli_ctx_t c,
|
||||
uint64_t jobid)
|
||||
int xcecli_notify_jobstop(xcecli_ctx_t c, uint64_t jobid)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -448,8 +413,7 @@ int xcecli_notify_jobstop(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_notify_jobresume(xcecli_ctx_t c,
|
||||
uint64_t jobid)
|
||||
int xcecli_notify_jobresume(xcecli_ctx_t c, uint64_t jobid)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -468,9 +432,7 @@ int xcecli_notify_jobresume(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_notify_jobchkpt(xcecli_ctx_t c,
|
||||
uint64_t jobid,
|
||||
char* info)
|
||||
int xcecli_notify_jobchkpt(xcecli_ctx_t c, uint64_t jobid, char* info)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -493,8 +455,7 @@ int xcecli_notify_jobchkpt(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_notify_jobpostdone(xcecli_ctx_t c,
|
||||
uint64_t jobid)
|
||||
int xcecli_notify_jobpostdone(xcecli_ctx_t c, uint64_t jobid)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -513,8 +474,7 @@ int xcecli_notify_jobpostdone(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_queuectrl(xcecli_ctx_t c,
|
||||
xce_queuectrl_t* ctrlinfo)
|
||||
int xcecli_queuectrl(xcecli_ctx_t c, xce_queuectrl_t* ctrlinfo)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
int rc;
|
||||
|
|
@ -528,8 +488,7 @@ int xcecli_queuectrl(xcecli_ctx_t c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xcecli_runtask(xcecli_ctx_t c,
|
||||
xce_taskrun_t* info)
|
||||
int xcecli_runtask(xcecli_ctx_t c, xce_taskrun_t* info)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
int rc;
|
||||
|
|
@ -547,8 +506,7 @@ int xcecli_runtask(xcecli_ctx_t c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xcecli_notify_taskstart(xcecli_ctx_t c,
|
||||
xce_task_pidinfo_t* pidinfo)
|
||||
int xcecli_notify_taskstart(xcecli_ctx_t c, xce_task_pidinfo_t* pidinfo)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -567,8 +525,7 @@ int xcecli_notify_taskstart(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_notify_taskfail(xcecli_ctx_t c,
|
||||
xce_task_failinfo_t* failinfo)
|
||||
int xcecli_notify_taskfail(xcecli_ctx_t c, xce_task_failinfo_t* failinfo)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
@ -587,8 +544,7 @@ int xcecli_notify_taskfail(xcecli_ctx_t c,
|
|||
return xcecli_notify(ctx, &data);
|
||||
}
|
||||
|
||||
int xcecli_notify_taskfinish(xcecli_ctx_t c,
|
||||
xce_task_finish_t* info)
|
||||
int xcecli_notify_taskfinish(xcecli_ctx_t c, xce_task_finish_t* info)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
/* clang-format off */
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
#include "dataq.h"
|
||||
|
||||
int dataq_init(dataq_t* q,
|
||||
data_item_killer_t killer)
|
||||
int dataq_init(dataq_t* q, data_item_killer_t killer)
|
||||
{
|
||||
q->head = q->tail = NULL;
|
||||
q->killer = killer;
|
||||
|
|
@ -28,8 +27,7 @@ static data_item_t* dataq_deq_head(dataq_t* q)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static data_item_t* dataq_deq_first_match(dataq_t* q,
|
||||
data_item_match_fn_t f)
|
||||
static data_item_t* dataq_deq_first_match(dataq_t* q, data_item_match_fn_t f)
|
||||
{
|
||||
data_item_t* prev = NULL;
|
||||
data_item_t* curr = q->head;
|
||||
|
|
@ -64,8 +62,7 @@ static data_item_t* dataq_deq_first_match(dataq_t* q,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
data_item_t* dataq_deq(dataq_t* q,
|
||||
data_item_match_fn_t f)
|
||||
data_item_t* dataq_deq(dataq_t* q, data_item_match_fn_t f)
|
||||
{
|
||||
data_item_t* b = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
#include "hook.h"
|
||||
#include "utils.h"
|
||||
|
||||
int xce_hook_init(hooksys_t* s,
|
||||
int maxtypes)
|
||||
int xce_hook_init(hooksys_t* s, int maxtypes)
|
||||
{
|
||||
int i;
|
||||
if ((s == NULL) || (maxtypes <= 0)) {
|
||||
|
|
@ -26,10 +25,7 @@ int xce_hook_init(hooksys_t* s,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_add_hook(hooksys_t* s,
|
||||
int typ,
|
||||
hook_fn_t fn,
|
||||
void* data)
|
||||
int xce_add_hook(hooksys_t* s, int typ, hook_fn_t fn, void* data)
|
||||
{
|
||||
hook_item_t* it;
|
||||
|
||||
|
|
@ -62,11 +58,7 @@ int xce_add_hook(hooksys_t* s,
|
|||
* negative value will cause
|
||||
* fail
|
||||
*/
|
||||
int xce_run_hooks(hooksys_t* s,
|
||||
int type,
|
||||
int situation,
|
||||
int detail,
|
||||
...)
|
||||
int xce_run_hooks(hooksys_t* s, int type, int situation, int detail, ...)
|
||||
{
|
||||
xlist_t* l;
|
||||
int i;
|
||||
|
|
@ -91,8 +83,7 @@ int xce_run_hooks(hooksys_t* s,
|
|||
}
|
||||
|
||||
va_start(ap, detail);
|
||||
rc = (*(it->fn))(type, situation, detail,
|
||||
it->data, ap);
|
||||
rc = (*(it->fn))(type, situation, detail, it->data, ap);
|
||||
va_end(ap);
|
||||
|
||||
if ((situation == HOOK_BEFORE_EVENT) && (rc < 0)) {
|
||||
|
|
@ -103,8 +94,7 @@ int xce_run_hooks(hooksys_t* s,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int free_hook_item(void* data1,
|
||||
void* data2)
|
||||
static int free_hook_item(void* data1, void* data2)
|
||||
{
|
||||
if (data1 == NULL) {
|
||||
return -EINVAL;
|
||||
|
|
@ -127,9 +117,7 @@ void xce_hook_fini(hooksys_t* s)
|
|||
}
|
||||
|
||||
for (i = 0; i < s->maxtypes; i++) {
|
||||
xlist_iter(&(s->hooks[i]),
|
||||
(xlist_iter_fn_t)free_hook_item,
|
||||
NULL);
|
||||
xlist_iter(&(s->hooks[i]), (xlist_iter_fn_t)free_hook_item, NULL);
|
||||
xlist_fini(&(s->hooks[i]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,20 +5,20 @@
|
|||
#include "htab.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define HASH_KEY_HASH(t, key) \
|
||||
#define HASH_KEY_HASH(t, key) \
|
||||
(((t)->fn.hash != NULL) ? ((t)->fn.hash)(key) : (unsigned long)key)
|
||||
|
||||
#define HASH_KEY_CMP(t, k1, k2) \
|
||||
#define HASH_KEY_CMP(t, k1, k2) \
|
||||
(((t)->fn.cmp != NULL) ? ((t)->fn.cmp)((k1), (k2)) : ((k1) != (k2)))
|
||||
|
||||
#define HASH_KEY_COPY(t, key) \
|
||||
#define HASH_KEY_COPY(t, key) \
|
||||
(((t)->fn.copy != NULL) ? ((t)->fn.copy)(key) : (key))
|
||||
|
||||
#define HASH_KEY_FREE(t, key) \
|
||||
do { \
|
||||
if (((t)->fn.free != NULL) && ((key) != NULL)) { \
|
||||
(t)->fn.free(key); \
|
||||
} \
|
||||
#define HASH_KEY_FREE(t, key) \
|
||||
do { \
|
||||
if (((t)->fn.free != NULL) && ((key) != NULL)) { \
|
||||
(t)->fn.free(key); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static unsigned int hash_code(const char* key)
|
||||
|
|
@ -38,16 +38,12 @@ static unsigned int string_hash(void* data)
|
|||
return hash_code((const char*)data);
|
||||
}
|
||||
|
||||
static int string_cmp(void* d1,
|
||||
void* d2)
|
||||
static int string_cmp(void* d1, void* d2)
|
||||
{
|
||||
return (int)strcmp((char*)d1, (char*)d2);
|
||||
}
|
||||
|
||||
static void* string_dup(void* data)
|
||||
{
|
||||
return (void*)strdup((char*)data);
|
||||
}
|
||||
static void* string_dup(void* data) { return (void*)strdup((char*)data); }
|
||||
|
||||
static void string_free(void* data)
|
||||
{
|
||||
|
|
@ -56,23 +52,15 @@ static void string_free(void* data)
|
|||
}
|
||||
}
|
||||
|
||||
hash_key_fn_t string_hash_key = {
|
||||
.hash = (hash_key_hash_fn_t)string_hash,
|
||||
.cmp = (hash_key_cmp_fn_t)string_cmp,
|
||||
.copy = (hash_key_copy_fn_t)string_dup,
|
||||
.free = (hash_key_free_fn_t)string_free
|
||||
};
|
||||
hash_key_fn_t string_hash_key = { .hash = (hash_key_hash_fn_t)string_hash,
|
||||
.cmp = (hash_key_cmp_fn_t)string_cmp,
|
||||
.copy = (hash_key_copy_fn_t)string_dup,
|
||||
.free = (hash_key_free_fn_t)string_free };
|
||||
|
||||
hash_key_fn_t int_hash_key = {
|
||||
.hash = NULL,
|
||||
.cmp = NULL,
|
||||
.copy = NULL,
|
||||
.free = NULL
|
||||
};
|
||||
hash_key_fn_t int_hash_key
|
||||
= { .hash = NULL, .cmp = NULL, .copy = NULL, .free = NULL };
|
||||
|
||||
int ht_init(htab_t* t,
|
||||
int nslots,
|
||||
hash_key_fn_t fn)
|
||||
int ht_init(htab_t* t, int nslots, hash_key_fn_t fn)
|
||||
{
|
||||
if ((t == NULL) || (nslots <= 1)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -112,8 +100,7 @@ void ht_fini(htab_t* t)
|
|||
return;
|
||||
}
|
||||
|
||||
hent_t* ht_get(htab_t* t,
|
||||
void* key)
|
||||
hent_t* ht_get(htab_t* t, void* key)
|
||||
{
|
||||
unsigned int hc;
|
||||
hent_t* e;
|
||||
|
|
@ -140,8 +127,7 @@ hent_t* ht_get(htab_t* t,
|
|||
return e;
|
||||
}
|
||||
|
||||
hent_t* ht_add(htab_t* t,
|
||||
void* key)
|
||||
hent_t* ht_add(htab_t* t, void* key)
|
||||
{
|
||||
unsigned int hc;
|
||||
hent_t* e;
|
||||
|
|
@ -177,8 +163,7 @@ hent_t* ht_add(htab_t* t,
|
|||
return e;
|
||||
}
|
||||
|
||||
int ht_del(htab_t* t,
|
||||
void* key)
|
||||
int ht_del(htab_t* t, void* key)
|
||||
{
|
||||
unsigned int hc;
|
||||
hent_t** e;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,7 @@
|
|||
#include "xce/types.h"
|
||||
#include "zarray.h"
|
||||
|
||||
int kvmgr_init(kvmgr_t* mgr,
|
||||
hash_key_fn_t keyfn,
|
||||
int nslots,
|
||||
int delta,
|
||||
int kvmgr_init(kvmgr_t* mgr, hash_key_fn_t keyfn, int nslots, int delta,
|
||||
zarray_item_killer_t killer)
|
||||
{
|
||||
ht_init(&(mgr->htab), nslots, keyfn);
|
||||
|
|
@ -28,9 +25,7 @@ void kvmgr_fini(kvmgr_t* mgr)
|
|||
mylock_fini(&(mgr->lock));
|
||||
}
|
||||
|
||||
static void* kvmgr_lock_(kvmgr_t* mgr,
|
||||
void* key,
|
||||
int op)
|
||||
static void* kvmgr_lock_(kvmgr_t* mgr, void* key, int op)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int32_t idx;
|
||||
|
|
@ -53,9 +48,7 @@ static void* kvmgr_lock_(kvmgr_t* mgr,
|
|||
return obj_ref(ptr, op);
|
||||
}
|
||||
|
||||
void* kvmgr_lock(kvmgr_t* mgr,
|
||||
void* key,
|
||||
int op)
|
||||
void* kvmgr_lock(kvmgr_t* mgr, void* key, int op)
|
||||
{
|
||||
void* ptr = NULL;
|
||||
|
||||
|
|
@ -80,9 +73,7 @@ void* kvmgr_lock(kvmgr_t* mgr,
|
|||
return ptr;
|
||||
}
|
||||
|
||||
static int32_t kvmgr_add_(kvmgr_t* mgr,
|
||||
void* key,
|
||||
void* p)
|
||||
static int32_t kvmgr_add_(kvmgr_t* mgr, void* key, void* p)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -97,8 +88,7 @@ static int32_t kvmgr_add_(kvmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
e = ht_add(&(mgr->htab),
|
||||
(void*)key);
|
||||
e = ht_add(&(mgr->htab), (void*)key);
|
||||
if (e == NULL) {
|
||||
zarray_del(&(mgr->data), idx);
|
||||
return -errno;
|
||||
|
|
@ -108,9 +98,7 @@ static int32_t kvmgr_add_(kvmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
int32_t kvmgr_add(kvmgr_t* mgr,
|
||||
void* key,
|
||||
void* p)
|
||||
int32_t kvmgr_add(kvmgr_t* mgr, void* key, void* p)
|
||||
{
|
||||
int32_t idx;
|
||||
|
||||
|
|
@ -125,8 +113,7 @@ int32_t kvmgr_add(kvmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
static void kvmgr_del_(kvmgr_t* mgr,
|
||||
void* key)
|
||||
static void kvmgr_del_(kvmgr_t* mgr, void* key)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -146,8 +133,7 @@ static void kvmgr_del_(kvmgr_t* mgr,
|
|||
return;
|
||||
}
|
||||
|
||||
void kvmgr_del(kvmgr_t* mgr,
|
||||
void* key)
|
||||
void kvmgr_del(kvmgr_t* mgr, void* key)
|
||||
{
|
||||
if (mgr == NULL) {
|
||||
return;
|
||||
|
|
@ -169,9 +155,7 @@ static int add_config_(xlist_t* l, void* data)
|
|||
return xlist_store(l, config);
|
||||
}
|
||||
|
||||
int kvmgr_publish(kvmgr_t* mgr,
|
||||
xlist_action_fn_t fn,
|
||||
void* arg)
|
||||
int kvmgr_publish(kvmgr_t* mgr, xlist_action_fn_t fn, void* arg)
|
||||
{
|
||||
xlist_t l;
|
||||
int rc = 0;
|
||||
|
|
@ -180,9 +164,7 @@ int kvmgr_publish(kvmgr_t* mgr,
|
|||
xlist_init(&l, 128);
|
||||
|
||||
mylock_lock(&(mgr->lock));
|
||||
zarray_iter(&(mgr->data),
|
||||
(zarray_iter_fn_t)add_config_,
|
||||
&l);
|
||||
zarray_iter(&(mgr->data), (zarray_iter_fn_t)add_config_, &l);
|
||||
mylock_unlock(&(mgr->lock));
|
||||
|
||||
rc = (*fn)(&l, arg);
|
||||
|
|
@ -197,9 +179,7 @@ int kvmgr_publish(kvmgr_t* mgr,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int kvmgr_iter(kvmgr_t* mgr,
|
||||
xlist_t* l,
|
||||
void* arg)
|
||||
int kvmgr_iter(kvmgr_t* mgr, xlist_t* l, void* arg)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ libxce_src = [ gen_srcs[0],
|
|||
'xcectx.c',
|
||||
'xlist.c',
|
||||
'xstring.c',
|
||||
'zarray.c'
|
||||
'zarray.c',
|
||||
'wrap.c'
|
||||
]
|
||||
|
||||
incdir = include_directories('../include')
|
||||
|
|
@ -56,7 +57,8 @@ libxce_test_src = ['testsuite/test.c',
|
|||
'testsuite/test_htab_int.c',
|
||||
'testsuite/test_utils.c',
|
||||
'testsuite/test_xstring.c',
|
||||
'testsuite/test_zarray.c'
|
||||
'testsuite/test_zarray.c',
|
||||
'testsuite/test_config.c'
|
||||
]
|
||||
|
||||
libxce_test_deps = [libxce_deps, unity_dep, libxce_dep]
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@ int mylock_unlock(mylock_t* l)
|
|||
return pthread_mutex_unlock(l);
|
||||
}
|
||||
|
||||
int cbuf_init(cbuf_t* b,
|
||||
int cap,
|
||||
int isize)
|
||||
int cbuf_init(cbuf_t* b, int cap, int isize)
|
||||
{
|
||||
if ((b == NULL) || (cap <= 0) || (isize <= 0)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -90,8 +88,7 @@ void cbuf_fini(cbuf_t* b)
|
|||
pthread_cond_destroy(&(b->condget));
|
||||
}
|
||||
|
||||
int cbuf_put(cbuf_t* b,
|
||||
void* it)
|
||||
int cbuf_put(cbuf_t* b, void* it)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -101,14 +98,12 @@ int cbuf_put(cbuf_t* b,
|
|||
|
||||
pthread_mutex_lock(&(b->mutex));
|
||||
while (b->len == b->ncap) {
|
||||
pthread_cond_wait(&(b->condput),
|
||||
&(b->mutex));
|
||||
pthread_cond_wait(&(b->condput), &(b->mutex));
|
||||
}
|
||||
|
||||
i = (b->head + b->len) % b->ncap;
|
||||
|
||||
memcpy((void*)((char*)b->data) + b->isize * i,
|
||||
it, b->isize);
|
||||
memcpy((void*)((char*)b->data) + b->isize * i, it, b->isize);
|
||||
|
||||
b->len++;
|
||||
|
||||
|
|
@ -118,8 +113,7 @@ int cbuf_put(cbuf_t* b,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cbuf_tryput(cbuf_t* b,
|
||||
void* it)
|
||||
int cbuf_tryput(cbuf_t* b, void* it)
|
||||
{
|
||||
int i;
|
||||
int rc = 0;
|
||||
|
|
@ -132,8 +126,7 @@ int cbuf_tryput(cbuf_t* b,
|
|||
if (b->len < b->ncap) {
|
||||
i = (b->head + b->len) % b->ncap;
|
||||
|
||||
memcpy((void*)((char*)b->data) + b->isize * i,
|
||||
it, b->isize);
|
||||
memcpy((void*)((char*)b->data) + b->isize * i, it, b->isize);
|
||||
|
||||
b->len++;
|
||||
|
||||
|
|
@ -146,8 +139,7 @@ int cbuf_tryput(cbuf_t* b,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int cbuf_get(cbuf_t* b,
|
||||
void* it)
|
||||
int cbuf_get(cbuf_t* b, void* it)
|
||||
{
|
||||
if ((b == NULL) || (it == NULL)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -155,12 +147,10 @@ int cbuf_get(cbuf_t* b,
|
|||
|
||||
pthread_mutex_lock(&(b->mutex));
|
||||
while (b->len == 0) {
|
||||
pthread_cond_wait(&(b->condget),
|
||||
&(b->mutex));
|
||||
pthread_cond_wait(&(b->condget), &(b->mutex));
|
||||
}
|
||||
|
||||
memcpy(it, (void*)((char*)b->data) + b->isize * b->head,
|
||||
b->isize);
|
||||
memcpy(it, (void*)((char*)b->data) + b->isize * b->head, b->isize);
|
||||
|
||||
b->head = (b->head + 1) % b->ncap;
|
||||
b->len--;
|
||||
|
|
|
|||
105
src/lib/netio.c
105
src/lib/netio.c
|
|
@ -17,10 +17,7 @@
|
|||
static int iomgr_update_poll(iomgr_t*, endpoint_t*, int);
|
||||
static void endpoint_fini(endpoint_t*);
|
||||
|
||||
static int socket_create(int domain,
|
||||
int type,
|
||||
int port,
|
||||
int backlog)
|
||||
static int socket_create(int domain, int type, int port, int backlog)
|
||||
{
|
||||
int sock;
|
||||
int opt = 1;
|
||||
|
|
@ -38,7 +35,9 @@ static int socket_create(int domain,
|
|||
|
||||
fcntl(sock, F_SETFD, (fcntl(sock, F_GETFD) | FD_CLOEXEC));
|
||||
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt)) < 0) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt,
|
||||
sizeof(opt))
|
||||
< 0) {
|
||||
close(sock);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -79,9 +78,7 @@ static int socket_create(int domain,
|
|||
return sock;
|
||||
}
|
||||
|
||||
static int socket_connect(int sock,
|
||||
char* host,
|
||||
int port)
|
||||
static int socket_connect(int sock, char* host, int port)
|
||||
{
|
||||
struct sockaddr_in server;
|
||||
struct hostent* hp;
|
||||
|
|
@ -130,9 +127,7 @@ static int socket_accept(int sock)
|
|||
return s;
|
||||
}
|
||||
|
||||
int netio_write(int fd,
|
||||
char* data,
|
||||
int sz)
|
||||
int netio_write(int fd, char* data, int sz)
|
||||
{
|
||||
int nc = 0;
|
||||
|
||||
|
|
@ -152,9 +147,7 @@ int netio_write(int fd,
|
|||
return nc;
|
||||
}
|
||||
|
||||
int netio_read(int fd,
|
||||
char* data,
|
||||
int sz)
|
||||
int netio_read(int fd, char* data, int sz)
|
||||
{
|
||||
int nc = 0;
|
||||
|
||||
|
|
@ -182,13 +175,11 @@ int netio_read(int fd,
|
|||
return nc;
|
||||
}
|
||||
|
||||
int write_packet(int fd,
|
||||
io_packet_t* pkt)
|
||||
int write_packet(int fd, io_packet_t* pkt)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = netio_write(fd, (char*)&(pkt->sz),
|
||||
sizeof(pkt->sz));
|
||||
rc = netio_write(fd, (char*)&(pkt->sz), sizeof(pkt->sz));
|
||||
if (rc < 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
|
@ -217,13 +208,11 @@ int alloc_packet(io_packet_t* pkt)
|
|||
|
||||
return 1;
|
||||
}
|
||||
int read_packet(int fd,
|
||||
io_packet_t* pkt)
|
||||
int read_packet(int fd, io_packet_t* pkt)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = netio_read(fd, (char*)&(pkt->sz),
|
||||
sizeof(pkt->sz));
|
||||
rc = netio_read(fd, (char*)&(pkt->sz), sizeof(pkt->sz));
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -260,8 +249,7 @@ static void* io_worker(void* args)
|
|||
int i;
|
||||
struct epoll_event events[MAX_EPOLL_EVENTS];
|
||||
|
||||
nfds = epoll_wait(iomgr->epoll_fd, events,
|
||||
MAX_EPOLL_EVENTS, -1);
|
||||
nfds = epoll_wait(iomgr->epoll_fd, events, MAX_EPOLL_EVENTS, -1);
|
||||
if (nfds == -1) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
|
|
@ -326,11 +314,7 @@ static void outq_item_killer(data_item_t* it)
|
|||
ioctx_deref(ctx, 1);
|
||||
}
|
||||
}
|
||||
int endpoint_init(endpoint_t* ep,
|
||||
int domain,
|
||||
int type,
|
||||
int port,
|
||||
int backlog)
|
||||
int endpoint_init(endpoint_t* ep, int domain, int type, int port, int backlog)
|
||||
{
|
||||
int fd = -1;
|
||||
|
||||
|
|
@ -340,8 +324,7 @@ int endpoint_init(endpoint_t* ep,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
fd = socket_create(domain, type,
|
||||
port, backlog);
|
||||
fd = socket_create(domain, type, port, backlog);
|
||||
if (fd < 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
|
@ -354,8 +337,7 @@ int endpoint_init(endpoint_t* ep,
|
|||
ep->busy = 0;
|
||||
ep->needfree = 0;
|
||||
|
||||
dataq_init(&(ep->outq),
|
||||
outq_item_killer);
|
||||
dataq_init(&(ep->outq), outq_item_killer);
|
||||
mylock_init(&(ep->lock));
|
||||
|
||||
endpoint_ref(ep);
|
||||
|
|
@ -363,9 +345,7 @@ int endpoint_init(endpoint_t* ep,
|
|||
return fd;
|
||||
}
|
||||
|
||||
int endpoint_connect(endpoint_t* ep,
|
||||
char* host,
|
||||
int port)
|
||||
int endpoint_connect(endpoint_t* ep, char* host, int port)
|
||||
{
|
||||
int rc = -1;
|
||||
|
||||
|
|
@ -378,8 +358,7 @@ int endpoint_connect(endpoint_t* ep,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int endpoint_accept(endpoint_t* ep,
|
||||
endpoint_t* ep2)
|
||||
int endpoint_accept(endpoint_t* ep, endpoint_t* ep2)
|
||||
{
|
||||
int sock = -1;
|
||||
|
||||
|
|
@ -394,9 +373,7 @@ int endpoint_accept(endpoint_t* ep,
|
|||
return sock;
|
||||
}
|
||||
|
||||
int endpoint_set_handler(endpoint_t* ep,
|
||||
msghandler_t h,
|
||||
void* owner)
|
||||
int endpoint_set_handler(endpoint_t* ep, msghandler_t h, void* owner)
|
||||
{
|
||||
if (ep->fd < 0) {
|
||||
SET_ERROR(EINVAL);
|
||||
|
|
@ -412,8 +389,7 @@ int endpoint_set_handler(endpoint_t* ep,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int endpoint_enq(endpoint_t* ep,
|
||||
data_item_t* it)
|
||||
int endpoint_enq(endpoint_t* ep, data_item_t* it)
|
||||
{
|
||||
int rc = 0;
|
||||
int flags;
|
||||
|
|
@ -433,8 +409,7 @@ int endpoint_enq(endpoint_t* ep,
|
|||
int rc1;
|
||||
|
||||
mylock_lock(&(ep->iomgr->lock));
|
||||
rc1 = iomgr_update_poll(ep->iomgr,
|
||||
ep, flags);
|
||||
rc1 = iomgr_update_poll(ep->iomgr, ep, flags);
|
||||
mylock_unlock(&(ep->iomgr->lock));
|
||||
|
||||
if (rc1 >= 0) {
|
||||
|
|
@ -468,8 +443,7 @@ data_item_t* endpoint_deq(endpoint_t* ep)
|
|||
int rc;
|
||||
|
||||
mylock_lock(&(ep->iomgr->lock));
|
||||
rc = iomgr_update_poll(ep->iomgr,
|
||||
ep, flags);
|
||||
rc = iomgr_update_poll(ep->iomgr, ep, flags);
|
||||
mylock_unlock(&(ep->iomgr->lock));
|
||||
|
||||
if (rc >= 0) {
|
||||
|
|
@ -519,8 +493,7 @@ uint64_t endpoint_getseq(endpoint_t* ep)
|
|||
|
||||
void endpoint_block_tasks(endpoint_t* ep)
|
||||
{
|
||||
TRACE("%s[%ld] block tasks for endpoint %p",
|
||||
__func__, pthread_self(), ep);
|
||||
TRACE("%s[%ld] block tasks for endpoint %p", __func__, pthread_self(), ep);
|
||||
mylock_lock(&(ep->lock));
|
||||
ep->busy = 1;
|
||||
mylock_unlock(&(ep->lock));
|
||||
|
|
@ -528,8 +501,8 @@ void endpoint_block_tasks(endpoint_t* ep)
|
|||
|
||||
void endpoint_unblock_tasks(endpoint_t* ep)
|
||||
{
|
||||
TRACE("%s[%ld] unblock tasks for endpoint %p",
|
||||
__func__, pthread_self(), ep);
|
||||
TRACE("%s[%ld] unblock tasks for endpoint %p", __func__, pthread_self(),
|
||||
ep);
|
||||
mylock_lock(&(ep->lock));
|
||||
ep->busy = 0;
|
||||
mylock_unlock(&(ep->lock));
|
||||
|
|
@ -543,9 +516,8 @@ int endpoint_is_task_blocked(endpoint_t* ep)
|
|||
busy = ep->busy;
|
||||
mylock_unlock(&(ep->lock));
|
||||
|
||||
TRACE("%s[%ld] endpoint %p task %s",
|
||||
__func__, pthread_self(),
|
||||
ep, (busy != 0) ? "blocked" : "not blocked");
|
||||
TRACE("%s[%ld] endpoint %p task %s", __func__, pthread_self(), ep,
|
||||
(busy != 0) ? "blocked" : "not blocked");
|
||||
|
||||
return (busy != 0);
|
||||
}
|
||||
|
|
@ -583,22 +555,17 @@ int iomgr_init(iomgr_t* iomgr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int iomgr_update_poll(iomgr_t* iomgr,
|
||||
endpoint_t* ep,
|
||||
int flags)
|
||||
static int iomgr_update_poll(iomgr_t* iomgr, endpoint_t* ep, int flags)
|
||||
{
|
||||
struct epoll_event ev;
|
||||
|
||||
ev.events = flags;
|
||||
ev.data.ptr = ep;
|
||||
|
||||
return epoll_ctl(iomgr->epoll_fd,
|
||||
EPOLL_CTL_MOD,
|
||||
ep->fd, &ev);
|
||||
return epoll_ctl(iomgr->epoll_fd, EPOLL_CTL_MOD, ep->fd, &ev);
|
||||
}
|
||||
|
||||
int iomgr_monitor(iomgr_t* iomgr,
|
||||
endpoint_t* ep)
|
||||
int iomgr_monitor(iomgr_t* iomgr, endpoint_t* ep)
|
||||
{
|
||||
struct epoll_event ev;
|
||||
int rc;
|
||||
|
|
@ -611,8 +578,7 @@ int iomgr_monitor(iomgr_t* iomgr,
|
|||
mylock_lock(&(ep->lock));
|
||||
ep->iomgr = iomgr;
|
||||
mylock_lock(&(iomgr->lock));
|
||||
rc = epoll_ctl(iomgr->epoll_fd, EPOLL_CTL_ADD,
|
||||
ep->fd, &ev);
|
||||
rc = epoll_ctl(iomgr->epoll_fd, EPOLL_CTL_ADD, ep->fd, &ev);
|
||||
mylock_unlock(&(iomgr->lock));
|
||||
|
||||
if (rc >= 0) {
|
||||
|
|
@ -624,14 +590,12 @@ int iomgr_monitor(iomgr_t* iomgr,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int iomgr_unmonitor(iomgr_t* iomgr,
|
||||
endpoint_t* ep)
|
||||
int iomgr_unmonitor(iomgr_t* iomgr, endpoint_t* ep)
|
||||
{
|
||||
int rc;
|
||||
|
||||
mylock_lock(&(iomgr->lock));
|
||||
rc = epoll_ctl(iomgr->epoll_fd, EPOLL_CTL_DEL,
|
||||
ep->fd, NULL);
|
||||
rc = epoll_ctl(iomgr->epoll_fd, EPOLL_CTL_DEL, ep->fd, NULL);
|
||||
if (rc < 0) {
|
||||
SET_ERROR(errno);
|
||||
|
||||
|
|
@ -650,10 +614,7 @@ int iomgr_start(iomgr_t* iomgr)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int iomgr_fini(iomgr_t* iomgr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int iomgr_fini(iomgr_t* iomgr) { return 0; }
|
||||
|
||||
int iomgr_stop(iomgr_t* iomgr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,10 +29,8 @@ int objmgr_init(objmgr_t* mgr)
|
|||
|
||||
mylock_init(&(mgr->lock));
|
||||
|
||||
ht_init(&(mgr->names), 32,
|
||||
string_hash_key);
|
||||
zarray_init(&(mgr->types), 32,
|
||||
(zarray_item_killer_t)objtype_killer);
|
||||
ht_init(&(mgr->names), 32, string_hash_key);
|
||||
zarray_init(&(mgr->types), 32, (zarray_item_killer_t)objtype_killer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -48,8 +46,7 @@ void objmgr_fini(objmgr_t* mgr)
|
|||
mylock_fini(&(mgr->lock));
|
||||
}
|
||||
|
||||
static int objmgr_register_internal(objmgr_t* mgr,
|
||||
objtype_t* type)
|
||||
static int objmgr_register_internal(objmgr_t* mgr, objtype_t* type)
|
||||
{
|
||||
hent_t* e = NULL;
|
||||
int idx;
|
||||
|
|
@ -74,10 +71,7 @@ static int objmgr_register_internal(objmgr_t* mgr,
|
|||
return idx;
|
||||
}
|
||||
|
||||
int obj_init(objmgr_t* mgr,
|
||||
objtype_t* type,
|
||||
int32_t exdata,
|
||||
myobj_t* obj)
|
||||
int obj_init(objmgr_t* mgr, objtype_t* type, int32_t exdata, myobj_t* obj)
|
||||
{
|
||||
obj->type = type;
|
||||
obj->nref = 1;
|
||||
|
|
@ -92,8 +86,7 @@ int obj_init(objmgr_t* mgr,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int objmgr_register(objmgr_t* mgr,
|
||||
objtype_t* type)
|
||||
int objmgr_register(objmgr_t* mgr, objtype_t* type)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
@ -115,9 +108,7 @@ int objmgr_register(objmgr_t* mgr,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static void* create_obj_ex(objmgr_t* mgr,
|
||||
int type,
|
||||
va_list ap)
|
||||
static void* create_obj_ex(objmgr_t* mgr, int type, va_list ap)
|
||||
{
|
||||
objtype_t* typeval = NULL;
|
||||
void* obj;
|
||||
|
|
@ -138,9 +129,7 @@ static void* create_obj_ex(objmgr_t* mgr,
|
|||
return obj;
|
||||
}
|
||||
|
||||
void* create_obj_by_typeid(objmgr_t* mgr,
|
||||
int type,
|
||||
...)
|
||||
void* create_obj_by_typeid(objmgr_t* mgr, int type, ...)
|
||||
{
|
||||
va_list ap;
|
||||
void* p = NULL;
|
||||
|
|
@ -154,9 +143,7 @@ void* create_obj_by_typeid(objmgr_t* mgr,
|
|||
return p;
|
||||
}
|
||||
|
||||
void* create_obj_by_typename(objmgr_t* mgr,
|
||||
char* type,
|
||||
...)
|
||||
void* create_obj_by_typename(objmgr_t* mgr, char* type, ...)
|
||||
{
|
||||
hent_t* e;
|
||||
va_list ap;
|
||||
|
|
@ -185,8 +172,7 @@ void* create_obj_by_typename(objmgr_t* mgr,
|
|||
return p;
|
||||
}
|
||||
|
||||
int typeid_of_name(objmgr_t* mgr,
|
||||
char* type)
|
||||
int typeid_of_name(objmgr_t* mgr, char* type)
|
||||
{
|
||||
hent_t* e;
|
||||
int typeid;
|
||||
|
|
@ -298,10 +284,7 @@ void obj_deref(void* obj)
|
|||
return;
|
||||
}
|
||||
|
||||
objmgr_t* objmgr_get_default()
|
||||
{
|
||||
return objmgr_default;
|
||||
}
|
||||
objmgr_t* objmgr_get_default() { return objmgr_default; }
|
||||
|
||||
int objmgr_set_default(objmgr_t* mgr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@
|
|||
#include "utils.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
ioctx_t* ioctx_alloc(endpoint_t* ep,
|
||||
xce_peerinfo_t* peer)
|
||||
ioctx_t* ioctx_alloc(endpoint_t* ep, xce_peerinfo_t* peer)
|
||||
{
|
||||
ioctx_t* ctx;
|
||||
|
||||
|
|
@ -37,8 +36,7 @@ int ioctx_ref(ioctx_t* ctx)
|
|||
return old;
|
||||
}
|
||||
|
||||
static void ioctx_kill(ioctx_t* ctx,
|
||||
int free_ctx)
|
||||
static void ioctx_kill(ioctx_t* ctx, int free_ctx)
|
||||
{
|
||||
if (ctx == NULL) {
|
||||
return;
|
||||
|
|
@ -53,8 +51,7 @@ static void ioctx_kill(ioctx_t* ctx,
|
|||
}
|
||||
}
|
||||
|
||||
void ioctx_deref(ioctx_t* ctx,
|
||||
int free_ctx)
|
||||
void ioctx_deref(ioctx_t* ctx, int free_ctx)
|
||||
{
|
||||
if (ctx == NULL) {
|
||||
return;
|
||||
|
|
@ -70,8 +67,7 @@ void ioctx_deref(ioctx_t* ctx,
|
|||
}
|
||||
}
|
||||
|
||||
int ioctx_encode(ioctx_t* ctx,
|
||||
xce_request_t* req)
|
||||
int ioctx_encode(ioctx_t* ctx, xce_request_t* req)
|
||||
{
|
||||
struct capn_segment* cs;
|
||||
Request_ptr rp;
|
||||
|
|
@ -94,19 +90,15 @@ int ioctx_encode(ioctx_t* ctx,
|
|||
return rc;
|
||||
}
|
||||
|
||||
capn_write_mem(&(ctx->c),
|
||||
(uint8_t*)ctx->pkt.data,
|
||||
ctx->pkt.sz, 0);
|
||||
capn_write_mem(&(ctx->c), (uint8_t*)ctx->pkt.data, ctx->pkt.sz, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ioctx_decode(ioctx_t* ctx,
|
||||
xce_request_t* req)
|
||||
int ioctx_decode(ioctx_t* ctx, xce_request_t* req)
|
||||
{
|
||||
Request_ptr rp;
|
||||
|
||||
capn_init_mem(&(ctx->c), (const uint8_t*)ctx->pkt.data,
|
||||
ctx->pkt.sz, 0);
|
||||
capn_init_mem(&(ctx->c), (const uint8_t*)ctx->pkt.data, ctx->pkt.sz, 0);
|
||||
rp.p = capn_getp(capn_root(&(ctx->c)), 0, 1);
|
||||
|
||||
read_Request(&(ctx->rq), rp);
|
||||
|
|
@ -124,15 +116,13 @@ int ioctx_flush(ioctx_t* ctx, int fd)
|
|||
return rc;
|
||||
}
|
||||
|
||||
void init_reply_by_req(xce_reply_t* reply,
|
||||
xce_request_t* req)
|
||||
void init_reply_by_req(xce_reply_t* reply, xce_request_t* req)
|
||||
{
|
||||
reply->seq = req->seq;
|
||||
reply->opcode = req->opcode;
|
||||
}
|
||||
|
||||
int xce_request(ioctx_t* ctx,
|
||||
xce_request_t* req)
|
||||
int xce_request(ioctx_t* ctx, xce_request_t* req)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
|
@ -148,9 +138,7 @@ int xce_request(ioctx_t* ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_reply_with_ctx(ioctx_t* ctx,
|
||||
xce_peerinfo_t* from,
|
||||
xce_reply_t* reply)
|
||||
int xce_reply_with_ctx(ioctx_t* ctx, xce_peerinfo_t* from, xce_reply_t* reply)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -160,9 +148,8 @@ int xce_reply_with_ctx(ioctx_t* ctx,
|
|||
/* clang-format on */
|
||||
int rc;
|
||||
|
||||
TRACE("%s seq %lu opcode %d status %d data which %d",
|
||||
__func__, reply->seq, reply->opcode,
|
||||
reply->status, reply->data_which);
|
||||
TRACE("%s seq %lu opcode %d status %d data which %d", __func__, reply->seq,
|
||||
reply->opcode, reply->status, reply->data_which);
|
||||
|
||||
request.from = from;
|
||||
request.body.replymsg = reply;
|
||||
|
|
@ -178,9 +165,7 @@ int xce_reply_with_ctx(ioctx_t* ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_reply(endpoint_t* ep,
|
||||
xce_peerinfo_t* from,
|
||||
xce_reply_t* reply)
|
||||
int xce_reply(endpoint_t* ep, xce_peerinfo_t* from, xce_reply_t* reply)
|
||||
{
|
||||
ioctx_t* ctx;
|
||||
|
||||
|
|
@ -194,10 +179,8 @@ int xce_reply(endpoint_t* ep,
|
|||
|
||||
int xce_nop_req(ioctx_t* ctx)
|
||||
{
|
||||
xce_request_t request = {
|
||||
.opcode = OPCode_nop,
|
||||
.body_which = Request_body_nomsg
|
||||
};
|
||||
xce_request_t request
|
||||
= { .opcode = OPCode_nop, .body_which = Request_body_nomsg };
|
||||
|
||||
if (ctx == NULL) {
|
||||
return -EINVAL;
|
||||
|
|
@ -206,8 +189,7 @@ int xce_nop_req(ioctx_t* ctx)
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_hello_req(ioctx_t* ctx,
|
||||
char* msg)
|
||||
int xce_hello_req(ioctx_t* ctx, char* msg)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -225,9 +207,7 @@ int xce_hello_req(ioctx_t* ctx,
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_join_req(ioctx_t* ctx,
|
||||
int role,
|
||||
hostattrs_t* attrs)
|
||||
int xce_join_req(ioctx_t* ctx, int role, hostattrs_t* attrs)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_joindata_t joinmsg = {
|
||||
|
|
@ -263,10 +243,8 @@ int xce_shutdown_req(ioctx_t* ctx)
|
|||
{
|
||||
int rc;
|
||||
dataq_t* outq;
|
||||
xce_request_t request = {
|
||||
.opcode = OPCode_shutdown,
|
||||
.body_which = Request_body_nomsg
|
||||
};
|
||||
xce_request_t request
|
||||
= { .opcode = OPCode_shutdown, .body_which = Request_body_nomsg };
|
||||
|
||||
if (ctx == NULL) {
|
||||
return -EINVAL;
|
||||
|
|
@ -286,15 +264,12 @@ int xce_shutdown_req(ioctx_t* ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_pushconfig_req(endpoint_t* ep,
|
||||
xce_peerinfo_t* from,
|
||||
int xce_pushconfig_req(endpoint_t* ep, xce_peerinfo_t* from,
|
||||
xce_configdata_t* config)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_request_t request = {
|
||||
.opcode = OPCode_push,
|
||||
.body_which = Request_body_configpushmsg
|
||||
};
|
||||
int rc = 0;
|
||||
xce_request_t request
|
||||
= { .opcode = OPCode_push, .body_which = Request_body_configpushmsg };
|
||||
ioctx_t* ctx = NULL;
|
||||
|
||||
if ((ep == NULL) || (config == NULL)) {
|
||||
|
|
@ -312,16 +287,12 @@ int xce_pushconfig_req(endpoint_t* ep,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int xce_push_req(endpoint_t* ep,
|
||||
xce_peerinfo_t* from,
|
||||
xce_data_t* data)
|
||||
static int xce_push_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data)
|
||||
{
|
||||
int rc = 0;
|
||||
ioctx_t* ctx = NULL;
|
||||
xce_request_t request = {
|
||||
.opcode = OPCode_push,
|
||||
.body_which = Request_body_pushmsg
|
||||
};
|
||||
int rc = 0;
|
||||
ioctx_t* ctx = NULL;
|
||||
xce_request_t request
|
||||
= { .opcode = OPCode_push, .body_which = Request_body_pushmsg };
|
||||
|
||||
if ((ep == NULL) || (from == NULL) || (data == NULL)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -338,12 +309,8 @@ static int xce_push_req(endpoint_t* ep,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xce_push_data_req(endpoint_t* ep,
|
||||
xce_peerinfo_t* from,
|
||||
xce_data_t* data,
|
||||
xce_check_fn_t checkf,
|
||||
void* checkarg,
|
||||
int pktlimit)
|
||||
int xce_push_data_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data,
|
||||
xce_check_fn_t checkf, void* checkarg, int pktlimit)
|
||||
{
|
||||
int nrows = 0;
|
||||
int pos = 0;
|
||||
|
|
@ -365,8 +332,9 @@ int xce_push_data_req(endpoint_t* ep,
|
|||
}
|
||||
break;
|
||||
case Data_data_schedworkers:
|
||||
nrows = data->data.workers->n_total;
|
||||
data1.data.workers = (xce_workers_data_t*)calloc(1, sizeof(xce_workers_data_t));
|
||||
nrows = data->data.workers->n_total;
|
||||
data1.data.workers
|
||||
= (xce_workers_data_t*)calloc(1, sizeof(xce_workers_data_t));
|
||||
if (data1.data.workers == NULL) {
|
||||
rc = -ENOMEM;
|
||||
}
|
||||
|
|
@ -416,7 +384,8 @@ int xce_push_data_req(endpoint_t* ep,
|
|||
if (nc == 0) {
|
||||
data1.data.workers->workers = NULL;
|
||||
} else {
|
||||
data1.data.workers->workers = &(data->data.workers->workers[pos]);
|
||||
data1.data.workers->workers
|
||||
= &(data->data.workers->workers[pos]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -447,8 +416,7 @@ int xce_push_data_req(endpoint_t* ep,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xce_get_req(ioctx_t* ctx,
|
||||
xce_get_t* get)
|
||||
int xce_get_req(ioctx_t* ctx, xce_get_t* get)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -463,12 +431,8 @@ int xce_get_req(ioctx_t* ctx,
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_reply_get(endpoint_t* ep,
|
||||
xce_peerinfo_t* from,
|
||||
xce_reply_t* reply,
|
||||
xce_check_fn_t checkf,
|
||||
void* checkarg,
|
||||
int pktlimit)
|
||||
int xce_reply_get(endpoint_t* ep, xce_peerinfo_t* from, xce_reply_t* reply,
|
||||
xce_check_fn_t checkf, void* checkarg, int pktlimit)
|
||||
{
|
||||
int rc = 0;
|
||||
int nrows = 0;
|
||||
|
|
@ -497,21 +461,25 @@ int xce_reply_get(endpoint_t* ep,
|
|||
switch (getdata.table) {
|
||||
case Data_data_schedjobs:
|
||||
case Data_data_jobs:
|
||||
nrows = data->data.jobs->n_total;
|
||||
getdata.data.jobs = (xce_jobs_data_t*)calloc(1, sizeof(xce_jobs_data_t));
|
||||
nrows = data->data.jobs->n_total;
|
||||
getdata.data.jobs
|
||||
= (xce_jobs_data_t*)calloc(1, sizeof(xce_jobs_data_t));
|
||||
break;
|
||||
case Data_data_schedworkers:
|
||||
case Data_data_workers:
|
||||
nrows = data->data.workers->n_total;
|
||||
getdata.data.workers = (xce_workers_data_t*)calloc(1, sizeof(xce_workers_data_t));
|
||||
nrows = data->data.workers->n_total;
|
||||
getdata.data.workers
|
||||
= (xce_workers_data_t*)calloc(1, sizeof(xce_workers_data_t));
|
||||
break;
|
||||
case Data_data_resources:
|
||||
nrows = data->data.resources->n_total;
|
||||
getdata.data.resources = (xce_resource_data_t*)calloc(1, sizeof(xce_resource_data_t));
|
||||
nrows = data->data.resources->n_total;
|
||||
getdata.data.resources
|
||||
= (xce_resource_data_t*)calloc(1, sizeof(xce_resource_data_t));
|
||||
break;
|
||||
case Data_data_resvals:
|
||||
nrows = data->data.resvals->n_total;
|
||||
getdata.data.resvals = (xce_resval_data_t*)calloc(1, sizeof(xce_resval_data_t));
|
||||
nrows = data->data.resvals->n_total;
|
||||
getdata.data.resvals
|
||||
= (xce_resval_data_t*)calloc(1, sizeof(xce_resval_data_t));
|
||||
break;
|
||||
default:
|
||||
rc = -EINVAL;
|
||||
|
|
@ -562,7 +530,8 @@ int xce_reply_get(endpoint_t* ep,
|
|||
if (nc == 0) {
|
||||
getdata.data.workers->workers = NULL;
|
||||
} else {
|
||||
getdata.data.workers->workers = &(data->data.workers->workers[pos]);
|
||||
getdata.data.workers->workers
|
||||
= &(data->data.workers->workers[pos]);
|
||||
}
|
||||
break;
|
||||
case Data_data_resources:
|
||||
|
|
@ -572,7 +541,8 @@ int xce_reply_get(endpoint_t* ep,
|
|||
if (nc == 0) {
|
||||
getdata.data.resources->resources = NULL;
|
||||
} else {
|
||||
getdata.data.resources->resources = &(data->data.resources->resources[pos]);
|
||||
getdata.data.resources->resources
|
||||
= &(data->data.resources->resources[pos]);
|
||||
}
|
||||
break;
|
||||
case Data_data_resvals:
|
||||
|
|
@ -620,8 +590,7 @@ int xce_reply_get(endpoint_t* ep,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int extract_data(dataset_t* dataset,
|
||||
xce_data_t* getdata)
|
||||
int extract_data(dataset_t* dataset, xce_data_t* getdata)
|
||||
{
|
||||
int ntotal;
|
||||
int rc = 0;
|
||||
|
|
@ -659,7 +628,8 @@ int extract_data(dataset_t* dataset,
|
|||
|
||||
ntotal = getdata->data.workers->n_total;
|
||||
if (dataset->rows == NULL) {
|
||||
dataset->rows = (xce_worker_t**)calloc(ntotal, sizeof(xce_worker_t*));
|
||||
dataset->rows
|
||||
= (xce_worker_t**)calloc(ntotal, sizeof(xce_worker_t*));
|
||||
dataset->nrows = 0;
|
||||
}
|
||||
pos = getdata->data.workers->pos;
|
||||
|
|
@ -667,7 +637,8 @@ int extract_data(dataset_t* dataset,
|
|||
|
||||
memcpy((void*)(((char*)dataset->rows) + sizeof(xce_worker_t*) * pos),
|
||||
getdata->data.workers->workers, count * sizeof(xce_worker_t*));
|
||||
memset(getdata->data.workers->workers, 0x0, count * sizeof(xce_worker_t*));
|
||||
memset(getdata->data.workers->workers, 0x0,
|
||||
count * sizeof(xce_worker_t*));
|
||||
|
||||
break;
|
||||
case Data_data_resources:
|
||||
|
|
@ -677,16 +648,19 @@ int extract_data(dataset_t* dataset,
|
|||
|
||||
ntotal = getdata->data.resources->n_total;
|
||||
if (dataset->rows == NULL) {
|
||||
dataset->rows = (xce_resource_t**)calloc(ntotal, sizeof(xce_resource_t*));
|
||||
dataset->rows
|
||||
= (xce_resource_t**)calloc(ntotal, sizeof(xce_resource_t*));
|
||||
dataset->nrows = 0;
|
||||
}
|
||||
pos = getdata->data.resources->pos;
|
||||
count = getdata->data.resources->count;
|
||||
|
||||
memcpy((void*)(((char*)dataset->rows) + sizeof(xce_resource_t*) * pos),
|
||||
getdata->data.resources->resources, count * sizeof(xce_resource_t*));
|
||||
getdata->data.resources->resources,
|
||||
count * sizeof(xce_resource_t*));
|
||||
|
||||
memset(getdata->data.resources->resources, 0x0, count * sizeof(xce_resource_t*));
|
||||
memset(getdata->data.resources->resources, 0x0,
|
||||
count * sizeof(xce_resource_t*));
|
||||
break;
|
||||
case Data_data_resvals:
|
||||
if (getdata->data.resvals->count <= 0) {
|
||||
|
|
@ -695,7 +669,8 @@ int extract_data(dataset_t* dataset,
|
|||
|
||||
ntotal = getdata->data.resvals->n_total;
|
||||
if (dataset->rows == NULL) {
|
||||
dataset->rows = (xce_resval_t**)calloc(ntotal, sizeof(xce_resval_t*));
|
||||
dataset->rows
|
||||
= (xce_resval_t**)calloc(ntotal, sizeof(xce_resval_t*));
|
||||
dataset->nrows = 0;
|
||||
}
|
||||
|
||||
|
|
@ -724,8 +699,7 @@ int extract_data(dataset_t* dataset,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int xce_jobdispatch_req(ioctx_t* ctx,
|
||||
xce_job_dispatch_t* info)
|
||||
int xce_jobdispatch_req(ioctx_t* ctx, xce_job_dispatch_t* info)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -747,8 +721,7 @@ int xce_jobdispatch_req(ioctx_t* ctx,
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_notify_req(ioctx_t* ctx,
|
||||
xce_notify_data_t* data)
|
||||
int xce_notify_req(ioctx_t* ctx, xce_notify_data_t* data)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -790,8 +763,7 @@ int xce_jobsubmit_req(ioctx_t* ctx,
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_startjob_req(ioctx_t* ctx,
|
||||
xce_job_exec_t* execinfo)
|
||||
int xce_startjob_req(ioctx_t* ctx, xce_job_exec_t* execinfo)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -818,8 +790,7 @@ int xce_clusterconf_req(ioctx_t* ctx)
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_update_req(ioctx_t* ctx,
|
||||
xce_update_data_t* data)
|
||||
int xce_update_req(ioctx_t* ctx, xce_update_data_t* data)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -838,8 +809,7 @@ int xce_update_req(ioctx_t* ctx,
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_jobctrl_req(ioctx_t* ctx,
|
||||
xce_jobctrl_t* ctrinfo)
|
||||
int xce_jobctrl_req(ioctx_t* ctx, xce_jobctrl_t* ctrinfo)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -874,8 +844,7 @@ int xce_jobctrl_req(ioctx_t* ctx,
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_queuectrl_req(ioctx_t* ctx,
|
||||
xce_queuectrl_t* ctrlinfo)
|
||||
int xce_queuectrl_req(ioctx_t* ctx, xce_queuectrl_t* ctrlinfo)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
@ -906,8 +875,7 @@ int xce_queuectrl_req(ioctx_t* ctx,
|
|||
return xce_request(ctx, &request);
|
||||
}
|
||||
|
||||
int xce_runtask_req(ioctx_t* ctx,
|
||||
xce_taskrun_t* runinfo)
|
||||
int xce_runtask_req(ioctx_t* ctx, xce_taskrun_t* runinfo)
|
||||
{
|
||||
/* clang-format off */
|
||||
xce_request_t request = {
|
||||
|
|
|
|||
|
|
@ -10,20 +10,16 @@ extern void test_ht_string(void);
|
|||
extern void test_ht_int(void);
|
||||
extern void test_error(void);
|
||||
extern void test_utils(void);
|
||||
extern void test_config(void);
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
void setUp(void) { return; }
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
void tearDown(void) { return; }
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
test_config();
|
||||
test_ht_string();
|
||||
test_ht_int();
|
||||
test_zarray();
|
||||
|
|
|
|||
39
src/lib/testsuite/test_config.c
Normal file
39
src/lib/testsuite/test_config.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unity/unity.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
static void test_cluster_id(void)
|
||||
{
|
||||
TEST_ASSERT_TRUE(MAX_CLUSTER_ID == 63);
|
||||
TEST_ASSERT_TRUE(CLUSTER_ID_SHIFT == 58);
|
||||
}
|
||||
|
||||
static void test_apiserver_id(void)
|
||||
{
|
||||
TEST_ASSERT_TRUE(MAX_APISERVER_ID == 15);
|
||||
TEST_ASSERT_TRUE(APISERVER_ID_SHIFT == 54);
|
||||
}
|
||||
|
||||
static void test_timestamp(void) { TEST_ASSERT_TRUE(TIMESTAMP_SHIFT == 22); }
|
||||
|
||||
static void test_tag(void) { TEST_ASSERT_TRUE(TAG_SHIFT == 20); }
|
||||
|
||||
static void test_array(void)
|
||||
{
|
||||
TEST_ASSERT_TRUE(SEQUENCE_HIGH_SHIFT == 15);
|
||||
TEST_ASSERT_TRUE(MAX_ARRAY_IDX == 32767);
|
||||
}
|
||||
|
||||
void test_config(void)
|
||||
{
|
||||
printf("\n>> config test\n\n");
|
||||
|
||||
RUN_TEST(test_cluster_id);
|
||||
RUN_TEST(test_apiserver_id);
|
||||
RUN_TEST(test_timestamp);
|
||||
RUN_TEST(test_tag);
|
||||
RUN_TEST(test_array);
|
||||
}
|
||||
|
|
@ -83,14 +83,10 @@ void test_dup_threshold()
|
|||
|
||||
TEST_ASSERT_TRUE(strcmp(threshold[0]->name, threshold2[0]->name) == 0);
|
||||
TEST_ASSERT_TRUE(strcmp(threshold[1]->name, threshold2[1]->name) == 0);
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[0]->sched,
|
||||
threshold2[0]->sched));
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[0]->stop,
|
||||
threshold2[0]->stop));
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[1]->sched,
|
||||
threshold2[1]->sched));
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[1]->stop,
|
||||
threshold2[1]->stop));
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[0]->sched, threshold2[0]->sched));
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[0]->stop, threshold2[0]->stop));
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[1]->sched, threshold2[1]->sched));
|
||||
TEST_ASSERT_TRUE(float_equal(threshold[1]->stop, threshold2[1]->stop));
|
||||
|
||||
free_resource_thresholds(threshold2, 2);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ void test_xstring_ref(void)
|
|||
register_xstring(&mgr, 4, 4);
|
||||
TEST_ASSERT_EQUAL(1, mgr.types.count);
|
||||
|
||||
s1 = create_obj_by_typename(&mgr, "xstring",
|
||||
"Hello,world");
|
||||
s1 = create_obj_by_typename(&mgr, "xstring", "Hello,world");
|
||||
TEST_ASSERT_NOT_NULL(s1);
|
||||
|
||||
obj = TO_MYOBJ(s1);
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
static void kill_thresholds(xce_res_threshold_t** thresholds,
|
||||
int count)
|
||||
static void kill_thresholds(xce_res_threshold_t** thresholds, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -30,8 +29,7 @@ static void kill_thresholds(xce_res_threshold_t** thresholds,
|
|||
FREEUP(thresholds);
|
||||
}
|
||||
|
||||
void free_resource_thresholds(xce_res_threshold_t** thresholds,
|
||||
int count)
|
||||
void free_resource_thresholds(xce_res_threshold_t** thresholds, int count)
|
||||
{
|
||||
kill_thresholds(thresholds, count);
|
||||
}
|
||||
|
|
@ -47,7 +45,8 @@ xce_res_threshold_t** dup_resource_thresholds(xce_res_threshold_t** src,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
thresholds = (xce_res_threshold_t**)calloc(count, sizeof(xce_res_threshold_t*));
|
||||
thresholds
|
||||
= (xce_res_threshold_t**)calloc(count, sizeof(xce_res_threshold_t*));
|
||||
if (thresholds == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
|
|
|
|||
236
src/lib/utils.c
236
src/lib/utils.c
|
|
@ -25,73 +25,52 @@
|
|||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
static capn_text chars_to_text_internal(const char* chars)
|
||||
{
|
||||
capn_text data = {
|
||||
.len = strlen(chars),
|
||||
.str = chars,
|
||||
.seg = NULL,
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
capn_text chars_to_text(const char* chars)
|
||||
{
|
||||
if (chars == NULL) {
|
||||
chars = "";
|
||||
}
|
||||
|
||||
return chars_to_text_internal(chars);
|
||||
}
|
||||
|
||||
#define ARGV_INCR_DELTA (16)
|
||||
|
||||
#define FILL_ARGV(rc, argv, argc, maxargc, delta, s) \
|
||||
do { \
|
||||
(rc) = 0; \
|
||||
char* s1; \
|
||||
if (((argc) >= (maxargc))) { \
|
||||
char** p; \
|
||||
int nc, i; \
|
||||
nc = (maxargc) + (delta); \
|
||||
p = (char**)realloc((argv), nc * sizeof(char*)); \
|
||||
if (p == NULL) { \
|
||||
(rc) = -ENOMEM; \
|
||||
break; \
|
||||
} \
|
||||
for (i = (maxargc); i < nc; i++) { \
|
||||
p[i] = NULL; \
|
||||
} \
|
||||
(argv) = p; \
|
||||
(maxargc) = nc; \
|
||||
} \
|
||||
s1 = strdup(s); \
|
||||
if (s1 == NULL) { \
|
||||
(rc) = -ENOMEM; \
|
||||
break; \
|
||||
} \
|
||||
(argv)[argc] = s1; \
|
||||
(argc)++; \
|
||||
#define FILL_ARGV(rc, argv, argc, maxargc, delta, s) \
|
||||
do { \
|
||||
(rc) = 0; \
|
||||
char* s1; \
|
||||
if (((argc) >= (maxargc))) { \
|
||||
char** p; \
|
||||
int nc, i; \
|
||||
nc = (maxargc) + (delta); \
|
||||
p = (char**)realloc((argv), nc * sizeof(char*)); \
|
||||
if (p == NULL) { \
|
||||
(rc) = -ENOMEM; \
|
||||
break; \
|
||||
} \
|
||||
for (i = (maxargc); i < nc; i++) { \
|
||||
p[i] = NULL; \
|
||||
} \
|
||||
(argv) = p; \
|
||||
(maxargc) = nc; \
|
||||
} \
|
||||
s1 = strdup(s); \
|
||||
if (s1 == NULL) { \
|
||||
(rc) = -ENOMEM; \
|
||||
break; \
|
||||
} \
|
||||
(argv)[argc] = s1; \
|
||||
(argc)++; \
|
||||
} while (0)
|
||||
|
||||
#define FREE_ARGV(argv, argc) \
|
||||
do { \
|
||||
int i; \
|
||||
if ((argv) == NULL) { \
|
||||
break; \
|
||||
} \
|
||||
for (i = 0; i < (argc); i++) { \
|
||||
if ((argv)[i] != NULL) { \
|
||||
free((argv)[i]); \
|
||||
(argv)[i] = NULL; \
|
||||
} \
|
||||
} \
|
||||
free(argv); \
|
||||
#define FREE_ARGV(argv, argc) \
|
||||
do { \
|
||||
int i; \
|
||||
if ((argv) == NULL) { \
|
||||
break; \
|
||||
} \
|
||||
for (i = 0; i < (argc); i++) { \
|
||||
if ((argv)[i] != NULL) { \
|
||||
free((argv)[i]); \
|
||||
(argv)[i] = NULL; \
|
||||
} \
|
||||
} \
|
||||
free(argv); \
|
||||
} while (0)
|
||||
|
||||
int parse_argv(char* input,
|
||||
char*** argv)
|
||||
int parse_argv(char* input, char*** argv)
|
||||
{
|
||||
int max_argc = 0;
|
||||
char* arg = NULL;
|
||||
|
|
@ -124,8 +103,7 @@ int parse_argv(char* input,
|
|||
if (isspace(*input)) {
|
||||
if (i > 0) {
|
||||
arg[i] = '\0';
|
||||
FILL_ARGV(rc, *argv, argc, max_argc,
|
||||
ARGV_INCR_DELTA, arg);
|
||||
FILL_ARGV(rc, *argv, argc, max_argc, ARGV_INCR_DELTA, arg);
|
||||
if (rc < 0) {
|
||||
FREE_ARGV(*argv, argc);
|
||||
free(arg);
|
||||
|
|
@ -150,8 +128,7 @@ int parse_argv(char* input,
|
|||
|
||||
if (i > 0) {
|
||||
arg[i] = '\0';
|
||||
FILL_ARGV(rc, *argv, argc, max_argc,
|
||||
ARGV_INCR_DELTA, arg);
|
||||
FILL_ARGV(rc, *argv, argc, max_argc, ARGV_INCR_DELTA, arg);
|
||||
if (rc < 0) {
|
||||
FREE_ARGV(*argv, argc);
|
||||
free(arg);
|
||||
|
|
@ -163,32 +140,9 @@ int parse_argv(char* input,
|
|||
return argc;
|
||||
}
|
||||
|
||||
void free_argv(char** argv, int argc)
|
||||
{
|
||||
FREE_ARGV(argv, argc);
|
||||
}
|
||||
void free_argv(char** argv, int argc) { FREE_ARGV(argv, argc); }
|
||||
|
||||
#if 0
|
||||
void freeup_kvs(int count,
|
||||
xce_kv_t* vals)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (vals == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (vals[i].value.which != XceFieldValue_data_svalue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FREEUP(vals[i].value.u.svalue);
|
||||
}
|
||||
|
||||
FREEUP(vals);
|
||||
}
|
||||
#endif
|
||||
int get_myname(char* name, size_t size) { return gethostname(name, size); }
|
||||
|
||||
char* frame_symbol(int k)
|
||||
{
|
||||
|
|
@ -217,8 +171,7 @@ int xce_vprintf(const char* fmt, va_list ap)
|
|||
if (tlog_get_root() == NULL) {
|
||||
rc = vfprintf(stdout, fmt, ap);
|
||||
} else {
|
||||
rc = tlog_vext(TLOG_INFO, __FILE__, __LINE__,
|
||||
__func__, NULL, fmt, ap);
|
||||
rc = tlog_vext(TLOG_INFO, __FILE__, __LINE__, __func__, NULL, fmt, ap);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -250,12 +203,8 @@ int name_to_level(char* lvlname)
|
|||
return TLOG_INFO;
|
||||
}
|
||||
|
||||
static int my_tlog_format(char* buff,
|
||||
int maxlen,
|
||||
struct tlog_loginfo* info,
|
||||
void* userptr,
|
||||
const char* fmt,
|
||||
va_list ap)
|
||||
static int my_tlog_format(char* buff, int maxlen, struct tlog_loginfo* info,
|
||||
void* userptr, const char* fmt, va_list ap)
|
||||
{
|
||||
int len = 0;
|
||||
int total_len = 0;
|
||||
|
|
@ -265,13 +214,19 @@ static int my_tlog_format(char* buff,
|
|||
|
||||
/* format prefix */
|
||||
if (info->level < TLOG_INFO) {
|
||||
len = snprintf(buff, maxlen, "[%.4d-%.2d-%.2d %.2d:%.2d:%.2d,%.3d] [%5d] [%6s] [%17s:%-4d] ",
|
||||
tm->year, tm->mon, tm->mday, tm->hour, tm->min, tm->sec, tm->usec / 1000, getpid(),
|
||||
tlog_get_level_string(info->level), info->file, info->line);
|
||||
len = snprintf(
|
||||
buff, maxlen,
|
||||
"[%.4d-%.2d-%.2d %.2d:%.2d:%.2d,%.3d] [%5d] [%6s] [%17s:%-4d] ",
|
||||
tm->year, tm->mon, tm->mday, tm->hour, tm->min, tm->sec,
|
||||
tm->usec / 1000, getpid(), tlog_get_level_string(info->level),
|
||||
info->file, info->line);
|
||||
} else {
|
||||
len = snprintf(buff, maxlen, "[%.4d-%.2d-%.2d %.2d:%.2d:%.2d,%.3d] [%5d] [%6s] [%22s] ",
|
||||
tm->year, tm->mon, tm->mday, tm->hour, tm->min, tm->sec, tm->usec / 1000, getpid(),
|
||||
tlog_get_level_string(info->level), info->func);
|
||||
len = snprintf(
|
||||
buff, maxlen,
|
||||
"[%.4d-%.2d-%.2d %.2d:%.2d:%.2d,%.3d] [%5d] [%6s] [%22s] ",
|
||||
tm->year, tm->mon, tm->mday, tm->hour, tm->min, tm->sec,
|
||||
tm->usec / 1000, getpid(), tlog_get_level_string(info->level),
|
||||
info->func);
|
||||
}
|
||||
|
||||
if (len < 0 || len >= maxlen) {
|
||||
|
|
@ -292,20 +247,16 @@ static int my_tlog_format(char* buff,
|
|||
/* return total length */
|
||||
return total_len;
|
||||
}
|
||||
int mylog_init(char* logfile,
|
||||
char* loglvl,
|
||||
int max_log_size,
|
||||
int max_log_count)
|
||||
int mylog_init(char* logfile, char* loglvl, int max_log_size, int max_log_count)
|
||||
{
|
||||
int flag = 0;
|
||||
int rc = 0;
|
||||
int flag = 0;
|
||||
int rc = 0;
|
||||
|
||||
if (isatty(STDERR_FILENO)) {
|
||||
flag = TLOG_SCREEN_COLOR;
|
||||
}
|
||||
|
||||
rc = tlog_init(logfile, max_log_size,
|
||||
max_log_count, 0, flag);
|
||||
rc = tlog_init(logfile, max_log_size, max_log_count, 0, flag);
|
||||
if (rc >= 0) {
|
||||
rc = tlog_setlevel(name_to_level(loglvl));
|
||||
}
|
||||
|
|
@ -315,22 +266,13 @@ int mylog_init(char* logfile,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int mylog_setlevel(char* level)
|
||||
{
|
||||
return tlog_setlevel(name_to_level(level));
|
||||
}
|
||||
int mylog_setlevel(char* level) { return tlog_setlevel(name_to_level(level)); }
|
||||
|
||||
void mylog_fini()
|
||||
{
|
||||
tlog_exit();
|
||||
}
|
||||
void mylog_fini() { tlog_exit(); }
|
||||
|
||||
static _Thread_local ectx_t ectx;
|
||||
|
||||
void set_error(char* file,
|
||||
char* func,
|
||||
int line,
|
||||
int code)
|
||||
void set_error(char* file, char* func, int line, int code)
|
||||
{
|
||||
ectx.file = file;
|
||||
ectx.func = func;
|
||||
|
|
@ -339,28 +281,21 @@ void set_error(char* file,
|
|||
errno = code;
|
||||
}
|
||||
|
||||
ectx_t* get_ectx()
|
||||
{
|
||||
return &ectx;
|
||||
}
|
||||
ectx_t* get_ectx() { return &ectx; }
|
||||
|
||||
static char* xce_err_str[] = {
|
||||
"invalid job",
|
||||
"invalid worker",
|
||||
"duplicated jobs",
|
||||
"duplicated workers",
|
||||
"bad opcode",
|
||||
"unknown role",
|
||||
"unknown resource",
|
||||
"unknown queue",
|
||||
"unknown group",
|
||||
"internal error",
|
||||
NULL
|
||||
};
|
||||
static char* xce_err_str[] = { "invalid job",
|
||||
"invalid worker",
|
||||
"duplicated jobs",
|
||||
"duplicated workers",
|
||||
"bad opcode",
|
||||
"unknown role",
|
||||
"unknown resource",
|
||||
"unknown queue",
|
||||
"unknown group",
|
||||
"internal error",
|
||||
NULL };
|
||||
|
||||
int xce_strerror_r(int errnum,
|
||||
char* buf,
|
||||
size_t bufsize)
|
||||
int xce_strerror_r(int errnum, char* buf, size_t bufsize)
|
||||
{
|
||||
if (errnum < XCE_ERRNO_BASE) {
|
||||
return strerror_r(errnum, buf, bufsize);
|
||||
|
|
@ -371,14 +306,11 @@ int xce_strerror_r(int errnum,
|
|||
return -1;
|
||||
}
|
||||
|
||||
strncpy(buf, xce_err_str[errnum - XCE_ERRNO_BASE],
|
||||
bufsize);
|
||||
strncpy(buf, xce_err_str[errnum - XCE_ERRNO_BASE], bufsize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int copy_int_list(int** dst,
|
||||
int* src,
|
||||
int count)
|
||||
int copy_int_list(int** dst, int* src, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -399,8 +331,7 @@ int copy_int_list(int** dst,
|
|||
return count;
|
||||
}
|
||||
|
||||
int copy_strlist(xce_strlist_t* dst,
|
||||
xce_strlist_t src)
|
||||
int copy_strlist(xce_strlist_t* dst, xce_strlist_t src)
|
||||
{
|
||||
if (!dst) {
|
||||
return -1;
|
||||
|
|
@ -428,8 +359,7 @@ int copy_strlist(xce_strlist_t* dst,
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
void free_resval_with_idx_list(xce_val_with_idx_t*** vals,
|
||||
int count)
|
||||
void free_resval_with_idx_list(xce_val_with_idx_t*** vals, int count)
|
||||
{
|
||||
xce_val_with_idx_t** resvals = *vals;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ vtask_t* vtask_alloc()
|
|||
return task;
|
||||
}
|
||||
|
||||
int vtask_init(vtask_t* task,
|
||||
vtask_func_t entry,
|
||||
endpoint_t* ep)
|
||||
int vtask_init(vtask_t* task, vtask_func_t entry, endpoint_t* ep)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
|
@ -54,10 +52,8 @@ void vcpu_idle(vcpu_t* vcpu)
|
|||
vtaskmgr_t* vtaskmgr = (vtaskmgr_t*)vcpu->owner;
|
||||
|
||||
vcpu->task = NULL;
|
||||
cbuf_put(&(vtaskmgr->wbuf),
|
||||
(void*)&(vcpu->cpuid));
|
||||
cbuf_get(&(vcpu->wbuf),
|
||||
(void*)&(vcpu->task));
|
||||
cbuf_put(&(vtaskmgr->wbuf), (void*)&(vcpu->cpuid));
|
||||
cbuf_get(&(vcpu->wbuf), (void*)&(vcpu->task));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -104,9 +100,7 @@ static void* vcpu_entry(void* arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int vcpu_init(vcpu_t* vcpu,
|
||||
int cpuid,
|
||||
void* owner)
|
||||
int vcpu_init(vcpu_t* vcpu, int cpuid, void* owner)
|
||||
{
|
||||
vcpu->state = VCPU_IDLE;
|
||||
vcpu->vcpu = 0;
|
||||
|
|
@ -122,8 +116,7 @@ int vcpu_start(vcpu_t* vcpu)
|
|||
{
|
||||
int rc;
|
||||
|
||||
rc = pthread_create(&(vcpu->vcpu), NULL,
|
||||
&vcpu_entry, vcpu);
|
||||
rc = pthread_create(&(vcpu->vcpu), NULL, &vcpu_entry, vcpu);
|
||||
if (rc != 0) {
|
||||
vcpu->state = VCPU_ERR;
|
||||
return -errno;
|
||||
|
|
@ -166,8 +159,7 @@ static void taskq_item_killer(data_item_t* it)
|
|||
}
|
||||
}
|
||||
|
||||
int vtaskmgr_init(vtaskmgr_t* vtaskmgr,
|
||||
int nvcpus)
|
||||
int vtaskmgr_init(vtaskmgr_t* vtaskmgr, int nvcpus)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -177,23 +169,18 @@ int vtaskmgr_init(vtaskmgr_t* vtaskmgr,
|
|||
|
||||
vtaskmgr->dispatcher = 0;
|
||||
vtaskmgr->n_vcpus = nvcpus;
|
||||
vtaskmgr->vcpus = (vcpu_t*)calloc(nvcpus,
|
||||
sizeof(vcpu_t));
|
||||
vtaskmgr->vcpus = (vcpu_t*)calloc(nvcpus, sizeof(vcpu_t));
|
||||
if (vtaskmgr->vcpus == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
for (i = 0; i < nvcpus; i++) {
|
||||
vcpu_init(&(vtaskmgr->vcpus[i]),
|
||||
i, vtaskmgr);
|
||||
vcpu_init(&(vtaskmgr->vcpus[i]), i, vtaskmgr);
|
||||
}
|
||||
|
||||
cbuf_init(&(vtaskmgr->wbuf),
|
||||
nvcpus, sizeof(int));
|
||||
cbuf_init(&(vtaskmgr->wtbuf),
|
||||
1, sizeof(int));
|
||||
cbuf_init(&(vtaskmgr->wbuf), nvcpus, sizeof(int));
|
||||
cbuf_init(&(vtaskmgr->wtbuf), 1, sizeof(int));
|
||||
|
||||
dataq_init(&(vtaskmgr->taskq),
|
||||
taskq_item_killer);
|
||||
dataq_init(&(vtaskmgr->taskq), taskq_item_killer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -207,8 +194,7 @@ static vcpu_t* pick_idle_vcpu(vtaskmgr_t* vtaskmgr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
TRACE("%s pick idle cpu #%d",
|
||||
__func__, i);
|
||||
TRACE("%s pick idle cpu #%d", __func__, i);
|
||||
|
||||
return &(vtaskmgr->vcpus[i]);
|
||||
}
|
||||
|
|
@ -224,8 +210,7 @@ static int vtask_eligible(data_item_t* data)
|
|||
}
|
||||
|
||||
eligible = !(endpoint_is_task_blocked(task->ctx.ep));
|
||||
TRACE("%s vtask %p is %s",
|
||||
__func__, task,
|
||||
TRACE("%s vtask %p is %s", __func__, task,
|
||||
eligible ? "eligible" : "not eligible");
|
||||
|
||||
return eligible;
|
||||
|
|
@ -246,11 +231,9 @@ static vtask_t* pick_eligible_task(vtaskmgr_t* vtaskmgr)
|
|||
return task;
|
||||
}
|
||||
|
||||
static int bind_vtask(vtask_t* task,
|
||||
vcpu_t* vcpu)
|
||||
static int bind_vtask(vtask_t* task, vcpu_t* vcpu)
|
||||
{
|
||||
TRACE("binding task %p to cpu#%d\n",
|
||||
task, vcpu->cpuid);
|
||||
TRACE("binding task %p to cpu#%d\n", task, vcpu->cpuid);
|
||||
|
||||
if (task != NULL) {
|
||||
endpoint_block_tasks(task->ctx.ep);
|
||||
|
|
@ -294,8 +277,8 @@ int vtaskmgr_start(vtaskmgr_t* vtaskmgr)
|
|||
{
|
||||
int i, rc;
|
||||
|
||||
rc = pthread_create(&(vtaskmgr->dispatcher), NULL,
|
||||
&vdispatcher_entry, vtaskmgr);
|
||||
rc = pthread_create(&(vtaskmgr->dispatcher), NULL, &vdispatcher_entry,
|
||||
vtaskmgr);
|
||||
if (rc != 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
|
@ -345,14 +328,12 @@ void vtaskmgr_fini(vtaskmgr_t* vtaskmgr)
|
|||
return;
|
||||
}
|
||||
|
||||
int vtask_enq(vtaskmgr_t* vtaskmgr,
|
||||
vtask_t* task)
|
||||
int vtask_enq(vtaskmgr_t* vtaskmgr, vtask_t* task)
|
||||
{
|
||||
int rc = 0;
|
||||
ioctx_ref(&(task->ctx));
|
||||
|
||||
rc = dataq_enq(&(vtaskmgr->taskq),
|
||||
&(task->ctx.link));
|
||||
rc = dataq_enq(&(vtaskmgr->taskq), &(task->ctx.link));
|
||||
if (rc >= 0) {
|
||||
/* wake up task dispatcher */
|
||||
task->owner = vtaskmgr;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@
|
|||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
static void kill_timewindow_time(xce_timewindow_time_t* t)
|
||||
{
|
||||
FREEUP(t);
|
||||
}
|
||||
static void kill_timewindow_time(xce_timewindow_time_t* t) { FREEUP(t); }
|
||||
|
||||
static void kill_timewindow_seg_config(xce_timewindow_seg_config_t* s)
|
||||
{
|
||||
|
|
@ -49,7 +46,8 @@ void free_timewindow_config(xce_timewindow_config_t* w)
|
|||
kill_timewindow_config(w);
|
||||
}
|
||||
|
||||
static xce_timewindow_seg_config_t* dup_timewindow_seg_config(xce_timewindow_seg_config_t* src)
|
||||
static xce_timewindow_seg_config_t*
|
||||
dup_timewindow_seg_config(xce_timewindow_seg_config_t* src)
|
||||
{
|
||||
xce_timewindow_seg_config_t* seg = NULL;
|
||||
|
||||
|
|
@ -72,8 +70,10 @@ static xce_timewindow_seg_config_t* dup_timewindow_seg_config(xce_timewindow_seg
|
|||
return NULL;
|
||||
}
|
||||
|
||||
seg->open = (xce_timewindow_time_t*)calloc(1, sizeof(xce_timewindow_time_t));
|
||||
seg->close = (xce_timewindow_time_t*)calloc(1, sizeof(xce_timewindow_time_t));
|
||||
seg->open
|
||||
= (xce_timewindow_time_t*)calloc(1, sizeof(xce_timewindow_time_t));
|
||||
seg->close
|
||||
= (xce_timewindow_time_t*)calloc(1, sizeof(xce_timewindow_time_t));
|
||||
if ((seg->open == NULL) || (seg->close == NULL)) {
|
||||
kill_timewindow_seg_config(seg);
|
||||
errno = ENOMEM;
|
||||
|
|
@ -103,8 +103,8 @@ xce_timewindow_config_t* dup_timewindow_config(xce_timewindow_config_t* src)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
w->segs = (xce_timewindow_seg_config_t**)calloc(src->nsegs,
|
||||
sizeof(xce_timewindow_seg_config_t*));
|
||||
w->segs = (xce_timewindow_seg_config_t**)calloc(
|
||||
src->nsegs, sizeof(xce_timewindow_seg_config_t*));
|
||||
if (w->segs == NULL) {
|
||||
kill_timewindow_config(w);
|
||||
errno = ENOMEM;
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
#include "utils.h"
|
||||
#include "xce/errnox.h"
|
||||
|
||||
int __wrap___xpg_strerror_r(int errnum,
|
||||
char* buf,
|
||||
size_t bufsize)
|
||||
int __wrap___xpg_strerror_r(int errnum, char* buf, size_t bufsize)
|
||||
{
|
||||
return xce_strerror_r(errnum, buf, bufsize);
|
||||
}
|
||||
|
|
@ -18,33 +16,27 @@ static void xce_perror_(const char* s, int errnum)
|
|||
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,
|
||||
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);
|
||||
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 xce_perror(const char* s) { xce_perror_(s, errno); }
|
||||
|
||||
void __wrap_perror(const char* s)
|
||||
{
|
||||
xce_perror(s);
|
||||
}
|
||||
void __wrap_perror(const char* s) { xce_perror(s); }
|
||||
|
||||
int __wrap_printf(const char* fmt, ...)
|
||||
{
|
||||
105
src/lib/xceapi.c
105
src/lib/xceapi.c
|
|
@ -3,8 +3,7 @@
|
|||
#include "utils.h"
|
||||
#include "xceapi.h"
|
||||
|
||||
int xce_hello(xce_ctx_t* ctx,
|
||||
char* msg)
|
||||
int xce_hello(xce_ctx_t* ctx, char* msg)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc, status;
|
||||
|
|
@ -66,25 +65,14 @@ int xce_shutdown(xce_ctx_t* ctx)
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_get(xce_ctx_t* ctx,
|
||||
int table,
|
||||
void*** data)
|
||||
int xce_get(xce_ctx_t* ctx, int table, void*** data)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
int status;
|
||||
xce_match_t condition = {
|
||||
.type = MatchCondition_condition_matchall
|
||||
};
|
||||
xce_get_t get = {
|
||||
.table = table,
|
||||
.condition = &condition
|
||||
};
|
||||
dataset_t getreply = {
|
||||
.table = table,
|
||||
.nrows = 0,
|
||||
.rows = NULL
|
||||
};
|
||||
xce_match_t condition = { .type = MatchCondition_condition_matchall };
|
||||
xce_get_t get = { .table = table, .condition = &condition };
|
||||
dataset_t getreply = { .table = table, .nrows = 0, .rows = NULL };
|
||||
|
||||
if (ctx == NULL) {
|
||||
return -EINVAL;
|
||||
|
|
@ -122,18 +110,14 @@ int xce_get(xce_ctx_t* ctx,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xce_reslist(xce_ctx_t* ctx,
|
||||
xce_resource_t*** res)
|
||||
int xce_reslist(xce_ctx_t* ctx, xce_resource_t*** res)
|
||||
{
|
||||
int table = Data_data_resources;
|
||||
|
||||
return xce_get(ctx, table, (void***)res);
|
||||
}
|
||||
|
||||
int xce_resval(xce_ctx_t* ctx,
|
||||
char* host,
|
||||
char* res,
|
||||
xce_resval_t*** vals)
|
||||
int xce_resval(xce_ctx_t* ctx, char* host, char* res, xce_resval_t*** vals)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
|
|
@ -196,9 +180,7 @@ int xce_resval(xce_ctx_t* ctx,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xce_join(xce_ctx_t* ctx,
|
||||
int role,
|
||||
hostattrs_t* attrs)
|
||||
int xce_join(xce_ctx_t* ctx, int role, hostattrs_t* attrs)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc, status;
|
||||
|
|
@ -228,22 +210,16 @@ int xce_join(xce_ctx_t* ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_workerlist(xce_ctx_t* ctx,
|
||||
xce_worker_t*** workers)
|
||||
int xce_workerlist(xce_ctx_t* ctx, xce_worker_t*** workers)
|
||||
{
|
||||
int table = Data_data_workers;
|
||||
|
||||
return xce_get(ctx, table, (void***)workers);
|
||||
}
|
||||
|
||||
int xce_free_workers(int nworkers,
|
||||
xce_worker_t* workers)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int xce_free_workers(int nworkers, xce_worker_t* workers) { return 0; }
|
||||
|
||||
int xce_jobdispatch(xce_ctx_t* ctx,
|
||||
xce_job_dispatch_t* info)
|
||||
int xce_jobdispatch(xce_ctx_t* ctx, xce_job_dispatch_t* info)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc, status;
|
||||
|
|
@ -274,8 +250,7 @@ int xce_jobdispatch(xce_ctx_t* ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_notify(xce_ctx_t* ctx,
|
||||
xce_notify_data_t* data)
|
||||
int xce_notify(xce_ctx_t* ctx, xce_notify_data_t* data)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
|
|
@ -298,9 +273,7 @@ int xce_notify(xce_ctx_t* ctx,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xce_jobsubmit(xce_ctx_t* ctx,
|
||||
xce_job_submit_t* submit,
|
||||
uint64_t* jobid)
|
||||
int xce_jobsubmit(xce_ctx_t* ctx, xce_job_submit_t* submit, uint64_t* jobid)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc, status;
|
||||
|
|
@ -334,9 +307,7 @@ int xce_jobsubmit(xce_ctx_t* ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_joblist_ex(xce_ctx_t* ctx,
|
||||
int sched,
|
||||
xce_job_t*** jobs)
|
||||
int xce_joblist_ex(xce_ctx_t* ctx, int sched, xce_job_t*** jobs)
|
||||
{
|
||||
int table;
|
||||
|
||||
|
|
@ -349,20 +320,17 @@ int xce_joblist_ex(xce_ctx_t* ctx,
|
|||
return xce_get(ctx, table, (void***)jobs);
|
||||
}
|
||||
|
||||
int xce_sched_joblist(xce_ctx_t* ctx,
|
||||
xce_job_t*** jobs)
|
||||
int xce_sched_joblist(xce_ctx_t* ctx, xce_job_t*** jobs)
|
||||
{
|
||||
return xce_joblist_ex(ctx, 1, jobs);
|
||||
}
|
||||
|
||||
int xce_joblist(xce_ctx_t* ctx,
|
||||
xce_job_t*** jobs)
|
||||
int xce_joblist(xce_ctx_t* ctx, xce_job_t*** jobs)
|
||||
{
|
||||
return xce_joblist_ex(ctx, 0, jobs);
|
||||
}
|
||||
|
||||
int xce_varlist(xce_ctx_t* ctx,
|
||||
xce_config_t*** vars)
|
||||
int xce_varlist(xce_ctx_t* ctx, xce_config_t*** vars)
|
||||
{
|
||||
#if 0
|
||||
int table = XCETables_conf;
|
||||
|
|
@ -372,8 +340,7 @@ int xce_varlist(xce_ctx_t* ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_queuelist(xce_ctx_t* ctx,
|
||||
xce_queue_t*** queues)
|
||||
int xce_queuelist(xce_ctx_t* ctx, xce_queue_t*** queues)
|
||||
{
|
||||
#if 0
|
||||
int table = XCETables_queues;
|
||||
|
|
@ -384,8 +351,7 @@ int xce_queuelist(xce_ctx_t* ctx,
|
|||
#endif
|
||||
}
|
||||
|
||||
int xce_free_queues(int nqueues,
|
||||
xce_queue_t* queues)
|
||||
int xce_free_queues(int nqueues, xce_queue_t* queues)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -399,9 +365,7 @@ int xce_free_queues(int nqueues,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_grouplist(xce_ctx_t* ctx,
|
||||
int group_type,
|
||||
xce_group_t*** groups)
|
||||
int xce_grouplist(xce_ctx_t* ctx, int group_type, xce_group_t*** groups)
|
||||
{
|
||||
#if 0
|
||||
int table;
|
||||
|
|
@ -421,15 +385,13 @@ int xce_grouplist(xce_ctx_t* ctx,
|
|||
#endif
|
||||
}
|
||||
|
||||
int xce_free_groups(int ngroups,
|
||||
xce_group_t* groups)
|
||||
int xce_free_groups(int ngroups, xce_group_t* groups)
|
||||
{
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xce_clusterconf(xce_ctx_t* ctx,
|
||||
xce_clusterconf_t** conf)
|
||||
int xce_clusterconf(xce_ctx_t* ctx, xce_clusterconf_t** conf)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc, status;
|
||||
|
|
@ -465,9 +427,7 @@ int xce_clusterconf(xce_ctx_t* ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_update_resvals(xce_ctx_t* ctx,
|
||||
int count,
|
||||
xce_resval_t** vals)
|
||||
int xce_update_resvals(xce_ctx_t* ctx, int count, xce_resval_t** vals)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
|
|
@ -512,14 +472,8 @@ int xce_update_resvals(xce_ctx_t* ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_update_jusage(xce_ctx_t* ctx,
|
||||
uint64_t jobid,
|
||||
int npids,
|
||||
int* pids,
|
||||
int ngids,
|
||||
int* pgids,
|
||||
int nusage,
|
||||
xce_rusage_t** usages)
|
||||
int xce_update_jusage(xce_ctx_t* ctx, uint64_t jobid, int npids, int* pids,
|
||||
int ngids, int* pgids, int nusage, xce_rusage_t** usages)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
|
|
@ -567,8 +521,7 @@ int xce_update_jusage(xce_ctx_t* ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_jobctrl(xce_ctx_t* ctx,
|
||||
xce_jobctrl_t* ctrl)
|
||||
int xce_jobctrl(xce_ctx_t* ctx, xce_jobctrl_t* ctrl)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
|
|
@ -600,8 +553,7 @@ int xce_jobctrl(xce_ctx_t* ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_queuectrl(xce_ctx_t* ctx,
|
||||
xce_queuectrl_t* ctrl)
|
||||
int xce_queuectrl(xce_ctx_t* ctx, xce_queuectrl_t* ctrl)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
|
|
@ -633,8 +585,7 @@ int xce_queuectrl(xce_ctx_t* ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
int xce_runtask(xce_ctx_t* ctx,
|
||||
xce_taskrun_t* runinfo)
|
||||
int xce_runtask(xce_ctx_t* ctx, xce_taskrun_t* runinfo)
|
||||
{
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
#include "utils.h"
|
||||
#include "xcectx.h"
|
||||
|
||||
static int handle_get_reply(xce_ctx_t* ctx,
|
||||
xce_reply_t* reply)
|
||||
static int handle_get_reply(xce_ctx_t* ctx, xce_reply_t* reply)
|
||||
{
|
||||
xce_data_t* getdata = reply->data.getdata;
|
||||
dataset_t* dataset = ctx->reply.u.get;
|
||||
|
|
@ -18,8 +17,7 @@ static int handle_get_reply(xce_ctx_t* ctx,
|
|||
return extract_data(dataset, getdata);
|
||||
}
|
||||
|
||||
static int handle_sub_reply(xce_ctx_t* ctx,
|
||||
xce_reply_t* reply)
|
||||
static int handle_sub_reply(xce_ctx_t* ctx, xce_reply_t* reply)
|
||||
{
|
||||
if (reply->data_which != RequestReply_data_jobid) {
|
||||
return -1;
|
||||
|
|
@ -29,8 +27,7 @@ static int handle_sub_reply(xce_ctx_t* ctx,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int handle_reply(xce_ctx_t* ctx,
|
||||
xce_reply_t* reply)
|
||||
static int handle_reply(xce_ctx_t* ctx, xce_reply_t* reply)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
@ -48,8 +45,7 @@ static int handle_reply(xce_ctx_t* ctx,
|
|||
case OPCode_clusterconf:
|
||||
rc = -1;
|
||||
if (reply->data_which == RequestReply_data_clusterconf) {
|
||||
MOVE_PTR(ctx->reply.u.clusterconf,
|
||||
reply->data.clusterconf);
|
||||
MOVE_PTR(ctx->reply.u.clusterconf, reply->data.clusterconf);
|
||||
rc = 1;
|
||||
}
|
||||
break;
|
||||
|
|
@ -93,15 +89,15 @@ static int vtask_entry(vtask_t* task)
|
|||
} else {
|
||||
int callnext = 1;
|
||||
|
||||
if ((request.opcode == OPCode_push) && (request.body_which == Request_body_pushmsg)) {
|
||||
if ((request.opcode == OPCode_push)
|
||||
&& (request.body_which == Request_body_pushmsg)) {
|
||||
|
||||
if (ctx->dataset == NULL) {
|
||||
ctx->dataset = (dataset_t*)calloc(1, sizeof(dataset_t));
|
||||
ctx->dataset->table = request.body.pushmsg->table;
|
||||
}
|
||||
|
||||
callnext = extract_data(ctx->dataset,
|
||||
request.body.pushmsg);
|
||||
callnext = extract_data(ctx->dataset, request.body.pushmsg);
|
||||
if (callnext) {
|
||||
FREEUP(request.body.pushmsg);
|
||||
request.body_which = Request_body_datamsg;
|
||||
|
|
@ -200,9 +196,7 @@ static int handle_io(struct epoll_event* p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_ctx_init(xce_ctx_t* ctx,
|
||||
char* name,
|
||||
char* key)
|
||||
int xce_ctx_init(xce_ctx_t* ctx, char* name, char* key)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
|
@ -254,8 +248,7 @@ void xce_ctx_fini(xce_ctx_t* ctx)
|
|||
return;
|
||||
}
|
||||
|
||||
int xce_ctx_set_handler(xce_ctx_t* ctx,
|
||||
xce_request_handler_t handler)
|
||||
int xce_ctx_set_handler(xce_ctx_t* ctx, xce_request_handler_t handler)
|
||||
{
|
||||
if ((ctx == NULL) || (handler == NULL)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -265,8 +258,7 @@ int xce_ctx_set_handler(xce_ctx_t* ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_ctx_set_endpoint(xce_ctx_t* ctx,
|
||||
endpoint_t* ep)
|
||||
int xce_ctx_set_endpoint(xce_ctx_t* ctx, endpoint_t* ep)
|
||||
{
|
||||
if ((ctx == NULL) || (ep == NULL)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -288,10 +280,8 @@ int xce_ctx_start(xce_ctx_t* ctx)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
endpoint_set_handler(ctx->ep,
|
||||
handle_io, ctx);
|
||||
rc = iomgr_monitor(&(ctx->iomgr),
|
||||
ctx->ep);
|
||||
endpoint_set_handler(ctx->ep, handle_io, ctx);
|
||||
rc = iomgr_monitor(&(ctx->iomgr), ctx->ep);
|
||||
if (rc < 0) {
|
||||
ctx->state = XCE_CTX_ERR;
|
||||
return rc;
|
||||
|
|
@ -312,8 +302,7 @@ int xce_ctx_stop(xce_ctx_t* ctx)
|
|||
}
|
||||
|
||||
if (ctx->ep != NULL) {
|
||||
iomgr_unmonitor(&(ctx->iomgr),
|
||||
ctx->ep);
|
||||
iomgr_unmonitor(&(ctx->iomgr), ctx->ep);
|
||||
ctx->ep = NULL;
|
||||
}
|
||||
iomgr_stop(&(ctx->iomgr));
|
||||
|
|
@ -323,8 +312,7 @@ int xce_ctx_stop(xce_ctx_t* ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int xce_wakeup(xce_ctx_t* ctx,
|
||||
int status)
|
||||
int xce_wakeup(xce_ctx_t* ctx, int status)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
@ -341,8 +329,7 @@ int xce_wakeup(xce_ctx_t* ctx,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int xce_try_wakeup(xce_ctx_t* ctx,
|
||||
int status)
|
||||
int xce_try_wakeup(xce_ctx_t* ctx, int status)
|
||||
{
|
||||
if (ctx == NULL) {
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#include "utils.h"
|
||||
#include "xlist.h"
|
||||
|
||||
int xlist_init(xlist_t* l,
|
||||
int delta)
|
||||
int xlist_init(xlist_t* l, int delta)
|
||||
{
|
||||
if ((l == NULL) || (delta <= 0)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -44,8 +43,7 @@ static int xlist_ensure(xlist_t* l)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int xlist_store(xlist_t* l,
|
||||
void* data)
|
||||
int xlist_store(xlist_t* l, void* data)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
|
@ -73,9 +71,7 @@ void xlist_clear(xlist_t* l)
|
|||
l->count = 0;
|
||||
}
|
||||
|
||||
int xlist_iter(xlist_t* l,
|
||||
xlist_iter_fn_t fn,
|
||||
void* data)
|
||||
int xlist_iter(xlist_t* l, xlist_iter_fn_t fn, void* data)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,12 @@ static void xstring_type_fini(objtype_t*);
|
|||
|
||||
static xstring_typedata_t xstring_typedata;
|
||||
|
||||
static objtype_t xstring = {
|
||||
.type = "xstring",
|
||||
.fn_create = (obj_create_fn_t)xstring_create,
|
||||
.fn_fini = xstring_fini,
|
||||
.fn_type_fini = (objtype_fini_fn_t)xstring_type_fini,
|
||||
.typedata = &xstring_typedata
|
||||
};
|
||||
static objtype_t xstring
|
||||
= { .type = "xstring",
|
||||
.fn_create = (obj_create_fn_t)xstring_create,
|
||||
.fn_fini = xstring_fini,
|
||||
.fn_type_fini = (objtype_fini_fn_t)xstring_type_fini,
|
||||
.typedata = &xstring_typedata };
|
||||
|
||||
static void xstring_obj_killer(myobj_t* obj)
|
||||
{
|
||||
|
|
@ -31,21 +30,16 @@ static void xstring_obj_killer(myobj_t* obj)
|
|||
free(obj);
|
||||
}
|
||||
|
||||
int register_xstring(objmgr_t* mgr,
|
||||
int nslots,
|
||||
int delta)
|
||||
int register_xstring(objmgr_t* mgr, int nslots, int delta)
|
||||
{
|
||||
ht_init(&(xstring_typedata.tab), nslots,
|
||||
string_hash_key);
|
||||
ht_init(&(xstring_typedata.tab), nslots, string_hash_key);
|
||||
zarray_init(&(xstring_typedata.strings), delta,
|
||||
(zarray_item_killer_t)xstring_obj_killer);
|
||||
|
||||
return objmgr_register(mgr, &xstring);
|
||||
}
|
||||
|
||||
static void* xstring_create(objmgr_t* mgr,
|
||||
objtype_t* type,
|
||||
va_list ap)
|
||||
static void* xstring_create(objmgr_t* mgr, objtype_t* type, va_list ap)
|
||||
{
|
||||
char* s = va_arg(ap, char*);
|
||||
char* p = NULL;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@
|
|||
#include "utils.h"
|
||||
#include "zarray.h"
|
||||
|
||||
int zarray_init(zarray_t* array,
|
||||
int delta,
|
||||
zarray_item_killer_t killer)
|
||||
int zarray_init(zarray_t* array, int delta, zarray_item_killer_t killer)
|
||||
{
|
||||
if ((array == NULL) || (delta <= 0)) {
|
||||
return -EINVAL;
|
||||
|
|
@ -24,8 +22,7 @@ int zarray_init(zarray_t* array,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int zarray_ensure_items(zarray_t* array,
|
||||
int mincap)
|
||||
static int zarray_ensure_items(zarray_t* array, int mincap)
|
||||
{
|
||||
int nc, i;
|
||||
void* p;
|
||||
|
|
@ -58,8 +55,7 @@ static int zarray_ensure_items(zarray_t* array,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int zarray_store(zarray_t* array,
|
||||
void* data)
|
||||
int zarray_store(zarray_t* array, void* data)
|
||||
{
|
||||
int rc, i;
|
||||
|
||||
|
|
@ -99,8 +95,7 @@ int zarray_store(zarray_t* array,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int zarray_clear(zarray_t* array,
|
||||
int idx)
|
||||
int zarray_clear(zarray_t* array, int idx)
|
||||
{
|
||||
if (array == NULL) {
|
||||
return -EINVAL;
|
||||
|
|
@ -141,9 +136,7 @@ void zarray_fini(zarray_t* array)
|
|||
}
|
||||
}
|
||||
|
||||
int zarray_iter_ex(zarray_t* array,
|
||||
xlist_t* l,
|
||||
void* arg)
|
||||
int zarray_iter_ex(zarray_t* array, xlist_t* l, void* arg)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
|
@ -169,9 +162,7 @@ int zarray_iter_ex(zarray_t* array,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int zarray_iter(zarray_t* array,
|
||||
zarray_iter_fn_t f,
|
||||
void* arg)
|
||||
int zarray_iter(zarray_t* array, zarray_iter_fn_t f, void* arg)
|
||||
{
|
||||
int rc;
|
||||
xlist_t l;
|
||||
|
|
@ -189,8 +180,7 @@ int zarray_iter(zarray_t* array,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int zarray_del(zarray_t* array,
|
||||
int idx)
|
||||
int zarray_del(zarray_t* array, int idx)
|
||||
{
|
||||
void* ptr = NULL;
|
||||
|
||||
|
|
@ -222,9 +212,7 @@ int zarray_del(zarray_t* array,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int zarray_put(zarray_t* array,
|
||||
int idx,
|
||||
void* data)
|
||||
int zarray_put(zarray_t* array, int idx, void* data)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
@ -255,8 +243,7 @@ int zarray_put(zarray_t* array,
|
|||
return rc;
|
||||
}
|
||||
|
||||
void* zarray_get(zarray_t* array,
|
||||
int idx)
|
||||
void* zarray_get(zarray_t* array, int idx)
|
||||
{
|
||||
void* ptr = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ endif
|
|||
|
||||
add_project_arguments('-DVERSION_COMMIT_ID='+get_option('commit_id'), language: 'c')
|
||||
|
||||
c_compiler_id = meson.get_compiler('c').get_id()
|
||||
if c_compiler_id == 'gcc' or c_compiler_id == 'clang'
|
||||
add_project_link_arguments('-Wl,--wrap=printf', language:'c')
|
||||
add_project_link_arguments('-Wl,--wrap=perror', language: 'c')
|
||||
endif
|
||||
|
||||
include_dir = include_directories('include', 'include/xce')
|
||||
|
||||
subdir('lib')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue