forked from lei.chen/myxce
update controller code
This commit is contained in:
parent
2836d196da
commit
41f56fa6ed
54 changed files with 9688 additions and 214 deletions
103
src/controller/opupd.c
Normal file
103
src/controller/opupd.c
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cluster.h"
|
||||
#include "xce/cluster_def.h"
|
||||
|
||||
static int
|
||||
do_update_resvals(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
ep_private_t* priv = NULL;
|
||||
int rc = -EPERM;
|
||||
xce_reply_t reply;
|
||||
|
||||
priv = (ep_private_t*)ep->data;
|
||||
TRACE("endpoint %p priv data %p", ep, priv);
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
if (priv != NULL) {
|
||||
int idx = priv->u.idx;
|
||||
|
||||
if ((priv->role == HostRole_worker) && (idx >= 0)) {
|
||||
worker_t* w;
|
||||
|
||||
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);
|
||||
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);
|
||||
DEREF_OBJ(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reply.status = rc;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
xce_reply(ep, c->myhost, &reply);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_jobrusage(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
rc = update_job_rusages(c, ep, request);
|
||||
|
||||
reply.status = rc;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
xce_reply(ep, c->myhost, &reply);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int do_update_op(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* request)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
||||
init_reply_by_req(&reply, request);
|
||||
|
||||
switch (request->body.updatemsg->table) {
|
||||
case Update_data_resvals:
|
||||
rc = do_update_resvals(c, ep, request);
|
||||
break;
|
||||
case Update_data_jobrusages:
|
||||
rc = do_update_jobrusage(c, ep, request);
|
||||
break;
|
||||
default:
|
||||
rc = -ENOENT;
|
||||
|
||||
reply.status = rc;
|
||||
reply.data_which = RequestReply_data_nodata;
|
||||
xce_reply(ep, c->myhost, &reply);
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue