reformat code and job array
This commit is contained in:
parent
a665ccd4fe
commit
9ff857db9f
64 changed files with 1497 additions and 2476 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue