reformat code and job array

This commit is contained in:
Rongsong Shen 2025-11-07 16:14:27 +08:00
parent a665ccd4fe
commit 9ff857db9f
64 changed files with 1497 additions and 2476 deletions

View file

@ -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));