improve api server support

This commit is contained in:
Rongsong Shen 2026-01-23 17:33:10 +08:00
parent 3b728e5135
commit 9e07a1b227
7 changed files with 141 additions and 44 deletions

View file

@ -52,6 +52,52 @@ void* xce_request_body(xce_request_t* req)
return NULL;
}
char* xce_request_msg_name(xce_request_t* req)
{
switch (req->body_which) {
case Request_body_nomsg:
return "nomsg";
case Request_body_replymsg:
return "replymsg";
case Request_body_hellomsg:
return "hellomsg";
case Request_body_joinmsg:
return "joinmsg";
case Request_body_configpushmsg:
return "configmsg";
case Request_body_pushmsg:
return "pushmsg";
case Request_body_getmsg:
return "getmsg";
case Request_body_datamsg:
return "datamsg";
case Request_body_dispatchmsg:
return "dispatchmsg";
case Request_body_jobstartmsg:
return "jobstartmsg";
case Request_body_notifymsg:
return "notifymsg";
case Request_body_jobsubmsg:
return "jobsubmsg";
case Request_body_updatemsg:
return "updatemsg";
case Request_body_jobctrlmsg:
return "jobctrlmsg";
case Request_body_queuectrlmsg:
return "queuectrlmsg";
case Request_body_runtaskmsg:
return "runtaskmsg";
case Request_body_preasonmsg:
return "preasonmsg";
case Request_body_clrpreasonmsg:
return "clrpreasonmsg";
default:
break;
}
return "unknown";
}
char* xce_request_op_name(xce_request_t* req)
{
switch (req->opcode) {
@ -104,8 +150,9 @@ char* xce_request_op_name(xce_request_t* req)
return "unknown";
}
void *xce_val_ptr(xce_val_t *v) {
switch(v->which) {
void* xce_val_ptr(xce_val_t* v)
{
switch (v->which) {
case Value_u_ivalue32:
return &(v->u.ivalue32);
case Value_u_uvalue32:
@ -127,8 +174,9 @@ void *xce_val_ptr(xce_val_t *v) {
return NULL;
}
void* xce_configdata_ptr(xce_configdata_t *d) {
switch(d->data_which) {
void* xce_configdata_ptr(xce_configdata_t* d)
{
switch (d->data_which) {
case ConfigData_data_schedconfig:
return d->data.conf4sched;
case ConfigData_data_workerconfig:
@ -142,8 +190,9 @@ void* xce_configdata_ptr(xce_configdata_t *d) {
return NULL;
}
void* xce_data_ptr(xce_data_t *d) {
switch(d->table) {
void* xce_data_ptr(xce_data_t* d)
{
switch (d->table) {
case Data_data_schedjobs:
return d->data.jobs;
case Data_data_schedworkers:
@ -162,8 +211,9 @@ void* xce_data_ptr(xce_data_t *d) {
return NULL;
}
void* xce_update_data_ptr(xce_update_data_t *d) {
switch(d->table) {
void* xce_update_data_ptr(xce_update_data_t* d)
{
switch (d->table) {
case Update_data_nodata:
break;
case Update_data_resvals:
@ -176,8 +226,9 @@ void* xce_update_data_ptr(xce_update_data_t *d) {
return NULL;
}
void* xce_notify_data_ptr(xce_notify_data_t *d) {
switch(d->event) {
void* xce_notify_data_ptr(xce_notify_data_t* d)
{
switch (d->event) {
case NotifyData_data_jobPidInfo:
return d->data.pidinfo;
case NotifyData_data_jobFailInfo:
@ -187,19 +238,19 @@ void* xce_notify_data_ptr(xce_notify_data_t *d) {
case NotifyData_data_jobFinishInfo:
return d->data.finishinfo;
case NotifyData_data_schedStartJob:
return (void *)d->data.sched_start_job;
return (void*)d->data.sched_start_job;
case NotifyData_data_schedExitJob:
return (void *)d->data.sched_exit_job;
return (void*)d->data.sched_exit_job;
case NotifyData_data_schedFailJob:
return (void *)d->data.sched_fail_job;
return (void*)d->data.sched_fail_job;
case NotifyData_data_schedUpdateJob:
return d->data.sched_update_job;
case NotifyData_data_schedUpdateResvals:
return d->data.sched_update_resvals;
case NotifyData_data_stoppedJob:
return (void *)d->data.stopped_job;
return (void*)d->data.stopped_job;
case NotifyData_data_resumedJob:
return (void *)d->data.resumed_job;
return (void*)d->data.resumed_job;
case NotifyData_data_ckptinfo:
return d->data.ckptinfo;
case NotifyData_data_schedUpdateQueue:
@ -211,7 +262,7 @@ void* xce_notify_data_ptr(xce_notify_data_t *d) {
case NotifyData_data_taskFinish:
return d->data.taskfinish;
case NotifyData_data_postDoneJob:
return (void *)d->data.pdone_job;
return (void*)d->data.pdone_job;
case NotifyData_data_schedJobRusages:
return d->data.sched_job_rusages;
default:
@ -220,8 +271,9 @@ void* xce_notify_data_ptr(xce_notify_data_t *d) {
return NULL;
}
void* xce_jobctrl_data_ptr(xce_jobctrl_t *d) {
switch(d->action) {
void* xce_jobctrl_data_ptr(xce_jobctrl_t* d)
{
switch (d->action) {
case JobControl_u_siginfo:
return d->u.siginfo;
case JobControl_u_ckptoption:
@ -232,8 +284,9 @@ void* xce_jobctrl_data_ptr(xce_jobctrl_t *d) {
return NULL;
}
void* xce_reply_data_ptr(xce_reply_t *reply) {
switch(reply->data_which) {
void* xce_reply_data_ptr(xce_reply_t* reply)
{
switch (reply->data_which) {
case RequestReply_data_nodata:
break;
case RequestReply_data_debugmsg:
@ -241,7 +294,7 @@ void* xce_reply_data_ptr(xce_reply_t *reply) {
case RequestReply_data_getdata:
return reply->data.getdata;
case RequestReply_data_jobid:
return (void *)reply->data.jobid;
return (void*)reply->data.jobid;
case RequestReply_data_clusterconf:
return reply->data.clusterconf;
default:
@ -249,3 +302,25 @@ void* xce_reply_data_ptr(xce_reply_t *reply) {
}
return NULL;
}
char* xce_dataset_table(int table)
{
switch (table) {
case Data_data_schedjobs:
return "schedjobs";
case Data_data_jobs:
return "jobs";
case Data_data_workers:
return "workers";
case Data_data_schedworkers:
return "schedworkers";
case Data_data_resources:
return "resources";
case Data_data_resvals:
return "resvals";
default:
break;
}
return "unknown";
}

View file

@ -281,6 +281,7 @@ int xce_push_data_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data,
data1.table = data->table;
switch (data->table) {
case Data_data_schedjobs:
case Data_data_jobs:
nrows = data->data.jobs->n_total;
data1.data.jobs = (xce_jobs_data_t*)calloc(1, sizeof(xce_jobs_data_t));
if (data1.data.jobs == NULL) {
@ -288,6 +289,7 @@ int xce_push_data_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data,
}
break;
case Data_data_schedworkers:
case Data_data_workers:
nrows = data->data.workers->n_total;
data1.data.workers
= (xce_workers_data_t*)calloc(1, sizeof(xce_workers_data_t));
@ -295,6 +297,10 @@ int xce_push_data_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data,
rc = -ENOMEM;
}
break;
case Data_data_resources:
break;
case Data_data_resvals:
break;
default:
rc = -EINVAL;
break;
@ -324,6 +330,7 @@ int xce_push_data_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data,
switch (data->table) {
case Data_data_schedjobs:
case Data_data_jobs:
data1.data.jobs->n_total = data->data.jobs->n_total;
data1.data.jobs->pos = pos;
data1.data.jobs->count = nc;
@ -334,6 +341,7 @@ int xce_push_data_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data,
}
break;
case Data_data_schedworkers:
case Data_data_workers:
data1.data.workers->n_total = data->data.workers->n_total;
data1.data.workers->pos = pos;
data1.data.workers->count = nc;
@ -344,6 +352,10 @@ int xce_push_data_req(endpoint_t* ep, xce_peerinfo_t* from, xce_data_t* data,
= &(data->data.workers->workers[pos]);
}
break;
case Data_data_resources:
break;
case Data_data_resvals:
break;
default:
break;
}